From 6e9b4f0e9ce4ccd6089c18b205065ef7fa077484 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 17 Feb 2016 01:09:32 -0800 Subject: [PATCH] Convert all array() syntax to [] Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b --- api.php | 6 +- img_auth.php | 16 +- includes/AjaxDispatcher.php | 4 +- includes/AjaxResponse.php | 4 +- includes/AuthPlugin.php | 10 +- includes/AutoLoader.php | 2 +- includes/Autopromote.php | 14 +- includes/Block.php | 130 +- includes/Category.php | 46 +- includes/CategoryFinder.php | 32 +- includes/CategoryViewer.php | 78 +- includes/Collation.php | 200 +- includes/DefaultSettings.php | 766 +++---- includes/EditPage.php | 358 +-- includes/EventRelayerGroup.php | 4 +- includes/Fallback.php | 4 +- includes/FauxRequest.php | 12 +- includes/Feed.php | 4 +- includes/FeedUtils.php | 12 +- includes/FileDeleteForm.php | 24 +- includes/ForkController.php | 8 +- includes/FormOptions.php | 12 +- includes/GlobalFunctions.php | 138 +- includes/HistoryBlob.php | 48 +- includes/Hooks.php | 12 +- includes/Html.php | 154 +- includes/HtmlFormatter.php | 32 +- includes/HttpFunctions.php | 66 +- includes/Licenses.php | 18 +- includes/Linker.php | 184 +- includes/MWNamespace.php | 20 +- includes/MWTimestamp.php | 12 +- includes/MagicWord.php | 74 +- includes/MediaWiki.php | 36 +- includes/MediaWikiVersionFetcher.php | 2 +- includes/MergeHistory.php | 42 +- includes/Message.php | 52 +- includes/MimeMagic.php | 44 +- includes/MovePage.php | 86 +- includes/NoLocalSettings.php | 6 +- includes/OutputHandler.php | 8 +- includes/OutputPage.php | 348 +-- includes/PageProps.php | 38 +- includes/PathRouter.php | 28 +- includes/Preferences.php | 436 ++-- includes/PrefixSearch.php | 46 +- includes/ProtectionForm.php | 70 +- includes/Revision.php | 142 +- includes/RevisionList.php | 22 +- includes/Sanitizer.php | 182 +- includes/Setup.php | 50 +- includes/SiteConfiguration.php | 58 +- includes/SiteStats.php | 34 +- includes/Status.php | 24 +- includes/StreamFile.php | 4 +- includes/StubObject.php | 8 +- includes/TemplateParser.php | 6 +- includes/Title.php | 430 ++-- includes/TitleArray.php | 2 +- includes/WatchedItem.php | 40 +- includes/WebRequest.php | 34 +- includes/WebResponse.php | 38 +- includes/WebStart.php | 2 +- includes/WikiMap.php | 6 +- includes/Xml.php | 120 +- includes/XmlSelect.php | 8 +- includes/actions/Action.php | 6 +- includes/actions/CachedAction.php | 10 +- includes/actions/CreditsAction.php | 16 +- includes/actions/DeleteAction.php | 4 +- includes/actions/EditAction.php | 6 +- includes/actions/FormAction.php | 12 +- includes/actions/HistoryAction.php | 162 +- includes/actions/InfoAction.php | 242 +-- includes/actions/MarkpatrolledAction.php | 6 +- includes/actions/ProtectAction.php | 4 +- includes/actions/PurgeAction.php | 4 +- includes/actions/RawAction.php | 4 +- includes/actions/RevertAction.php | 16 +- includes/actions/RollbackAction.php | 4 +- includes/actions/SpecialPageAction.php | 4 +- includes/actions/WatchAction.php | 8 +- includes/api/ApiBase.php | 156 +- includes/api/ApiBlock.php | 20 +- includes/api/ApiCheckToken.php | 22 +- includes/api/ApiClearHasMsg.php | 4 +- includes/api/ApiComparePages.php | 30 +- includes/api/ApiContinuationManager.php | 22 +- includes/api/ApiCreateAccount.php | 48 +- includes/api/ApiDelete.php | 42 +- includes/api/ApiEditPage.php | 124 +- includes/api/ApiEmailUser.php | 30 +- includes/api/ApiErrorFormatter.php | 54 +- includes/api/ApiExpandTemplates.php | 50 +- includes/api/ApiFeedContributions.php | 46 +- includes/api/ApiFeedRecentChanges.php | 48 +- includes/api/ApiFeedWatchlist.php | 36 +- includes/api/ApiFileRevert.php | 28 +- includes/api/ApiFormatBase.php | 24 +- includes/api/ApiFormatJson.php | 38 +- includes/api/ApiFormatPhp.php | 24 +- includes/api/ApiFormatXml.php | 46 +- includes/api/ApiHelp.php | 108 +- includes/api/ApiHelpParamValueMessage.php | 2 +- includes/api/ApiImageRotate.php | 34 +- includes/api/ApiImport.php | 32 +- includes/api/ApiLogin.php | 38 +- includes/api/ApiLogout.php | 6 +- includes/api/ApiMain.php | 140 +- includes/api/ApiManageTags.php | 30 +- includes/api/ApiMergeHistory.php | 32 +- includes/api/ApiMessage.php | 6 +- includes/api/ApiModuleManager.php | 12 +- includes/api/ApiMove.php | 48 +- includes/api/ApiOpenSearch.php | 80 +- includes/api/ApiOptions.php | 30 +- includes/api/ApiPageSet.php | 162 +- includes/api/ApiParamInfo.php | 96 +- includes/api/ApiParse.php | 134 +- includes/api/ApiPatrol.php | 22 +- includes/api/ApiProtect.php | 62 +- includes/api/ApiPurge.php | 20 +- includes/api/ApiQuery.php | 72 +- includes/api/ApiQueryAllCategories.php | 66 +- includes/api/ApiQueryAllDeletedRevisions.php | 126 +- includes/api/ApiQueryAllImages.php | 102 +- includes/api/ApiQueryAllLinks.php | 62 +- includes/api/ApiQueryAllMessages.php | 52 +- includes/api/ApiQueryAllPages.php | 98 +- includes/api/ApiQueryAllRevisions.php | 82 +- includes/api/ApiQueryAllUsers.php | 104 +- includes/api/ApiQueryBacklinks.php | 128 +- includes/api/ApiQueryBacklinksprop.php | 90 +- includes/api/ApiQueryBase.php | 52 +- includes/api/ApiQueryBlocks.php | 90 +- includes/api/ApiQueryCategories.php | 80 +- includes/api/ApiQueryCategoryInfo.php | 36 +- includes/api/ApiQueryCategoryMembers.php | 106 +- includes/api/ApiQueryContributors.php | 52 +- includes/api/ApiQueryDeletedRevisions.php | 54 +- includes/api/ApiQueryDeletedrevs.php | 118 +- includes/api/ApiQueryDisabled.php | 2 +- includes/api/ApiQueryDuplicateFiles.php | 32 +- includes/api/ApiQueryExtLinksUsage.php | 56 +- includes/api/ApiQueryExternalLinks.php | 26 +- includes/api/ApiQueryFileRepoInfo.php | 18 +- includes/api/ApiQueryFilearchive.php | 52 +- includes/api/ApiQueryIWBacklinks.php | 58 +- includes/api/ApiQueryIWLinks.php | 56 +- includes/api/ApiQueryImageInfo.php | 114 +- includes/api/ApiQueryImages.php | 42 +- includes/api/ApiQueryInfo.php | 194 +- includes/api/ApiQueryLangBacklinks.php | 58 +- includes/api/ApiQueryLangLinks.php | 52 +- includes/api/ApiQueryLinks.php | 42 +- includes/api/ApiQueryLogEvents.php | 100 +- includes/api/ApiQueryMyStashedFiles.php | 42 +- includes/api/ApiQueryPagePropNames.php | 22 +- includes/api/ApiQueryPageProps.php | 22 +- includes/api/ApiQueryPagesWithProp.php | 52 +- includes/api/ApiQueryPrefixSearch.php | 34 +- includes/api/ApiQueryProtectedTitles.php | 66 +- includes/api/ApiQueryQueryPage.php | 36 +- includes/api/ApiQueryRandom.php | 52 +- includes/api/ApiQueryRecentChanges.php | 134 +- includes/api/ApiQueryRevisions.php | 96 +- includes/api/ApiQueryRevisionsBase.php | 66 +- includes/api/ApiQuerySearch.php | 88 +- includes/api/ApiQuerySiteinfo.php | 138 +- includes/api/ApiQueryStashImageInfo.php | 44 +- includes/api/ApiQueryTags.php | 36 +- includes/api/ApiQueryTokens.php | 28 +- includes/api/ApiQueryUserContributions.php | 100 +- includes/api/ApiQueryUserInfo.php | 58 +- includes/api/ApiQueryUsers.php | 68 +- includes/api/ApiQueryWatchlist.php | 118 +- includes/api/ApiQueryWatchlistRaw.php | 72 +- includes/api/ApiResult.php | 102 +- includes/api/ApiRevisionDelete.php | 60 +- includes/api/ApiRollback.php | 50 +- includes/api/ApiRsd.php | 36 +- includes/api/ApiSetNotificationTimestamp.php | 54 +- includes/api/ApiStashEdit.php | 60 +- includes/api/ApiTag.php | 40 +- includes/api/ApiTokens.php | 28 +- includes/api/ApiUnblock.php | 18 +- includes/api/ApiUndelete.php | 38 +- includes/api/ApiUpload.php | 110 +- includes/api/ApiUserrights.php | 34 +- includes/api/ApiWatch.php | 28 +- includes/cache/BacklinkCache.php | 76 +- includes/cache/CacheDependency.php | 8 +- includes/cache/CacheHelper.php | 14 +- includes/cache/GenderCache.php | 20 +- includes/cache/HTMLFileCache.php | 4 +- includes/cache/LCStoreStaticArray.php | 14 +- includes/cache/LinkBatch.php | 14 +- includes/cache/LinkCache.php | 18 +- includes/cache/LocalisationCache.php | 96 +- includes/cache/MessageBlobStore.php | 24 +- includes/cache/MessageCache.php | 52 +- includes/cache/ResourceFileCache.php | 4 +- includes/cache/UserCache.php | 18 +- includes/changes/CategoryMembershipChange.php | 14 +- includes/changes/ChangesFeed.php | 8 +- includes/changes/ChangesList.php | 46 +- includes/changes/EnhancedChangesList.php | 90 +- includes/changes/OldChangesList.php | 12 +- includes/changes/RCCacheEntryFactory.php | 16 +- includes/changes/RecentChange.php | 86 +- includes/changetags/ChangeTags.php | 184 +- includes/changetags/ChangeTagsLogList.php | 4 +- .../changetags/ChangeTagsRevisionItem.php | 2 +- .../changetags/ChangeTagsRevisionList.php | 16 +- includes/clientpool/RedisConnectionPool.php | 40 +- includes/clientpool/SquidPurgeClient.php | 18 +- includes/clientpool/SquidPurgeClientPool.php | 6 +- includes/composer/ComposerPackageModifier.php | 2 +- includes/config/ConfigFactory.php | 4 +- includes/config/HashConfig.php | 2 +- includes/content/AbstractContent.php | 20 +- includes/content/Content.php | 2 +- includes/content/ContentHandler.php | 32 +- includes/content/CssContentHandler.php | 2 +- includes/content/JavaScriptContentHandler.php | 4 +- includes/content/JsonContent.php | 42 +- includes/content/JsonContentHandler.php | 2 +- includes/content/WikitextContent.php | 14 +- includes/content/WikitextContentHandler.php | 2 +- includes/context/ContextSource.php | 2 +- includes/context/RequestContext.php | 22 +- includes/dao/DBAccessBase.php | 2 +- includes/dao/DBAccessObjectUtils.php | 4 +- includes/db/ChronologyProtector.php | 12 +- includes/db/CloneDatabase.php | 8 +- includes/db/DBConnRef.php | 24 +- includes/db/Database.php | 196 +- includes/db/DatabaseError.php | 24 +- includes/db/DatabaseMssql.php | 66 +- includes/db/DatabaseMysqlBase.php | 50 +- includes/db/DatabaseOracle.php | 92 +- includes/db/DatabasePostgres.php | 60 +- includes/db/DatabaseSqlite.php | 28 +- includes/db/DatabaseUtility.php | 2 +- includes/db/IDatabase.php | 22 +- includes/db/loadbalancer/LBFactory.php | 36 +- includes/db/loadbalancer/LBFactoryFake.php | 2 +- includes/db/loadbalancer/LBFactoryMulti.php | 44 +- includes/db/loadbalancer/LBFactorySimple.php | 24 +- includes/db/loadbalancer/LBFactorySingle.php | 20 +- includes/db/loadbalancer/LoadBalancer.php | 54 +- includes/db/loadbalancer/LoadMonitorMySQL.php | 6 +- includes/debug/MWDebug.php | 54 +- includes/debug/logger/LegacyLogger.php | 10 +- includes/debug/logger/LegacySpi.php | 2 +- includes/debug/logger/MonologSpi.php | 16 +- .../debug/logger/monolog/AvroFormatter.php | 2 +- .../debug/logger/monolog/BufferHandler.php | 2 +- .../debug/logger/monolog/KafkaHandler.php | 24 +- .../debug/logger/monolog/LegacyHandler.php | 2 +- .../debug/logger/monolog/LineFormatter.php | 10 +- .../debug/logger/monolog/WikiProcessor.php | 4 +- includes/deferred/CdnCacheUpdate.php | 14 +- includes/deferred/DataUpdate.php | 4 +- includes/deferred/DeferredUpdates.php | 14 +- includes/deferred/LinksDeletionUpdate.php | 40 +- includes/deferred/LinksUpdate.php | 168 +- includes/deferred/SiteStatsUpdate.php | 24 +- includes/deferred/SqlDataUpdate.php | 16 +- includes/diff/ArrayDiffFormatter.php | 14 +- includes/diff/DairikiDiff.php | 54 +- includes/diff/DiffFormatter.php | 4 +- includes/diff/DifferenceEngine.php | 88 +- includes/diff/WikiDiff3.php | 20 +- includes/exception/BadTitleError.php | 4 +- includes/exception/ErrorPageError.php | 2 +- includes/exception/HttpError.php | 4 +- includes/exception/MWException.php | 4 +- includes/exception/MWExceptionHandler.php | 28 +- includes/exception/PermissionsError.php | 8 +- includes/exception/ReadOnlyError.php | 2 +- includes/exception/UserNotLoggedIn.php | 6 +- includes/export/DumpMultiWriter.php | 2 +- includes/export/DumpNamespaceFilter.php | 6 +- includes/export/DumpPipeOutput.php | 8 +- includes/export/WikiExporter.php | 42 +- includes/export/XmlDumpWriter.php | 60 +- includes/externalstore/ExternalStore.php | 16 +- includes/externalstore/ExternalStoreDB.php | 30 +- includes/externalstore/ExternalStoreHttp.php | 2 +- .../externalstore/ExternalStoreMedium.php | 6 +- .../externalstore/ExternalStoreMwstore.php | 12 +- includes/filebackend/FSFile.php | 6 +- includes/filebackend/FSFileBackend.php | 46 +- includes/filebackend/FileBackend.php | 68 +- includes/filebackend/FileBackendGroup.php | 24 +- .../filebackend/FileBackendMultiWrite.php | 40 +- includes/filebackend/FileBackendStore.php | 144 +- includes/filebackend/FileOp.php | 110 +- includes/filebackend/FileOpBatch.php | 12 +- includes/filebackend/MemoryFileBackend.php | 24 +- includes/filebackend/SwiftFileBackend.php | 270 +-- includes/filebackend/TempFSFile.php | 8 +- .../filebackend/filejournal/DBFileJournal.php | 28 +- .../filebackend/filejournal/FileJournal.php | 2 +- .../filebackend/lockmanager/DBLockManager.php | 42 +- .../filebackend/lockmanager/FSLockManager.php | 10 +- .../filebackend/lockmanager/LockManager.php | 16 +- .../lockmanager/LockManagerGroup.php | 14 +- .../lockmanager/MemcLockManager.php | 28 +- .../lockmanager/QuorumLockManager.php | 16 +- .../lockmanager/RedisLockManager.php | 22 +- .../filebackend/lockmanager/ScopedLock.php | 2 +- includes/filerepo/FSRepo.php | 8 +- .../filerepo/FileBackendDBRepoWrapper.php | 14 +- includes/filerepo/FileRepo.php | 198 +- includes/filerepo/ForeignAPIRepo.php | 56 +- includes/filerepo/ForeignDBRepo.php | 8 +- includes/filerepo/ForeignDBViaLBRepo.php | 10 +- includes/filerepo/LocalRepo.php | 84 +- includes/filerepo/RepoGroup.php | 16 +- includes/filerepo/file/ArchivedFile.php | 8 +- includes/filerepo/file/File.php | 56 +- includes/filerepo/file/ForeignAPIFile.php | 18 +- includes/filerepo/file/ForeignDBFile.php | 10 +- includes/filerepo/file/LocalFile.php | 304 +-- includes/filerepo/file/OldLocalFile.php | 26 +- .../filerepo/file/UnregisteredLocalFile.php | 2 +- includes/gallery/ImageGalleryBase.php | 18 +- includes/gallery/PackedImageGallery.php | 6 +- includes/gallery/TraditionalImageGallery.php | 16 +- .../htmlform/HTMLAutoCompleteSelectField.php | 12 +- includes/htmlform/HTMLButtonField.php | 14 +- includes/htmlform/HTMLCheckField.php | 12 +- includes/htmlform/HTMLCheckMatrix.php | 60 +- includes/htmlform/HTMLComboboxField.php | 14 +- includes/htmlform/HTMLForm.php | 100 +- includes/htmlform/HTMLFormField.php | 114 +- includes/htmlform/HTMLFormFieldCloner.php | 44 +- includes/htmlform/HTMLFormFieldWithButton.php | 10 +- includes/htmlform/HTMLHiddenField.php | 4 +- includes/htmlform/HTMLInfoField.php | 4 +- includes/htmlform/HTMLMultiSelectField.php | 32 +- includes/htmlform/HTMLRadioField.php | 22 +- includes/htmlform/HTMLSelectAndOtherField.php | 14 +- includes/htmlform/HTMLSelectField.php | 12 +- includes/htmlform/HTMLSelectNamespace.php | 10 +- includes/htmlform/HTMLSelectOrOtherField.php | 4 +- includes/htmlform/HTMLSubmitField.php | 2 +- includes/htmlform/HTMLTextAreaField.php | 22 +- includes/htmlform/HTMLTextField.php | 22 +- includes/htmlform/HTMLTitleTextField.php | 4 +- includes/htmlform/HTMLUserTextField.php | 4 +- includes/htmlform/OOUIHTMLForm.php | 72 +- includes/htmlform/VFormHTMLForm.php | 24 +- includes/import/ImportStreamSource.php | 4 +- includes/import/UploadSourceAdapter.php | 4 +- includes/import/WikiImporter.php | 80 +- includes/import/WikiRevision.php | 30 +- includes/installer/CliInstaller.php | 12 +- includes/installer/DatabaseInstaller.php | 62 +- includes/installer/DatabaseUpdater.php | 100 +- includes/installer/InstallDocFormatter.php | 4 +- includes/installer/Installer.php | 224 +- .../installer/InstallerSessionProvider.php | 4 +- includes/installer/LocalSettingsGenerator.php | 20 +- includes/installer/MssqlInstaller.php | 146 +- includes/installer/MssqlUpdater.php | 54 +- includes/installer/MysqlInstaller.php | 98 +- includes/installer/MysqlUpdater.php | 454 ++-- includes/installer/OracleInstaller.php | 30 +- includes/installer/OracleUpdater.php | 124 +- includes/installer/PhpBugTests.php | 2 +- includes/installer/PostgresInstaller.php | 82 +- includes/installer/PostgresUpdater.php | 706 +++--- includes/installer/SqliteInstaller.php | 16 +- includes/installer/SqliteUpdater.php | 184 +- includes/installer/WebInstaller.php | 86 +- includes/installer/WebInstallerComplete.php | 2 +- includes/installer/WebInstallerDBConnect.php | 8 +- .../installer/WebInstallerExistingWiki.php | 8 +- includes/installer/WebInstallerInstall.php | 4 +- includes/installer/WebInstallerName.php | 58 +- includes/installer/WebInstallerOptions.php | 114 +- includes/installer/WebInstallerOutput.php | 20 +- includes/installer/WebInstallerPage.php | 18 +- includes/interwiki/Interwiki.php | 26 +- includes/jobqueue/Job.php | 20 +- includes/jobqueue/JobQueue.php | 10 +- includes/jobqueue/JobQueueDB.php | 104 +- includes/jobqueue/JobQueueFederated.php | 18 +- includes/jobqueue/JobQueueGroup.php | 32 +- includes/jobqueue/JobQueueMemory.php | 12 +- includes/jobqueue/JobQueueRedis.php | 46 +- includes/jobqueue/JobRunner.php | 34 +- includes/jobqueue/JobSpecification.php | 18 +- .../aggregator/JobQueueAggregator.php | 4 +- .../aggregator/JobQueueAggregatorRedis.php | 10 +- includes/jobqueue/jobs/ActivityUpdateJob.php | 8 +- .../jobqueue/jobs/AssembleUploadChunksJob.php | 14 +- .../jobs/CategoryMembershipChangeJob.php | 34 +- includes/jobqueue/jobs/DeleteLinksJob.php | 2 +- includes/jobqueue/jobs/DoubleRedirectJob.php | 26 +- includes/jobqueue/jobs/DuplicateJob.php | 4 +- includes/jobqueue/jobs/EmaillingJob.php | 2 +- includes/jobqueue/jobs/EnqueueJob.php | 12 +- includes/jobqueue/jobs/HTMLCacheUpdateJob.php | 22 +- .../jobqueue/jobs/PublishStashedFileJob.php | 20 +- .../jobqueue/jobs/RecentChangesUpdateJob.php | 54 +- includes/jobqueue/jobs/RefreshLinksJob.php | 2 +- includes/jobqueue/jobs/ThumbnailRenderJob.php | 2 +- includes/jobqueue/utils/BacklinkJobUtils.php | 22 +- includes/json/FormatJson.php | 10 +- includes/libs/ArrayUtils.php | 6 +- includes/libs/BufferingStatsdDataFactory.php | 4 +- includes/libs/CSSMin.php | 24 +- includes/libs/Cookie.php | 6 +- includes/libs/GenericArrayObject.php | 6 +- includes/libs/HashRing.php | 16 +- includes/libs/HttpStatus.php | 4 +- includes/libs/IEContentAnalyzer.php | 56 +- includes/libs/IEUrlExtension.php | 12 +- includes/libs/MapCacheLRU.php | 4 +- includes/libs/MappedIterator.php | 8 +- includes/libs/MemoizedCallable.php | 4 +- includes/libs/MultiHttpClient.php | 34 +- includes/libs/ObjectFactory.php | 4 +- includes/libs/ProcessCacheLRU.php | 8 +- includes/libs/ReplacementArray.php | 2 +- includes/libs/RiffExtractor.php | 10 +- includes/libs/SamplingStatsdClient.php | 4 +- includes/libs/ScopedCallback.php | 2 +- includes/libs/StatusValue.php | 22 +- includes/libs/StringUtils.php | 10 +- includes/libs/Timing.php | 22 +- includes/libs/Xhprof.php | 36 +- includes/libs/XmlTypeCheck.php | 16 +- includes/libs/composer/ComposerInstalled.php | 10 +- includes/libs/composer/ComposerJson.php | 2 +- includes/libs/composer/ComposerLock.php | 10 +- includes/libs/eventrelayer/EventRelayer.php | 2 +- .../libs/eventrelayer/EventRelayerMCRD.php | 10 +- includes/libs/objectcache/APCBagOStuff.php | 2 +- includes/libs/objectcache/BagOStuff.php | 12 +- includes/libs/objectcache/CachedBagOStuff.php | 2 +- includes/libs/objectcache/HashBagOStuff.php | 10 +- .../libs/objectcache/MultiWriteBagOStuff.php | 8 +- includes/libs/objectcache/WANObjectCache.php | 70 +- .../libs/objectcache/WinCacheBagOStuff.php | 2 +- includes/libs/replacers/RegexlikeReplacer.php | 2 +- includes/libs/replacers/Replacer.php | 2 +- .../virtualrest/ParsoidVirtualRESTService.php | 6 +- .../RestbaseVirtualRESTService.php | 8 +- .../virtualrest/SwiftVirtualRESTService.php | 36 +- .../libs/virtualrest/VirtualRESTService.php | 4 +- .../virtualrest/VirtualRESTServiceClient.php | 32 +- includes/logging/BlockLogFormatter.php | 22 +- includes/logging/ContentModelLogFormatter.php | 6 +- includes/logging/DeleteLogFormatter.php | 56 +- includes/logging/LogEntry.php | 36 +- includes/logging/LogEventsList.php | 68 +- includes/logging/LogFormatter.php | 24 +- includes/logging/LogPage.php | 18 +- includes/logging/LogPager.php | 24 +- includes/logging/MergeLogFormatter.php | 14 +- includes/logging/MoveLogFormatter.php | 14 +- includes/logging/NewUsersLogFormatter.php | 4 +- includes/logging/PatrolLog.php | 4 +- includes/logging/PatrolLogFormatter.php | 10 +- includes/logging/ProtectLogFormatter.php | 30 +- includes/logging/RightsLogFormatter.php | 8 +- includes/logging/UploadLogFormatter.php | 4 +- includes/mail/EmailNotification.php | 66 +- includes/mail/UserMailer.php | 32 +- includes/media/BMP.php | 4 +- includes/media/Bitmap.php | 74 +- includes/media/BitmapMetadataHandler.php | 28 +- includes/media/DjVu.php | 40 +- includes/media/DjVuImage.php | 26 +- includes/media/Exif.php | 52 +- includes/media/ExifBitmap.php | 4 +- includes/media/FormatMetadata.php | 50 +- includes/media/GIF.php | 6 +- includes/media/GIFMetadataExtractor.php | 6 +- includes/media/IPTC.php | 16 +- includes/media/ImageHandler.php | 8 +- includes/media/JpegMetadataExtractor.php | 10 +- includes/media/MediaHandler.php | 32 +- includes/media/MediaTransformOutput.php | 48 +- includes/media/PNG.php | 6 +- includes/media/PNGMetadataExtractor.php | 12 +- includes/media/SVG.php | 56 +- includes/media/SVGMetadataExtractor.php | 12 +- .../media/TransformationalImageHandler.php | 22 +- includes/media/WebP.php | 24 +- includes/media/XCF.php | 6 +- includes/media/XMP.php | 36 +- includes/media/XMPInfo.php | 842 ++++---- includes/media/XMPValidate.php | 4 +- .../objectcache/MemcachedPeclBagOStuff.php | 6 +- includes/objectcache/ObjectCache.php | 12 +- includes/objectcache/RedisBagOStuff.php | 20 +- includes/objectcache/SqlBagOStuff.php | 72 +- includes/page/Article.php | 228 +- includes/page/CategoryPage.php | 6 +- includes/page/ImageHistoryList.php | 36 +- includes/page/ImageHistoryPseudoPager.php | 12 +- includes/page/ImagePage.php | 142 +- includes/page/WikiFilePage.php | 22 +- includes/page/WikiPage.php | 340 +-- includes/pager/AlphabeticPager.php | 10 +- includes/pager/IndexPager.php | 48 +- includes/pager/ReverseChronologicalPager.php | 4 +- includes/pager/TablePager.php | 50 +- includes/parser/CoreParserFunctions.php | 72 +- includes/parser/CoreTagHooks.php | 16 +- includes/parser/DateFormatter.php | 20 +- includes/parser/LinkHolderArray.php | 84 +- includes/parser/MWTidy.php | 8 +- includes/parser/Parser.php | 144 +- includes/parser/ParserCache.php | 4 +- includes/parser/ParserDiffTest.php | 8 +- includes/parser/ParserOptions.php | 18 +- includes/parser/ParserOutput.php | 76 +- includes/parser/Preprocessor.php | 18 +- includes/parser/Preprocessor_DOM.php | 110 +- includes/parser/Preprocessor_Hash.php | 90 +- includes/parser/StripState.php | 14 +- includes/password/BcryptPassword.php | 4 +- includes/password/EncryptedPassword.php | 8 +- .../password/LayeredParameterizedPassword.php | 2 +- includes/password/MWOldPassword.php | 4 +- includes/password/MWSaltedPassword.php | 2 +- includes/password/ParameterizedPassword.php | 4 +- includes/password/PasswordFactory.php | 12 +- includes/password/PasswordPolicyChecks.php | 6 +- includes/password/Pbkdf2Password.php | 4 +- includes/password/UserPasswordPolicy.php | 4 +- includes/poolcounter/PoolCounterRedis.php | 22 +- includes/poolcounter/PoolCounterWork.php | 4 +- .../PoolCounterWorkViaCallback.php | 10 +- includes/poolcounter/PoolWorkArticleView.php | 4 +- includes/profiler/Profiler.php | 12 +- includes/profiler/ProfilerSectionOnly.php | 4 +- includes/profiler/ProfilerXhprof.php | 10 +- includes/profiler/SectionProfiler.php | 58 +- includes/profiler/TransactionProfiler.php | 32 +- includes/profiler/output/ProfilerOutput.php | 2 +- includes/profiler/output/ProfilerOutputDb.php | 10 +- .../rcfeed/IRCColourfulRCFeedFormatter.php | 6 +- .../rcfeed/MachineReadableRCFeedFormatter.php | 18 +- includes/rcfeed/RedisPubSubFeedEngine.php | 2 +- includes/registration/ExtensionProcessor.php | 46 +- includes/registration/ExtensionRegistry.php | 26 +- includes/resourceloader/ResourceLoader.php | 124 +- .../resourceloader/ResourceLoaderContext.php | 10 +- .../ResourceLoaderFileModule.php | 80 +- .../ResourceLoaderForeignApiModule.php | 2 +- .../resourceloader/ResourceLoaderImage.php | 12 +- .../ResourceLoaderImageModule.php | 54 +- .../ResourceLoaderJqueryMsgModule.php | 4 +- .../ResourceLoaderLanguageDataModule.php | 12 +- .../ResourceLoaderLanguageNamesModule.php | 8 +- .../resourceloader/ResourceLoaderModule.php | 64 +- .../ResourceLoaderOOUIImageModule.php | 6 +- .../ResourceLoaderSiteModule.php | 12 +- ...sourceLoaderSpecialCharacterDataModule.php | 12 +- .../ResourceLoaderStartUpModule.php | 52 +- .../ResourceLoaderUserCSSPrefsModule.php | 6 +- .../ResourceLoaderUserDefaultsModule.php | 4 +- .../ResourceLoaderUserGroupsModule.php | 12 +- .../ResourceLoaderUserModule.php | 14 +- .../ResourceLoaderUserOptionsModule.php | 6 +- .../ResourceLoaderUserTokensModule.php | 8 +- .../ResourceLoaderWikiModule.php | 38 +- includes/revisiondelete/RevDelArchiveItem.php | 20 +- includes/revisiondelete/RevDelArchiveList.php | 8 +- .../revisiondelete/RevDelArchivedFileItem.php | 38 +- .../revisiondelete/RevDelArchivedFileList.php | 6 +- .../RevDelArchivedRevisionItem.php | 8 +- includes/revisiondelete/RevDelFileItem.php | 50 +- includes/revisiondelete/RevDelFileList.php | 16 +- includes/revisiondelete/RevDelList.php | 18 +- includes/revisiondelete/RevDelLogList.php | 16 +- .../revisiondelete/RevDelRevisionItem.php | 46 +- .../revisiondelete/RevDelRevisionList.php | 28 +- .../revisiondelete/RevisionDeleteUser.php | 34 +- includes/revisiondelete/RevisionDeleter.php | 24 +- includes/search/SearchEngine.php | 52 +- includes/search/SearchExactMatchRescorer.php | 2 +- includes/search/SearchHighlighter.php | 30 +- includes/search/SearchMssql.php | 6 +- includes/search/SearchMySQL.php | 52 +- includes/search/SearchOracle.php | 20 +- includes/search/SearchPostgres.php | 6 +- includes/search/SearchResult.php | 2 +- includes/search/SearchResultSet.php | 2 +- includes/search/SearchSqlite.php | 18 +- includes/search/SearchSuggestionSet.php | 6 +- .../session/BotPasswordSessionProvider.php | 34 +- includes/session/CookieSessionProvider.php | 76 +- .../ImmutableSessionProviderWithCookie.php | 10 +- includes/session/PHPSessionHandler.php | 12 +- includes/session/Session.php | 6 +- includes/session/SessionBackend.php | 86 +- includes/session/SessionInfo.php | 8 +- includes/session/SessionManager.php | 134 +- includes/session/SessionProvider.php | 8 +- includes/site/CachingSiteStore.php | 2 +- includes/site/DBSiteStore.php | 34 +- includes/site/HashSiteStore.php | 6 +- includes/site/MediaWikiPageNameNormalizer.php | 10 +- includes/site/Site.php | 22 +- includes/site/SiteExporter.php | 10 +- includes/site/SiteImporter.php | 2 +- includes/site/SiteList.php | 12 +- includes/site/SitesCacheFileBuilder.php | 14 +- .../specialpage/ChangesListSpecialPage.php | 24 +- includes/specialpage/FormSpecialPage.php | 6 +- includes/specialpage/PageQueryPage.php | 2 +- includes/specialpage/QueryPage.php | 120 +- includes/specialpage/RedirectSpecialPage.php | 16 +- includes/specialpage/SpecialPage.php | 20 +- includes/specialpage/SpecialPageFactory.php | 24 +- includes/specialpage/WantedQueryPage.php | 6 +- includes/specials/SpecialActiveusers.php | 54 +- includes/specials/SpecialAllMessages.php | 70 +- includes/specials/SpecialAllPages.php | 54 +- includes/specials/SpecialAncientpages.php | 14 +- includes/specials/SpecialApiHelp.php | 6 +- includes/specials/SpecialApiSandbox.php | 8 +- includes/specials/SpecialBlock.php | 154 +- includes/specials/SpecialBlockList.php | 74 +- includes/specials/SpecialBooksources.php | 14 +- includes/specials/SpecialBotPasswords.php | 76 +- includes/specials/SpecialBrokenRedirects.php | 50 +- includes/specials/SpecialCachedPage.php | 10 +- includes/specials/SpecialCategories.php | 20 +- .../specials/SpecialChangeContentModel.php | 30 +- includes/specials/SpecialChangeEmail.php | 22 +- includes/specials/SpecialChangePassword.php | 62 +- includes/specials/SpecialComparePages.php | 42 +- includes/specials/SpecialConfirmemail.php | 12 +- includes/specials/SpecialContributions.php | 200 +- includes/specials/SpecialCreateAccount.php | 2 +- includes/specials/SpecialDeadendpages.php | 28 +- .../specials/SpecialDeletedContributions.php | 130 +- includes/specials/SpecialDiff.php | 2 +- includes/specials/SpecialDoubleRedirects.php | 34 +- includes/specials/SpecialEditTags.php | 50 +- includes/specials/SpecialEditWatchlist.php | 110 +- includes/specials/SpecialEmailuser.php | 54 +- includes/specials/SpecialExpandTemplates.php | 42 +- includes/specials/SpecialExport.php | 110 +- includes/specials/SpecialFewestrevisions.php | 26 +- .../specials/SpecialFileDuplicateSearch.php | 44 +- includes/specials/SpecialFilepath.php | 2 +- includes/specials/SpecialImport.php | 72 +- includes/specials/SpecialJavaScriptTest.php | 34 +- includes/specials/SpecialLinkSearch.php | 54 +- .../specials/SpecialListDuplicatedFiles.php | 14 +- includes/specials/SpecialListfiles.php | 64 +- includes/specials/SpecialListgrants.php | 6 +- includes/specials/SpecialListgrouprights.php | 50 +- includes/specials/SpecialListredirects.php | 26 +- includes/specials/SpecialListusers.php | 66 +- includes/specials/SpecialLockdb.php | 12 +- includes/specials/SpecialLog.php | 38 +- includes/specials/SpecialLonelypages.php | 40 +- includes/specials/SpecialMIMEsearch.php | 30 +- includes/specials/SpecialMediaStatistics.php | 52 +- includes/specials/SpecialMergeHistory.php | 56 +- includes/specials/SpecialMostcategories.php | 28 +- includes/specials/SpecialMostimages.php | 14 +- includes/specials/SpecialMostinterwikis.php | 26 +- includes/specials/SpecialMostlinked.php | 32 +- .../specials/SpecialMostlinkedcategories.php | 14 +- .../specials/SpecialMostlinkedtemplates.php | 14 +- includes/specials/SpecialMovepage.php | 156 +- includes/specials/SpecialMyRedirectPages.php | 8 +- includes/specials/SpecialNewimages.php | 50 +- includes/specials/SpecialNewpages.php | 90 +- includes/specials/SpecialPageLanguage.php | 34 +- includes/specials/SpecialPagesWithProp.php | 46 +- includes/specials/SpecialPasswordReset.php | 50 +- includes/specials/SpecialPermanentLink.php | 2 +- includes/specials/SpecialPreferences.php | 24 +- includes/specials/SpecialPrefixindex.php | 40 +- includes/specials/SpecialProtectedpages.php | 88 +- includes/specials/SpecialProtectedtitles.php | 32 +- includes/specials/SpecialRandomInCategory.php | 48 +- includes/specials/SpecialRandompage.php | 30 +- includes/specials/SpecialRecentchanges.php | 100 +- .../specials/SpecialRecentchangeslinked.php | 46 +- includes/specials/SpecialRedirect.php | 50 +- includes/specials/SpecialResetTokens.php | 22 +- includes/specials/SpecialRevisiondelete.php | 98 +- includes/specials/SpecialRunJobs.php | 8 +- includes/specials/SpecialSearch.php | 164 +- includes/specials/SpecialShortpages.php | 28 +- includes/specials/SpecialSpecialpages.php | 14 +- includes/specials/SpecialStatistics.php | 52 +- includes/specials/SpecialTags.php | 92 +- .../specials/SpecialTrackingCategories.php | 24 +- includes/specials/SpecialUnblock.php | 30 +- .../specials/SpecialUncategorizedimages.php | 18 +- .../specials/SpecialUncategorizedpages.php | 24 +- includes/specials/SpecialUndelete.php | 262 +-- includes/specials/SpecialUnlockdb.php | 8 +- includes/specials/SpecialUnusedcategories.php | 16 +- includes/specials/SpecialUnusedimages.php | 26 +- includes/specials/SpecialUnusedtemplates.php | 24 +- includes/specials/SpecialUnwatchedpages.php | 28 +- includes/specials/SpecialUpload.php | 170 +- includes/specials/SpecialUploadStash.php | 38 +- includes/specials/SpecialUserlogin.php | 118 +- includes/specials/SpecialUserlogout.php | 6 +- includes/specials/SpecialUserrights.php | 78 +- includes/specials/SpecialVersion.php | 166 +- includes/specials/SpecialWantedcategories.php | 34 +- includes/specials/SpecialWantedfiles.php | 38 +- includes/specials/SpecialWantedpages.php | 42 +- includes/specials/SpecialWantedtemplates.php | 22 +- includes/specials/SpecialWatchlist.php | 90 +- includes/specials/SpecialWhatlinkshere.php | 102 +- includes/specials/SpecialWithoutinterwiki.php | 20 +- includes/tidy/Html5Depurate.php | 12 +- includes/tidy/RaggettExternal.php | 22 +- includes/tidy/RaggettWrapper.php | 6 +- includes/title/MalformedTitleException.php | 4 +- includes/title/MediaWikiPageLinkRenderer.php | 2 +- includes/title/MediaWikiTitleCodec.php | 18 +- .../NamespaceAwareForeignTitleFactory.php | 2 +- includes/title/PageLinkRenderer.php | 2 +- includes/upload/UploadBase.php | 174 +- includes/upload/UploadFromChunks.php | 16 +- includes/upload/UploadFromFile.php | 4 +- includes/upload/UploadFromUrl.php | 12 +- includes/upload/UploadStash.php | 28 +- includes/user/BotPassword.php | 34 +- includes/user/CentralIdLookup.php | 8 +- includes/user/LocalIdLookup.php | 36 +- includes/user/User.php | 372 ++-- includes/user/UserArray.php | 10 +- includes/user/UserNamePrefixSearch.php | 16 +- includes/user/UserRightsProxy.php | 36 +- includes/utils/AutoloadGenerator.php | 18 +- includes/utils/AvroValidator.php | 28 +- includes/utils/BatchRowIterator.php | 20 +- includes/utils/BatchRowUpdate.php | 6 +- includes/utils/IP.php | 38 +- includes/utils/MWCryptHKDF.php | 12 +- includes/utils/MWCryptHash.php | 6 +- includes/utils/MWCryptRand.php | 2 +- includes/utils/MWGrants.php | 12 +- includes/utils/MWRestrictions.php | 14 +- includes/utils/UIDGenerator.php | 16 +- includes/utils/ZipDirectoryReader.php | 58 +- .../widget/ComplexNamespaceInputWidget.php | 30 +- includes/widget/ComplexTitleInputWidget.php | 16 +- includes/widget/NamespaceInputWidget.php | 16 +- includes/widget/TitleInputWidget.php | 6 +- includes/widget/UserInputWidget.php | 6 +- languages/ConverterRule.php | 42 +- languages/FakeConverter.php | 4 +- languages/Language.php | 236 +- languages/LanguageConverter.php | 34 +- languages/classes/LanguageCu.php | 2 +- languages/classes/LanguageEo.php | 12 +- languages/classes/LanguageFi.php | 4 +- languages/classes/LanguageGan.php | 34 +- languages/classes/LanguageHy.php | 2 +- languages/classes/LanguageIu.php | 28 +- languages/classes/LanguageKk.php | 46 +- languages/classes/LanguageKk_cyrl.php | 68 +- languages/classes/LanguageKsh.php | 4 +- languages/classes/LanguageKu.php | 18 +- languages/classes/LanguageLa.php | 24 +- languages/classes/LanguageShi.php | 28 +- languages/classes/LanguageSr.php | 26 +- languages/classes/LanguageTg.php | 10 +- languages/classes/LanguageTyv.php | 20 +- languages/classes/LanguageUk.php | 2 +- languages/classes/LanguageUz.php | 18 +- languages/classes/LanguageZh.php | 48 +- languages/classes/LanguageZh_hans.php | 6 +- languages/data/Names.php | 4 +- languages/data/ZhConversion.php | 20 +- languages/messages/MessagesAb.php | 46 +- languages/messages/MessagesAce.php | 190 +- languages/messages/MessagesAdy_cyrl.php | 4 +- languages/messages/MessagesAf.php | 324 +-- languages/messages/MessagesAk.php | 4 +- languages/messages/MessagesAln.php | 46 +- languages/messages/MessagesAm.php | 18 +- languages/messages/MessagesAn.php | 174 +- languages/messages/MessagesAng.php | 8 +- languages/messages/MessagesAr.php | 602 +++--- languages/messages/MessagesArc.php | 188 +- languages/messages/MessagesArq.php | 6 +- languages/messages/MessagesArz.php | 568 ++--- languages/messages/MessagesAs.php | 204 +- languages/messages/MessagesAst.php | 30 +- languages/messages/MessagesAv.php | 200 +- languages/messages/MessagesAvk.php | 128 +- languages/messages/MessagesAz.php | 58 +- languages/messages/MessagesAzb.php | 94 +- languages/messages/MessagesBa.php | 168 +- languages/messages/MessagesBar.php | 10 +- languages/messages/MessagesBcc.php | 170 +- languages/messages/MessagesBcl.php | 122 +- languages/messages/MessagesBe.php | 44 +- languages/messages/MessagesBe_tarask.php | 378 ++-- languages/messages/MessagesBg.php | 356 +-- languages/messages/MessagesBgn.php | 234 +- languages/messages/MessagesBho.php | 54 +- languages/messages/MessagesBjn.php | 184 +- languages/messages/MessagesBm.php | 2 +- languages/messages/MessagesBn.php | 12 +- languages/messages/MessagesBo.php | 4 +- languages/messages/MessagesBpy.php | 8 +- languages/messages/MessagesBr.php | 240 +-- languages/messages/MessagesBs.php | 450 ++-- languages/messages/MessagesBxr.php | 52 +- languages/messages/MessagesCa.php | 232 +- languages/messages/MessagesCdo.php | 208 +- languages/messages/MessagesCe.php | 506 ++--- languages/messages/MessagesCeb.php | 52 +- languages/messages/MessagesCh.php | 4 +- languages/messages/MessagesCkb.php | 174 +- languages/messages/MessagesCrh_cyrl.php | 24 +- languages/messages/MessagesCrh_latn.php | 22 +- languages/messages/MessagesCs.php | 448 ++-- languages/messages/MessagesCsb.php | 4 +- languages/messages/MessagesCu.php | 44 +- languages/messages/MessagesCv.php | 6 +- languages/messages/MessagesCy.php | 138 +- languages/messages/MessagesDa.php | 190 +- languages/messages/MessagesDe.php | 572 ++--- languages/messages/MessagesDe_ch.php | 2 +- languages/messages/MessagesDiq.php | 550 ++--- languages/messages/MessagesDsb.php | 198 +- languages/messages/MessagesDv.php | 90 +- languages/messages/MessagesDz.php | 4 +- languages/messages/MessagesEl.php | 510 ++--- languages/messages/MessagesEn.php | 612 +++--- languages/messages/MessagesEn_gb.php | 12 +- languages/messages/MessagesEo.php | 468 ++-- languages/messages/MessagesEs.php | 524 ++--- languages/messages/MessagesEt.php | 452 ++-- languages/messages/MessagesEu.php | 150 +- languages/messages/MessagesExt.php | 12 +- languages/messages/MessagesFa.php | 584 ++--- languages/messages/MessagesFf.php | 2 +- languages/messages/MessagesFi.php | 448 ++-- languages/messages/MessagesFo.php | 106 +- languages/messages/MessagesFr.php | 524 ++--- languages/messages/MessagesFrp.php | 486 ++--- languages/messages/MessagesFur.php | 142 +- languages/messages/MessagesFy.php | 168 +- languages/messages/MessagesGa.php | 94 +- languages/messages/MessagesGag.php | 84 +- languages/messages/MessagesGan.php | 8 +- languages/messages/MessagesGan_hans.php | 4 +- languages/messages/MessagesGan_hant.php | 52 +- languages/messages/MessagesGd.php | 4 +- languages/messages/MessagesGl.php | 462 ++-- languages/messages/MessagesGlk.php | 8 +- languages/messages/MessagesGn.php | 6 +- languages/messages/MessagesGom_deva.php | 4 +- languages/messages/MessagesGot.php | 12 +- languages/messages/MessagesGrc.php | 4 +- languages/messages/MessagesGsw.php | 198 +- languages/messages/MessagesGu.php | 174 +- languages/messages/MessagesGv.php | 4 +- languages/messages/MessagesHaw.php | 176 +- languages/messages/MessagesHe.php | 560 ++--- languages/messages/MessagesHi.php | 518 ++--- languages/messages/MessagesHif_latn.php | 4 +- languages/messages/MessagesHr.php | 460 ++-- languages/messages/MessagesHsb.php | 206 +- languages/messages/MessagesHt.php | 204 +- languages/messages/MessagesHu.php | 452 ++-- languages/messages/MessagesHy.php | 374 ++-- languages/messages/MessagesIa.php | 206 +- languages/messages/MessagesId.php | 504 ++--- languages/messages/MessagesIe.php | 188 +- languages/messages/MessagesIg.php | 62 +- languages/messages/MessagesIlo.php | 4 +- languages/messages/MessagesIo.php | 132 +- languages/messages/MessagesIs.php | 302 +-- languages/messages/MessagesIt.php | 364 ++-- languages/messages/MessagesJa.php | 540 ++--- languages/messages/MessagesJbo.php | 4 +- languages/messages/MessagesJv.php | 8 +- languages/messages/MessagesKa.php | 214 +- languages/messages/MessagesKaa.php | 146 +- languages/messages/MessagesKab.php | 8 +- languages/messages/MessagesKbd_cyrl.php | 10 +- languages/messages/MessagesKg.php | 4 +- languages/messages/MessagesKhw.php | 4 +- languages/messages/MessagesKiu.php | 8 +- languages/messages/MessagesKk_arab.php | 436 ++-- languages/messages/MessagesKk_cyrl.php | 436 ++-- languages/messages/MessagesKk_latn.php | 434 ++-- languages/messages/MessagesKl.php | 8 +- languages/messages/MessagesKm.php | 352 +-- languages/messages/MessagesKn.php | 8 +- languages/messages/MessagesKo.php | 578 ++--- languages/messages/MessagesKo_kp.php | 8 +- languages/messages/MessagesKrc.php | 142 +- languages/messages/MessagesKs_arab.php | 12 +- languages/messages/MessagesKs_deva.php | 8 +- languages/messages/MessagesKsh.php | 212 +- languages/messages/MessagesKu_arab.php | 4 +- languages/messages/MessagesKu_latn.php | 120 +- languages/messages/MessagesKv.php | 8 +- languages/messages/MessagesKw.php | 294 +-- languages/messages/MessagesKy.php | 4 +- languages/messages/MessagesLa.php | 186 +- languages/messages/MessagesLad.php | 216 +- languages/messages/MessagesLb.php | 288 +-- languages/messages/MessagesLbe.php | 10 +- languages/messages/MessagesLez.php | 10 +- languages/messages/MessagesLfn.php | 12 +- languages/messages/MessagesLi.php | 186 +- languages/messages/MessagesLij.php | 150 +- languages/messages/MessagesLmo.php | 68 +- languages/messages/MessagesLn.php | 4 +- languages/messages/MessagesLo.php | 102 +- languages/messages/MessagesLrc.php | 232 +- languages/messages/MessagesLt.php | 238 +- languages/messages/MessagesLtg.php | 4 +- languages/messages/MessagesLv.php | 30 +- languages/messages/MessagesLzh.php | 184 +- languages/messages/MessagesLzz.php | 8 +- languages/messages/MessagesMai.php | 4 +- languages/messages/MessagesMdf.php | 178 +- languages/messages/MessagesMg.php | 358 +-- languages/messages/MessagesMhr.php | 58 +- languages/messages/MessagesMin.php | 212 +- languages/messages/MessagesMk.php | 548 ++--- languages/messages/MessagesMl.php | 546 ++--- languages/messages/MessagesMn.php | 14 +- languages/messages/MessagesMo.php | 10 +- languages/messages/MessagesMr.php | 480 ++--- languages/messages/MessagesMrj.php | 10 +- languages/messages/MessagesMs.php | 292 +-- languages/messages/MessagesMt.php | 444 ++-- languages/messages/MessagesMwl.php | 50 +- languages/messages/MessagesMy.php | 12 +- languages/messages/MessagesMyv.php | 286 +-- languages/messages/MessagesMzn.php | 108 +- languages/messages/MessagesNah.php | 42 +- languages/messages/MessagesNan.php | 28 +- languages/messages/MessagesNap.php | 8 +- languages/messages/MessagesNb.php | 462 ++-- languages/messages/MessagesNds.php | 240 +-- languages/messages/MessagesNds_nl.php | 502 ++--- languages/messages/MessagesNe.php | 16 +- languages/messages/MessagesNew.php | 8 +- languages/messages/MessagesNl.php | 558 ++--- languages/messages/MessagesNn.php | 412 ++-- languages/messages/MessagesNso.php | 24 +- languages/messages/MessagesNv.php | 4 +- languages/messages/MessagesOc.php | 440 ++-- languages/messages/MessagesOr.php | 362 ++-- languages/messages/MessagesOs.php | 258 +-- languages/messages/MessagesPa.php | 236 +- languages/messages/MessagesPcd.php | 2 +- languages/messages/MessagesPdc.php | 20 +- languages/messages/MessagesPfl.php | 10 +- languages/messages/MessagesPi.php | 8 +- languages/messages/MessagesPl.php | 404 ++-- languages/messages/MessagesPms.php | 4 +- languages/messages/MessagesPnb.php | 4 +- languages/messages/MessagesPnt.php | 16 +- languages/messages/MessagesPs.php | 236 +- languages/messages/MessagesPt.php | 452 ++-- languages/messages/MessagesPt_br.php | 432 ++-- languages/messages/MessagesQu.php | 480 ++--- languages/messages/MessagesQug.php | 6 +- languages/messages/MessagesRm.php | 16 +- languages/messages/MessagesRmy.php | 4 +- languages/messages/MessagesRo.php | 444 ++-- languages/messages/MessagesRoa_tara.php | 18 +- languages/messages/MessagesRu.php | 542 ++--- languages/messages/MessagesRue.php | 180 +- languages/messages/MessagesSa.php | 390 ++-- languages/messages/MessagesSah.php | 10 +- languages/messages/MessagesSc.php | 12 +- languages/messages/MessagesScn.php | 208 +- languages/messages/MessagesSd.php | 240 +-- languages/messages/MessagesSdc.php | 146 +- languages/messages/MessagesSe.php | 192 +- languages/messages/MessagesSg.php | 2 +- languages/messages/MessagesSgs.php | 10 +- languages/messages/MessagesSh.php | 342 +-- languages/messages/MessagesSi.php | 270 +-- languages/messages/MessagesSk.php | 328 +-- languages/messages/MessagesSl.php | 236 +- languages/messages/MessagesSq.php | 290 +-- languages/messages/MessagesSr_ec.php | 492 ++--- languages/messages/MessagesSr_el.php | 304 +-- languages/messages/MessagesSrn.php | 202 +- languages/messages/MessagesStq.php | 12 +- languages/messages/MessagesSu.php | 170 +- languages/messages/MessagesSv.php | 470 ++-- languages/messages/MessagesSw.php | 154 +- languages/messages/MessagesSzl.php | 10 +- languages/messages/MessagesTa.php | 38 +- languages/messages/MessagesTe.php | 172 +- languages/messages/MessagesTet.php | 76 +- languages/messages/MessagesTg_cyrl.php | 16 +- languages/messages/MessagesTh.php | 226 +- languages/messages/MessagesTk.php | 4 +- languages/messages/MessagesTl.php | 206 +- languages/messages/MessagesTly.php | 238 +- languages/messages/MessagesTpi.php | 34 +- languages/messages/MessagesTr.php | 526 ++--- languages/messages/MessagesTt_cyrl.php | 200 +- languages/messages/MessagesTt_latn.php | 64 +- languages/messages/MessagesTy.php | 2 +- languages/messages/MessagesTyv.php | 136 +- languages/messages/MessagesUdm.php | 12 +- languages/messages/MessagesUg_arab.php | 18 +- languages/messages/MessagesUk.php | 532 ++--- languages/messages/MessagesUr.php | 224 +- languages/messages/MessagesUz.php | 116 +- languages/messages/MessagesVec.php | 210 +- languages/messages/MessagesVep.php | 102 +- languages/messages/MessagesVi.php | 530 ++--- languages/messages/MessagesVls.php | 4 +- languages/messages/MessagesVmf.php | 54 +- languages/messages/MessagesVo.php | 118 +- languages/messages/MessagesVro.php | 10 +- languages/messages/MessagesWa.php | 56 +- languages/messages/MessagesWar.php | 50 +- languages/messages/MessagesWo.php | 64 +- languages/messages/MessagesXal.php | 10 +- languages/messages/MessagesYi.php | 286 +-- languages/messages/MessagesYo.php | 36 +- languages/messages/MessagesYue.php | 208 +- languages/messages/MessagesZea.php | 4 +- languages/messages/MessagesZh.php | 180 +- languages/messages/MessagesZh_hans.php | 572 ++--- languages/messages/MessagesZh_hant.php | 378 ++-- languages/messages/MessagesZh_hk.php | 8 +- languages/messages/MessagesZh_tw.php | 64 +- maintenance/Maintenance.php | 72 +- maintenance/archives/upgradeLogging.php | 14 +- maintenance/attachLatest.php | 6 +- maintenance/backup.inc | 12 +- maintenance/benchmarks/Benchmarker.php | 6 +- maintenance/benchmarks/bench_HTTP_HTTPS.php | 10 +- .../bench_Wikimedia_base_convert.php | 22 +- .../benchmarks/bench_delete_truncate.php | 4 +- maintenance/benchmarks/bench_if_switch.php | 8 +- .../benchmarks/bench_strtr_str_replace.php | 12 +- .../benchmarks/bench_utf8_title_check.php | 34 +- maintenance/benchmarks/bench_wfIsWindows.php | 8 +- maintenance/benchmarks/benchmarkHooks.php | 8 +- maintenance/benchmarks/benchmarkParse.php | 14 +- maintenance/benchmarks/benchmarkPurge.php | 6 +- maintenance/cdb.php | 4 +- maintenance/checkBadRedirects.php | 6 +- maintenance/checkImages.php | 4 +- maintenance/checkLess.php | 4 +- maintenance/checkSyntax.php | 26 +- maintenance/checkUsernames.php | 8 +- maintenance/cleanupAncientTables.php | 12 +- maintenance/cleanupBlocks.php | 32 +- maintenance/cleanupCaps.php | 8 +- maintenance/cleanupImages.php | 26 +- maintenance/cleanupPreferences.php | 2 +- maintenance/cleanupRemovedModules.php | 2 +- maintenance/cleanupSpam.php | 10 +- maintenance/cleanupTable.inc | 20 +- maintenance/cleanupTitles.php | 14 +- maintenance/cleanupUploadStash.php | 18 +- maintenance/cleanupWatchlist.php | 12 +- maintenance/clearInterwikiCache.php | 4 +- maintenance/commandLine.inc | 2 +- maintenance/compareParserCache.php | 8 +- .../convertExtensionToRegistration.php | 30 +- maintenance/convertLinks.php | 6 +- maintenance/convertUserOptions.php | 24 +- maintenance/copyFileBackend.php | 80 +- maintenance/copyJobQueue.php | 10 +- maintenance/createAndPromote.php | 8 +- maintenance/createCommonPasswordCdb.php | 2 +- maintenance/deleteArchivedFiles.php | 10 +- maintenance/deleteBatch.php | 4 +- maintenance/deleteDefaultMessages.php | 8 +- maintenance/deleteEqualMessages.php | 14 +- maintenance/deleteOldRevisions.php | 12 +- maintenance/deleteOrphanedRevisions.php | 6 +- maintenance/deleteRevision.php | 24 +- maintenance/doMaintenance.php | 2 +- maintenance/dumpIterator.php | 2 +- maintenance/dumpLinks.php | 10 +- maintenance/dumpTextPass.php | 44 +- maintenance/dumpUploads.php | 2 +- maintenance/edit.php | 2 +- maintenance/eraseArchivedFile.php | 6 +- maintenance/eval.php | 2 +- maintenance/fetchText.php | 4 +- maintenance/fileOpPerfTest.php | 32 +- maintenance/findDeprecated.php | 8 +- maintenance/findHooks.php | 44 +- maintenance/findMissingFiles.php | 38 +- maintenance/findOrphanedFiles.php | 30 +- maintenance/fixDefaultJsonContentPages.php | 22 +- maintenance/fixDoubleRedirects.php | 22 +- maintenance/fixExtLinksProtocolRelative.php | 20 +- maintenance/fixTimestamps.php | 2 +- maintenance/fixUserRegistration.php | 14 +- maintenance/generateJsonI18n.php | 4 +- maintenance/generateLocalAutoload.php | 2 +- maintenance/generateSitemap.php | 24 +- maintenance/getConfiguration.php | 10 +- maintenance/importDump.php | 12 +- maintenance/importImages.inc | 12 +- maintenance/importImages.php | 20 +- maintenance/importSiteScripts.php | 16 +- maintenance/importSites.php | 2 +- maintenance/importTextFiles.php | 4 +- maintenance/initEditCount.php | 4 +- maintenance/language/StatOutputs.php | 2 +- maintenance/language/checkLanguage.inc | 98 +- maintenance/language/date-formats.php | 4 +- maintenance/language/dumpMessages.php | 2 +- .../language/generateCollationData.php | 26 +- .../language/generateNormalizerDataAr.php | 8 +- .../language/generateNormalizerDataMl.php | 6 +- maintenance/language/generateUtf8Case.php | 14 +- maintenance/language/languages.inc | 74 +- maintenance/language/listVariants.php | 4 +- maintenance/language/transstat.php | 2 +- maintenance/mcc.php | 10 +- maintenance/mctest.php | 8 +- maintenance/mergeMessageFileList.php | 16 +- maintenance/migrateFileRepoLayout.php | 54 +- maintenance/migrateUserGroup.php | 20 +- maintenance/moveBatch.php | 2 +- maintenance/mwdocgen.php | 10 +- maintenance/namespaceDupes.php | 80 +- maintenance/nukeNS.php | 6 +- maintenance/nukePage.php | 2 +- maintenance/orphans.php | 16 +- maintenance/patchSql.php | 4 +- maintenance/populateBacklinkNamespace.php | 14 +- maintenance/populateCategory.php | 8 +- maintenance/populateContentModel.php | 48 +- maintenance/populateFilearchiveSha1.php | 10 +- maintenance/populateImageSha1.php | 14 +- maintenance/populateLogSearch.php | 22 +- maintenance/populateLogUsertext.php | 8 +- maintenance/populateParentId.php | 24 +- maintenance/populateRecentChangesSource.php | 6 +- maintenance/populateRevisionLength.php | 8 +- maintenance/populateRevisionSha1.php | 12 +- maintenance/preprocessorFuzzTest.php | 16 +- maintenance/protect.php | 8 +- maintenance/purgeChangedFiles.php | 48 +- maintenance/purgeChangedPages.php | 32 +- maintenance/purgeList.php | 18 +- maintenance/purgeParserCache.php | 2 +- maintenance/reassignEdits.php | 6 +- maintenance/rebuildFileCache.php | 10 +- maintenance/rebuildImages.php | 12 +- maintenance/rebuildLocalisationCache.php | 2 +- maintenance/rebuildmessages.php | 2 +- maintenance/rebuildrecentchanges.php | 58 +- maintenance/rebuildtextindex.php | 4 +- maintenance/refreshFileHeaders.php | 8 +- maintenance/refreshImageMetadata.php | 10 +- maintenance/refreshLinks.php | 40 +- maintenance/removeInvalidEmails.php | 14 +- maintenance/removeUnusedAccounts.php | 32 +- maintenance/renderDump.php | 2 +- maintenance/resetUserTokens.php | 12 +- maintenance/rollbackEdits.php | 14 +- maintenance/runJobs.php | 6 +- maintenance/showJobs.php | 8 +- maintenance/showSiteStats.php | 4 +- maintenance/sql.php | 4 +- maintenance/sqlite.inc | 6 +- maintenance/sqlite.php | 2 +- maintenance/storage/checkStorage.php | 92 +- maintenance/storage/compressOld.php | 62 +- maintenance/storage/dumpRev.php | 6 +- maintenance/storage/fixBug20757.php | 46 +- maintenance/storage/moveToExternal.php | 10 +- maintenance/storage/orphanStats.php | 6 +- maintenance/storage/recompressTracked.php | 118 +- maintenance/storage/resolveStubs.php | 18 +- maintenance/storage/storageTypeStats.php | 16 +- maintenance/storage/testCompression.php | 12 +- maintenance/storage/trackBlobs.php | 60 +- maintenance/syncFileBackend.php | 36 +- maintenance/tidyUpBug37714.php | 14 +- maintenance/undelete.php | 4 +- maintenance/update.php | 6 +- maintenance/updateArticleCount.php | 4 +- maintenance/updateCollation.php | 34 +- maintenance/updateDoubleWidthSearch.php | 2 +- maintenance/updateRestrictions.php | 22 +- maintenance/updateSearchIndex.php | 2 +- maintenance/userDupes.inc | 18 +- maintenance/userOptions.inc | 16 +- maintenance/wrapOldPasswords.php | 16 +- mw-config/index.php | 2 +- mw-config/overrides.php | 2 +- opensearch_desc.php | 20 +- phpcs.xml | 5 + profileinfo.php | 26 +- resources/Resources.php | 1916 ++++++++--------- resources/ResourcesOOUI.php | 74 +- tests/TestsAutoLoader.php | 4 +- tests/parser/parserTest.inc | 194 +- tests/parser/parserTestsParserHook.php | 6 +- tests/parserTests.php | 8 +- tests/phpunit/MediaWikiLangTestCase.php | 4 +- tests/phpunit/MediaWikiTestCase.php | 60 +- tests/phpunit/ResourceLoaderTestCase.php | 26 +- tests/phpunit/data/xmp/1.result.php | 8 +- tests/phpunit/data/xmp/2.result.php | 8 +- tests/phpunit/data/xmp/3-invalid.result.php | 8 +- tests/phpunit/data/xmp/3.result.php | 8 +- tests/phpunit/data/xmp/4.result.php | 8 +- tests/phpunit/data/xmp/5.result.php | 8 +- tests/phpunit/data/xmp/6.result.php | 8 +- tests/phpunit/data/xmp/7.result.php | 36 +- tests/phpunit/data/xmp/bag-for-seq.result.php | 12 +- .../data/xmp/doctype-included.result.php | 2 +- tests/phpunit/data/xmp/flash.result.php | 8 +- tests/phpunit/data/xmp/gps.result.php | 8 +- .../xmp/invalid-child-not-struct.result.php | 8 +- .../phpunit/data/xmp/no-namespace.result.php | 8 +- .../data/xmp/no-recognized-props.result.php | 2 +- tests/phpunit/data/xmp/utf16BE.result.php | 12 +- tests/phpunit/data/xmp/utf16LE.result.php | 12 +- tests/phpunit/data/xmp/utf32BE.result.php | 12 +- tests/phpunit/data/xmp/utf32LE.result.php | 12 +- tests/phpunit/data/xmp/xmpExt.result.php | 8 +- tests/phpunit/includes/BlockTest.php | 94 +- tests/phpunit/includes/CollationTest.php | 72 +- .../phpunit/includes/DiffHistoryBlobTest.php | 16 +- tests/phpunit/includes/EditPageTest.php | 208 +- tests/phpunit/includes/ExportTest.php | 4 +- tests/phpunit/includes/ExtraParserTest.php | 24 +- tests/phpunit/includes/FallbackTest.php | 22 +- tests/phpunit/includes/FauxRequestTest.php | 4 +- tests/phpunit/includes/FauxResponseTest.php | 10 +- .../FormOptionsInitializationTest.php | 20 +- tests/phpunit/includes/FormOptionsTest.php | 2 +- .../includes/GlobalFunctions/GlobalTest.php | 400 ++-- .../GlobalFunctions/GlobalWithDBTest.php | 24 +- .../GlobalFunctions/wfAppendQueryTest.php | 42 +- .../GlobalFunctions/wfArrayPlus2dTest.php | 124 +- .../GlobalFunctions/wfAssembleUrlTest.php | 60 +- .../includes/GlobalFunctions/wfBCP47Test.php | 84 +- .../GlobalFunctions/wfBaseNameTest.php | 40 +- .../GlobalFunctions/wfEscapeShellArgTest.php | 2 +- .../GlobalFunctions/wfExpandUrlTest.php | 38 +- .../GlobalFunctions/wfParseUrlTest.php | 92 +- .../wfRemoveDotSegmentsTest.php | 134 +- .../wfShorthandToIntegerTest.php | 20 +- .../GlobalFunctions/wfThumbIsStandardTest.php | 92 +- .../GlobalFunctions/wfTimestampTest.php | 118 +- .../GlobalFunctions/wfUrlencodeTest.php | 28 +- tests/phpunit/includes/HooksTest.php | 50 +- tests/phpunit/includes/HtmlFormatterTest.php | 48 +- tests/phpunit/includes/HtmlTest.php | 378 ++-- tests/phpunit/includes/HttpTest.php | 600 +++--- tests/phpunit/includes/LicensesTest.php | 4 +- tests/phpunit/includes/LinkFilterTest.php | 200 +- tests/phpunit/includes/LinkerTest.php | 72 +- tests/phpunit/includes/MWNamespaceTest.php | 42 +- tests/phpunit/includes/MWTimestampTest.php | 136 +- tests/phpunit/includes/MediaWikiTest.php | 94 +- tests/phpunit/includes/MergeHistoryTest.php | 24 +- tests/phpunit/includes/MessageTest.php | 220 +- tests/phpunit/includes/MimeMagicTest.php | 32 +- tests/phpunit/includes/MovePageTest.php | 16 +- tests/phpunit/includes/OutputPageTest.php | 178 +- tests/phpunit/includes/PagePropsTest.php | 36 +- tests/phpunit/includes/PathRouterTest.php | 116 +- tests/phpunit/includes/PreferencesTest.php | 6 +- tests/phpunit/includes/PrefixSearchTest.php | 188 +- .../phpunit/includes/RevisionStorageTest.php | 78 +- ...RevisionStorageTestContentHandlerUseDB.php | 8 +- tests/phpunit/includes/RevisionTest.php | 108 +- tests/phpunit/includes/SampleTest.php | 18 +- tests/phpunit/includes/SanitizerTest.php | 214 +- .../includes/SiteConfigurationTest.php | 148 +- tests/phpunit/includes/StatusTest.php | 176 +- .../includes/TemplateCategoriesTest.php | 16 +- tests/phpunit/includes/TemplateParserTest.php | 48 +- tests/phpunit/includes/TestLogger.php | 8 +- tests/phpunit/includes/TestUser.php | 10 +- tests/phpunit/includes/TimeAdjustTest.php | 24 +- .../includes/TitleArrayFromResultTest.php | 18 +- tests/phpunit/includes/TitleMethodsTest.php | 278 +-- .../phpunit/includes/TitlePermissionTest.php | 372 ++-- tests/phpunit/includes/TitleTest.php | 434 ++-- tests/phpunit/includes/WebRequestTest.php | 326 +-- tests/phpunit/includes/WikiMapTest.php | 102 +- tests/phpunit/includes/WikiReferenceTest.php | 66 +- tests/phpunit/includes/XmlJsTest.php | 8 +- tests/phpunit/includes/XmlSelectTest.php | 24 +- tests/phpunit/includes/XmlTest.php | 32 +- tests/phpunit/includes/actions/ActionTest.php | 34 +- tests/phpunit/includes/api/ApiBaseTest.php | 6 +- tests/phpunit/includes/api/ApiBlockTest.php | 8 +- .../api/ApiContinuationManagerTest.php | 136 +- .../includes/api/ApiCreateAccountTest.php | 40 +- .../phpunit/includes/api/ApiEditPageTest.php | 100 +- .../includes/api/ApiErrorFormatterTest.php | 454 ++-- tests/phpunit/includes/api/ApiLoginTest.php | 78 +- tests/phpunit/includes/api/ApiMainTest.php | 160 +- tests/phpunit/includes/api/ApiMessageTest.php | 54 +- .../includes/api/ApiModuleManagerTest.php | 160 +- tests/phpunit/includes/api/ApiOptionsTest.php | 118 +- tests/phpunit/includes/api/ApiPageSetTest.php | 42 +- tests/phpunit/includes/api/ApiParseTest.php | 4 +- tests/phpunit/includes/api/ApiPurgeTest.php | 6 +- .../includes/api/ApiQueryAllPagesTest.php | 4 +- tests/phpunit/includes/api/ApiResultTest.php | 1222 +++++------ .../includes/api/ApiRevisionDeleteTest.php | 20 +- tests/phpunit/includes/api/ApiTestCase.php | 34 +- .../includes/api/ApiTestCaseUpload.php | 16 +- tests/phpunit/includes/api/ApiUnblockTest.php | 4 +- tests/phpunit/includes/api/ApiUploadTest.php | 60 +- tests/phpunit/includes/api/ApiWatchTest.php | 28 +- tests/phpunit/includes/api/MockApi.php | 4 +- .../includes/api/PrefixUniquenessTest.php | 2 +- .../includes/api/RandomImageGenerator.php | 84 +- tests/phpunit/includes/api/UserWrapper.php | 4 +- .../includes/api/format/ApiFormatJsonTest.php | 138 +- .../includes/api/format/ApiFormatNoneTest.php | 52 +- .../includes/api/format/ApiFormatPhpTest.php | 8 +- .../includes/api/format/ApiFormatTestBase.php | 2 +- .../includes/api/generateRandomImages.php | 4 +- .../includes/api/query/ApiQueryBasicTest.php | 270 +-- .../api/query/ApiQueryContinue2Test.php | 6 +- .../api/query/ApiQueryContinueTest.php | 48 +- .../api/query/ApiQueryContinueTestBase.php | 8 +- .../api/query/ApiQueryRevisionsTest.php | 4 +- .../includes/api/query/ApiQueryTest.php | 56 +- .../includes/api/query/ApiQueryTestBase.php | 8 +- .../includes/cache/GenderCacheTest.php | 32 +- .../includes/cache/LocalisationCacheTest.php | 30 +- .../includes/cache/MessageCacheTest.php | 56 +- .../changes/EnhancedChangesListTest.php | 4 +- .../includes/changes/OldChangesListTest.php | 14 +- .../changes/RCCacheEntryFactoryTest.php | 110 +- .../includes/changes/RecentChangeTest.php | 40 +- .../changes/TestRecentChangesHelper.php | 26 +- .../ComposerVersionNormalizerTest.php | 98 +- .../includes/config/ConfigFactoryTest.php | 4 +- .../includes/config/GlobalVarConfigTest.php | 32 +- .../includes/config/HashConfigTest.php | 16 +- .../includes/config/MultiConfigTest.php | 20 +- .../includes/content/ContentHandlerTest.php | 174 +- .../content/CssContentHandlerTest.php | 4 +- .../includes/content/CssContentTest.php | 54 +- .../content/JavaScriptContentHandlerTest.php | 4 +- .../content/JavaScriptContentTest.php | 198 +- .../includes/content/JsonContentTest.php | 94 +- .../includes/content/TextContentTest.php | 152 +- .../content/WikitextContentHandlerTest.php | 70 +- .../includes/content/WikitextContentTest.php | 230 +- .../includes/context/RequestContextTest.php | 12 +- .../includes/db/DatabaseMysqlBaseTest.php | 114 +- tests/phpunit/includes/db/DatabaseSQLTest.php | 594 ++--- .../includes/db/DatabaseSqliteTest.php | 90 +- tests/phpunit/includes/db/DatabaseTest.php | 14 +- .../includes/db/DatabaseTestHelper.php | 8 +- tests/phpunit/includes/db/LBFactoryTest.php | 70 +- tests/phpunit/includes/debug/MWDebugTest.php | 20 +- .../debug/logger/LegacyLoggerTest.php | 136 +- .../includes/debug/logger/MonologSpiTest.php | 152 +- .../logger/monolog/AvroFormatterTest.php | 22 +- .../debug/logger/monolog/KafkaHandlerTest.php | 86 +- .../includes/deferred/CdnCacheUpdateTest.php | 4 +- .../includes/deferred/DeferredUpdatesTest.php | 8 +- .../includes/deferred/LinksUpdateTest.php | 92 +- .../includes/diff/ArrayDiffFormatterTest.php | 110 +- tests/phpunit/includes/diff/DiffOpTest.php | 14 +- tests/phpunit/includes/diff/DiffTest.php | 2 +- .../includes/diff/DifferenceEngineTest.php | 26 +- .../includes/exception/ErrorPageErrorTest.php | 4 +- .../includes/exception/HttpErrorTest.php | 28 +- .../exception/MWExceptionHandlerTest.php | 2 +- .../includes/exception/MWExceptionTest.php | 116 +- .../includes/exception/ReadOnlyErrorTest.php | 2 +- .../exception/UserNotLoggedInTest.php | 2 +- .../externalstore/ExternalStoreTest.php | 14 +- .../includes/filebackend/FileBackendTest.php | 1078 +++++----- .../filebackend/SwiftFileBackendTest.php | 78 +- .../filerepo/FileBackendDBRepoWrapperTest.php | 46 +- .../includes/filerepo/FileRepoTest.php | 20 +- .../filerepo/MigrateFileRepoLayoutTest.php | 24 +- .../includes/filerepo/RepoGroupTest.php | 12 +- .../includes/filerepo/StoreBatchTest.php | 16 +- .../includes/filerepo/file/FileTest.php | 164 +- .../includes/filerepo/file/LocalFileTest.php | 18 +- .../HTMLAutoCompleteSelectFieldTest.php | 16 +- .../includes/htmlform/HTMLCheckMatrixTest.php | 50 +- .../installer/DatabaseUpdaterTest.php | 10 +- .../installer/InstallDocFormatterTest.php | 64 +- .../installer/OracleInstallerTest.php | 34 +- .../includes/jobqueue/JobQueueMemoryTest.php | 8 +- .../includes/jobqueue/JobQueueTest.php | 70 +- tests/phpunit/includes/jobqueue/JobTest.php | 48 +- .../jobqueue/RefreshLinksPartitionTest.php | 20 +- .../phpunit/includes/json/FormatJsonTest.php | 176 +- .../phpunit/includes/libs/ArrayUtilsTest.php | 384 ++-- tests/phpunit/includes/libs/CSSMinTest.php | 154 +- .../includes/libs/DeferredStringifierTest.php | 20 +- .../includes/libs/GenericArrayObjectTest.php | 10 +- tests/phpunit/includes/libs/HashRingTest.php | 24 +- .../includes/libs/JavaScriptMinifierTest.php | 180 +- .../includes/libs/MWMessagePackTest.php | 70 +- .../includes/libs/MemoizedCallableTest.php | 14 +- .../includes/libs/ObjectFactoryTest.php | 78 +- .../includes/libs/ProcessCacheLRUTest.php | 70 +- .../libs/SamplingStatsdClientTest.php | 16 +- .../phpunit/includes/libs/StringUtilsTest.php | 160 +- tests/phpunit/includes/libs/TimingTest.php | 4 +- tests/phpunit/includes/libs/XhprofTest.php | 98 +- .../includes/libs/XmlTypeCheckTest.php | 4 +- .../libs/composer/ComposerJsonTest.php | 20 +- .../libs/composer/ComposerLockTest.php | 106 +- .../libs/objectcache/BagOStuffTest.php | 18 +- .../libs/objectcache/HashBagOStuffTest.php | 14 +- .../objectcache/MultiWriteBagOStuffTest.php | 6 +- .../objectcache/ReplicatedBagOStuffTest.php | 4 +- .../libs/objectcache/WANObjectCacheTest.php | 118 +- .../logging/BlockLogFormatterTest.php | 276 +-- .../logging/DeleteLogFormatterTest.php | 372 ++-- .../logging/ImportLogFormatterTest.php | 90 +- .../includes/logging/LogFormatterTest.php | 146 +- .../includes/logging/LogFormatterTestCase.php | 4 +- .../includes/logging/LogTests.i18n.php | 6 +- .../logging/MergeLogFormatterTest.php | 44 +- .../includes/logging/MoveLogFormatterTest.php | 208 +- .../logging/NewUsersLogFormatterTest.php | 120 +- .../logging/PageLangLogFormatterTest.php | 30 +- .../logging/PatrolLogFormatterTest.php | 84 +- .../logging/ProtectLogFormatterTest.php | 328 +-- .../logging/RightsLogFormatterTest.php | 128 +- .../logging/UploadLogFormatterTest.php | 120 +- .../phpunit/includes/mail/MailAddressTest.php | 20 +- .../media/BitmapMetadataHandlerTest.php | 34 +- .../includes/media/BitmapScalingTest.php | 114 +- tests/phpunit/includes/media/DjVuTest.php | 4 +- .../phpunit/includes/media/ExifBitmapTest.php | 56 +- .../includes/media/ExifRotationTest.php | 140 +- tests/phpunit/includes/media/ExifTest.php | 8 +- .../includes/media/FormatMetadataTest.php | 54 +- .../media/GIFMetadataExtractorTest.php | 34 +- tests/phpunit/includes/media/GIFTest.php | 72 +- tests/phpunit/includes/media/IPTCTest.php | 12 +- .../media/JpegMetadataExtractorTest.php | 16 +- tests/phpunit/includes/media/JpegTest.php | 8 +- .../includes/media/MediaHandlerTest.php | 20 +- .../includes/media/MediaWikiMediaTestCase.php | 10 +- tests/phpunit/includes/media/PNGTest.php | 62 +- .../media/SVGMetadataExtractorTest.php | 90 +- tests/phpunit/includes/media/SVGTest.php | 10 +- tests/phpunit/includes/media/WebPTest.php | 42 +- tests/phpunit/includes/media/XCFTest.php | 32 +- tests/phpunit/includes/media/XMPTest.php | 84 +- .../includes/media/XMPValidateTest.php | 42 +- .../objectcache/MemcachedBagOStuffTest.php | 30 +- .../includes/page/ArticleTablesTest.php | 2 +- .../includes/page/ImagePage404Test.php | 28 +- tests/phpunit/includes/page/ImagePageTest.php | 78 +- tests/phpunit/includes/page/WikiPageTest.php | 270 +-- .../includes/parser/MagicVariableTest.php | 12 +- .../includes/parser/MediaWikiParserTest.php | 6 +- .../phpunit/includes/parser/NewParserTest.php | 166 +- .../includes/parser/ParserMethodsTest.php | 80 +- .../includes/parser/ParserOutputTest.php | 30 +- .../includes/parser/PreprocessorTest.php | 4 +- .../phpunit/includes/parser/TagHooksTest.php | 24 +- tests/phpunit/includes/parser/TidyTest.php | 20 +- .../includes/password/BcryptPasswordTest.php | 4 +- .../LayeredParameterizedPasswordTest.php | 20 +- .../includes/password/Pbkdf2PasswordTest.php | 16 +- .../password/UserPasswordPolicyTest.php | 130 +- .../includes/poolcounter/PoolCounterTest.php | 20 +- .../registration/CoreVersionCheckerTest.php | 38 +- .../registration/ExtensionProcessorTest.php | 412 ++-- .../registration/ExtensionRegistryTest.php | 294 +-- .../DerivativeResourceLoaderContextTest.php | 10 +- .../resourceloader/MessageBlobStoreTest.php | 60 +- .../ResourceLoaderFileModuleTest.php | 156 +- .../ResourceLoaderImageModuleTest.php | 84 +- .../ResourceLoaderImageTest.php | 42 +- .../ResourceLoaderModuleTest.php | 48 +- .../ResourceLoaderStartUpModuleTest.php | 178 +- .../resourceloader/ResourceLoaderTest.php | 148 +- .../ResourceLoaderWikiModuleTest.php | 98 +- .../search/SearchEnginePrefixTest.php | 190 +- .../includes/search/SearchEngineTest.php | 32 +- .../BotPasswordSessionProviderTest.php | 118 +- .../session/CookieSessionProviderTest.php | 304 +-- ...ImmutableSessionProviderWithCookieTest.php | 78 +- .../session/PHPSessionHandlerTest.php | 114 +- .../includes/session/SessionBackendTest.php | 134 +- .../includes/session/SessionInfoTest.php | 110 +- .../includes/session/SessionManagerTest.php | 816 +++---- .../includes/session/SessionProviderTest.php | 50 +- .../phpunit/includes/session/SessionTest.php | 96 +- .../includes/session/TestBagOStuff.php | 16 +- tests/phpunit/includes/session/TestUtils.php | 10 +- tests/phpunit/includes/session/TokenTest.php | 4 +- .../includes/site/CachingSiteStoreTest.php | 2 +- .../phpunit/includes/site/DBSiteStoreTest.php | 10 +- .../includes/site/FileBasedSiteLookupTest.php | 2 +- .../includes/site/HashSiteStoreTest.php | 4 +- .../site/MediaWikiPageNameNormalizerTest.php | 18 +- .../includes/site/MediaWikiSiteTest.php | 42 +- .../includes/site/SiteExporterTest.php | 16 +- .../includes/site/SiteImporterTest.php | 40 +- tests/phpunit/includes/site/SiteListTest.php | 10 +- tests/phpunit/includes/site/SiteTest.php | 16 +- .../site/SitesCacheFileBuilderTest.php | 50 +- tests/phpunit/includes/site/TestSites.php | 6 +- .../specialpage/SpecialPageFactoryTest.php | 108 +- .../includes/specialpage/SpecialPageTest.php | 30 +- .../specials/QueryAllSpecialPagesTest.php | 8 +- .../specials/SpecialBooksourcesTest.php | 42 +- .../specials/SpecialMIMESearchTest.php | 14 +- .../specials/SpecialMyLanguageTest.php | 22 +- .../includes/specials/SpecialPageTestBase.php | 2 +- .../specials/SpecialPreferencesTest.php | 10 +- .../specials/SpecialRecentchangesTest.php | 40 +- .../includes/specials/SpecialSearchTest.php | 72 +- .../includes/title/ForeignTitleTest.php | 40 +- .../title/MediaWikiPageLinkRendererTest.php | 52 +- .../title/MediaWikiTitleCodecTest.php | 266 +-- .../title/NaiveForeignTitleFactoryTest.php | 36 +- .../title/NaiveImportTitleFactoryTest.php | 46 +- .../NamespaceAwareForeignTitleFactoryTest.php | 36 +- .../title/NamespaceImportTitleFactoryTest.php | 28 +- .../title/SubpageImportTitleFactoryTest.php | 30 +- .../phpunit/includes/title/TitleValueTest.php | 48 +- .../includes/upload/UploadBaseTest.php | 64 +- .../includes/upload/UploadFromUrlTest.php | 32 +- .../includes/upload/UploadStashTest.php | 28 +- .../phpunit/includes/user/BotPasswordTest.php | 134 +- .../includes/user/CentralIdLookupTest.php | 52 +- .../includes/user/LocalIdLookupTest.php | 30 +- .../includes/user/UserArrayFromResultTest.php | 18 +- tests/phpunit/includes/user/UserTest.php | 168 +- .../includes/utils/AvroValidatorTest.php | 100 +- .../includes/utils/BatchRowUpdateTest.php | 108 +- .../includes/utils/FileContentsHasherTest.php | 14 +- tests/phpunit/includes/utils/IPTest.php | 412 ++-- tests/phpunit/includes/utils/MWGrantsTest.php | 82 +- .../includes/utils/MWRestrictionsTest.php | 104 +- .../includes/utils/UIDGeneratorTest.php | 20 +- .../includes/utils/ZipDirectoryReaderTest.php | 12 +- .../languages/LanguageConverterTest.php | 18 +- tests/phpunit/languages/LanguageTest.php | 1210 +++++------ .../languages/SpecialPageAliasTest.php | 8 +- .../languages/classes/LanguageAmTest.php | 14 +- .../languages/classes/LanguageArTest.php | 54 +- .../languages/classes/LanguageArqTest.php | 8 +- .../languages/classes/LanguageBeTest.php | 28 +- .../classes/LanguageBe_taraskTest.php | 44 +- .../languages/classes/LanguageBhoTest.php | 14 +- .../languages/classes/LanguageBsTest.php | 28 +- .../languages/classes/LanguageCsTest.php | 26 +- .../languages/classes/LanguageCuTest.php | 28 +- .../languages/classes/LanguageCyTest.php | 30 +- .../languages/classes/LanguageDsbTest.php | 26 +- .../languages/classes/LanguageFrTest.php | 14 +- .../languages/classes/LanguageGaTest.php | 14 +- .../languages/classes/LanguageGanTest.php | 20 +- .../languages/classes/LanguageGdTest.php | 44 +- .../languages/classes/LanguageGvTest.php | 30 +- .../languages/classes/LanguageHeTest.php | 78 +- .../languages/classes/LanguageHiTest.php | 14 +- .../languages/classes/LanguageHrTest.php | 28 +- .../languages/classes/LanguageHsbTest.php | 26 +- .../languages/classes/LanguageHuTest.php | 14 +- .../languages/classes/LanguageHyTest.php | 14 +- .../languages/classes/LanguageIuTest.php | 20 +- .../languages/classes/LanguageKkTest.php | 12 +- .../languages/classes/LanguageKshTest.php | 14 +- .../languages/classes/LanguageKuTest.php | 28 +- .../languages/classes/LanguageLnTest.php | 14 +- .../languages/classes/LanguageLtTest.php | 46 +- .../languages/classes/LanguageLvTest.php | 32 +- .../languages/classes/LanguageMgTest.php | 16 +- .../languages/classes/LanguageMkTest.php | 24 +- .../languages/classes/LanguageMlTest.php | 32 +- .../languages/classes/LanguageMoTest.php | 34 +- .../languages/classes/LanguageMtTest.php | 76 +- .../languages/classes/LanguageNsoTest.php | 12 +- .../languages/classes/LanguagePlTest.php | 76 +- .../languages/classes/LanguageRoTest.php | 34 +- .../languages/classes/LanguageRuTest.php | 126 +- .../languages/classes/LanguageSeTest.php | 28 +- .../languages/classes/LanguageSgsTest.php | 64 +- .../languages/classes/LanguageShTest.php | 28 +- .../languages/classes/LanguageShiTest.php | 20 +- .../languages/classes/LanguageSkTest.php | 26 +- .../languages/classes/LanguageSlTest.php | 30 +- .../languages/classes/LanguageSmaTest.php | 28 +- .../languages/classes/LanguageSrTest.php | 44 +- .../languages/classes/LanguageTgTest.php | 20 +- .../languages/classes/LanguageTiTest.php | 12 +- .../languages/classes/LanguageTlTest.php | 16 +- .../languages/classes/LanguageTrTest.php | 24 +- .../languages/classes/LanguageUkTest.php | 70 +- .../languages/classes/LanguageWaTest.php | 12 +- .../languages/classes/LanguageZhTest.php | 60 +- tests/phpunit/maintenance/DumpTestCase.php | 2 +- tests/phpunit/maintenance/MaintenanceTest.php | 24 +- .../maintenance/backupPrefetchTest.php | 18 +- .../maintenance/backupTextPassTest.php | 42 +- tests/phpunit/maintenance/backup_LogTest.php | 14 +- tests/phpunit/maintenance/backup_PageTest.php | 20 +- tests/phpunit/maintenance/fetchTextTest.php | 10 +- .../content/DummyContentHandlerForTesting.php | 2 +- .../content/DummyNonTextContentHandler.php | 2 +- .../phpunit/mocks/filebackend/MockFSFile.php | 4 +- .../mocks/filebackend/MockFileBackend.php | 2 +- tests/phpunit/mocks/media/MockDjVuHandler.php | 4 +- .../phpunit/mocks/media/MockImageHandler.php | 4 +- .../mocks/session/DummySessionBackend.php | 4 +- .../mocks/session/DummySessionProvider.php | 8 +- tests/phpunit/phpunit.php | 30 +- .../structure/ApiDocumentationTest.php | 28 +- tests/phpunit/structure/AutoLoaderTest.php | 22 +- .../phpunit/structure/AvailableRightsTest.php | 2 +- tests/phpunit/structure/ResourcesTest.php | 44 +- tests/phpunit/structure/StructureTest.php | 8 +- .../phpunit/suites/UploadFromUrlTestSuite.php | 18 +- tests/phpunit/tests/MediaWikiTestCaseTest.php | 14 +- tests/qunit/QUnitTestResources.php | 40 +- tests/qunit/data/generateJqueryMsgData.php | 48 +- tests/qunit/data/load.mock.php | 6 +- tests/testHelpers.inc | 68 +- thumb.php | 32 +- 1652 files changed, 57888 insertions(+), 57883 deletions(-) diff --git a/api.php b/api.php index 83c1373c14..6e75fb746a 100644 --- a/api.php +++ b/api.php @@ -68,7 +68,7 @@ try { $processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI ); // Last chance hook before executing the API - Hooks::run( 'ApiBeforeMain', array( &$processor ) ); + Hooks::run( 'ApiBeforeMain', [ &$processor ] ); if ( !$processor instanceof ApiMain ) { throw new MWException( 'ApiBeforeMain hook set $processor to a non-ApiMain class' ); } @@ -88,12 +88,12 @@ $endtime = microtime( true ); // Log the request if ( $wgAPIRequestLog ) { - $items = array( + $items = [ wfTimestamp( TS_MW ), $endtime - $starttime, $wgRequest->getIP(), $wgRequest->getHeader( 'User-agent' ) - ); + ]; $items[] = $wgRequest->wasPosted() ? 'POST' : 'GET'; if ( $processor ) { try { diff --git a/img_auth.php b/img_auth.php index 885914171c..d63618817a 100644 --- a/img_auth.php +++ b/img_auth.php @@ -43,7 +43,7 @@ require __DIR__ . '/includes/WebStart.php'; # Set action base paths so that WebRequest::getPathInfo() # recognizes the "X" as the 'title' in ../img_auth.php/X urls. $wgArticlePath = false; # Don't let a "/*" article path clober our action path -$wgActionPaths = array( "$wgUploadPath/" ); +$wgActionPaths = [ "$wgUploadPath/" ]; wfImageAuthMain(); @@ -54,7 +54,7 @@ function wfImageAuthMain() { global $wgImgAuthUrlPathMap; $request = RequestContext::getMain()->getRequest(); - $publicWiki = in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ); + $publicWiki = in_array( 'read', User::getGroupPermissions( [ '*' ] ), true ); // Get the requested file path (source file or thumbnail) $matches = WebRequest::getPathInfo(); @@ -69,7 +69,7 @@ function wfImageAuthMain() { } // Check for bug 28235: QUERY_STRING overriding the correct extension - $whitelist = array(); + $whitelist = []; $extension = FileBackend::extensionFromPath( $path, 'rawcase' ); if ( $extension != '' ) { $whitelist[] = $extension; @@ -90,10 +90,10 @@ function wfImageAuthMain() { wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $path ); return; } - if ( $be->fileExists( array( 'src' => $filename ) ) ) { + if ( $be->fileExists( [ 'src' => $filename ] ) ) { wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." ); - $be->streamFile( array( 'src' => $filename ), - array( 'Cache-Control: private', 'Vary: Cookie' ) ); + $be->streamFile( [ 'src' => $filename ], + [ 'Cache-Control: private', 'Vary: Cookie' ] ); } else { wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $path ); } @@ -133,7 +133,7 @@ function wfImageAuthMain() { } } - $headers = array(); // extra HTTP headers to send + $headers = []; // extra HTTP headers to send if ( !$publicWiki ) { // For private wikis, run extra auth checks and set cache control headers @@ -149,7 +149,7 @@ function wfImageAuthMain() { // Run hook for extension authorization plugins /** @var $result array */ $result = null; - if ( !Hooks::run( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) { + if ( !Hooks::run( 'ImgAuthBeforeStream', [ &$title, &$path, &$name, &$result ] ) ) { wfForbidden( $result[0], $result[1], array_slice( $result, 2 ) ); return; } diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index c2ea582e63..91422385a2 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -74,7 +74,7 @@ class AjaxDispatcher { if ( !empty( $_GET["rsargs"] ) ) { $this->args = $_GET["rsargs"]; } else { - $this->args = array(); + $this->args = []; } break; case 'post': @@ -82,7 +82,7 @@ class AjaxDispatcher { if ( !empty( $_POST["rsargs"] ) ) { $this->args = $_POST["rsargs"]; } else { - $this->args = array(); + $this->args = []; } break; default: diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php index 6c2782c0fa..4fe46dd1af 100644 --- a/includes/AjaxResponse.php +++ b/includes/AjaxResponse.php @@ -303,10 +303,10 @@ class AjaxResponse { */ function storeInMemcached( $mckey, $expiry = 86400 ) { ObjectCache::getMainWANInstance()->set( $mckey, - array( + [ 'timestamp' => wfTimestampNow(), 'value' => $this->mText - ), $expiry + ], $expiry ); return true; diff --git a/includes/AuthPlugin.php b/includes/AuthPlugin.php index badf47c375..6449d371cc 100644 --- a/includes/AuthPlugin.php +++ b/includes/AuthPlugin.php @@ -157,11 +157,11 @@ class AuthPlugin { * @return bool */ public function allowPropChange( $prop = '' ) { - if ( $prop == 'realname' && is_callable( array( $this, 'allowRealNameChange' ) ) ) { + if ( $prop == 'realname' && is_callable( [ $this, 'allowRealNameChange' ] ) ) { return $this->allowRealNameChange(); - } elseif ( $prop == 'emailaddress' && is_callable( array( $this, 'allowEmailChange' ) ) ) { + } elseif ( $prop == 'emailaddress' && is_callable( [ $this, 'allowEmailChange' ] ) ) { return $this->allowEmailChange(); - } elseif ( $prop == 'nickname' && is_callable( array( $this, 'allowNickChange' ) ) ) { + } elseif ( $prop == 'nickname' && is_callable( [ $this, 'allowNickChange' ] ) ) { return $this->allowNickChange(); } else { return true; @@ -224,7 +224,7 @@ class AuthPlugin { * @param array $delgroups Groups to remove. * @return bool */ - public function updateExternalDBGroups( $user, $addgroups, $delgroups = array() ) { + public function updateExternalDBGroups( $user, $addgroups, $delgroups = [] ) { return true; } @@ -318,7 +318,7 @@ class AuthPlugin { * @return array */ public function domainList() { - return array(); + return []; } } diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 6344c27668..4a0818561d 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -111,4 +111,4 @@ class AutoLoader { } } -spl_autoload_register( array( 'AutoLoader', 'autoload' ) ); +spl_autoload_register( [ 'AutoLoader', 'autoload' ] ); diff --git a/includes/Autopromote.php b/includes/Autopromote.php index d492d196af..56fbb07f88 100644 --- a/includes/Autopromote.php +++ b/includes/Autopromote.php @@ -35,7 +35,7 @@ class Autopromote { public static function getAutopromoteGroups( User $user ) { global $wgAutopromote; - $promote = array(); + $promote = []; foreach ( $wgAutopromote as $group => $cond ) { if ( self::recCheckCondition( $cond, $user ) ) { @@ -43,7 +43,7 @@ class Autopromote { } } - Hooks::run( 'GetAutoPromoteGroups', array( $user, &$promote ) ); + Hooks::run( 'GetAutoPromoteGroups', [ $user, &$promote ] ); return $promote; } @@ -63,7 +63,7 @@ class Autopromote { public static function getAutopromoteOnceGroups( User $user, $event ) { global $wgAutopromoteOnce; - $promote = array(); + $promote = []; if ( isset( $wgAutopromoteOnce[$event] ) && count( $wgAutopromoteOnce[$event] ) ) { $currentGroups = $user->getGroups(); @@ -104,7 +104,7 @@ class Autopromote { * @return bool Whether the condition is true */ private static function recCheckCondition( $cond, User $user ) { - $validOps = array( '&', '|', '^', '!' ); + $validOps = [ '&', '|', '^', '!' ]; if ( is_array( $cond ) && count( $cond ) >= 2 && in_array( $cond[0], $validOps ) ) { # Recursive condition @@ -144,7 +144,7 @@ class Autopromote { // If we got here, the array presumably does not contain other conditions; // it's not recursive. Pass it off to self::checkCondition. if ( !is_array( $cond ) ) { - $cond = array( $cond ); + $cond = [ $cond ]; } return self::checkCondition( $cond, $user ); @@ -197,8 +197,8 @@ class Autopromote { return in_array( 'bot', User::getGroupPermissions( $user->getGroups() ) ); default: $result = null; - Hooks::run( 'AutopromoteCondition', array( $cond[0], - array_slice( $cond, 1 ), $user, &$result ) ); + Hooks::run( 'AutopromoteCondition', [ $cond[0], + array_slice( $cond, 1 ), $user, &$result ] ); if ( $result === null ) { throw new MWException( "Unrecognized condition {$cond[0]} for autopromotion!" ); } diff --git a/includes/Block.php b/includes/Block.php index c017c6c9b7..696a520ed8 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -100,8 +100,8 @@ class Block { * @since 1.26 accepts $options array instead of individual parameters; order * of parameters above reflects the original order */ - function __construct( $options = array() ) { - $defaults = array( + function __construct( $options = [] ) { + $defaults = [ 'address' => '', 'user' => null, 'by' => null, @@ -116,7 +116,7 @@ class Block { 'blockEmail' => false, 'allowUsertalk' => false, 'byText' => '', - ); + ]; if ( func_num_args() > 1 || !is_array( $options ) ) { $options = array_combine( @@ -172,7 +172,7 @@ class Block { $res = $dbr->selectRow( 'ipblocks', self::selectFields(), - array( 'ipb_id' => $id ), + [ 'ipb_id' => $id ], __METHOD__ ); if ( $res ) { @@ -188,7 +188,7 @@ class Block { * @return array */ public static function selectFields() { - return array( + return [ 'ipb_id', 'ipb_address', 'ipb_by', @@ -204,7 +204,7 @@ class Block { 'ipb_block_email', 'ipb_allow_usertalk', 'ipb_parent_block_id', - ); + ]; } /** @@ -245,11 +245,11 @@ class Block { $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE ); if ( $this->type !== null ) { - $conds = array( - 'ipb_address' => array( (string)$this->target ), - ); + $conds = [ + 'ipb_address' => [ (string)$this->target ], + ]; } else { - $conds = array( 'ipb_address' => array() ); + $conds = [ 'ipb_address' => [] ]; } # Be aware that the != '' check is explicit, since empty values will be @@ -360,11 +360,11 @@ class Block { $safeEnd = $dbr->addQuotes( $end ); return $dbr->makeList( - array( + [ "ipb_range_start $like", "ipb_range_start <= $safeStart", "ipb_range_end >= $safeEnd", - ), + ], LIST_AND ); } @@ -442,8 +442,8 @@ class Block { } $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'ipblocks', array( 'ipb_parent_block_id' => $this->getId() ), __METHOD__ ); - $dbw->delete( 'ipblocks', array( 'ipb_id' => $this->getId() ), __METHOD__ ); + $dbw->delete( 'ipblocks', [ 'ipb_parent_block_id' => $this->getId() ], __METHOD__ ); + $dbw->delete( 'ipblocks', [ 'ipb_id' => $this->getId() ], __METHOD__ ); return $dbw->affectedRows() > 0; } @@ -471,7 +471,7 @@ class Block { $row = $this->getDatabaseArray(); $row['ipb_id'] = $dbw->nextSequenceValue( "ipblocks_ipb_id_seq" ); - $dbw->insert( 'ipblocks', $row, __METHOD__, array( 'IGNORE' ) ); + $dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] ); $affected = $dbw->affectedRows(); $this->mId = $dbw->insertId(); @@ -482,16 +482,16 @@ class Block { # use a standard SELECT + DELETE to avoid annoying gap locks. $ids = $dbw->selectFieldValues( 'ipblocks', 'ipb_id', - array( + [ 'ipb_address' => $row['ipb_address'], 'ipb_user' => $row['ipb_user'], 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) - ), + ], __METHOD__ ); if ( $ids ) { - $dbw->delete( 'ipblocks', array( 'ipb_id' => $ids ), __METHOD__ ); - $dbw->insert( 'ipblocks', $row, __METHOD__, array( 'IGNORE' ) ); + $dbw->delete( 'ipblocks', [ 'ipb_id' => $ids ], __METHOD__ ); + $dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] ); $affected = $dbw->affectedRows(); $this->mId = $dbw->insertId(); } @@ -499,7 +499,7 @@ class Block { if ( $affected ) { $auto_ipd_ids = $this->doRetroactiveAutoblock(); - return array( 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ); + return [ 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ]; } return false; @@ -521,7 +521,7 @@ class Block { $dbw->update( 'ipblocks', $this->getDatabaseArray( $dbw ), - array( 'ipb_id' => $this->getId() ), + [ 'ipb_id' => $this->getId() ], __METHOD__ ); @@ -532,14 +532,14 @@ class Block { $dbw->update( 'ipblocks', $this->getAutoblockUpdateArray(), - array( 'ipb_parent_block_id' => $this->getId() ), + [ 'ipb_parent_block_id' => $this->getId() ], __METHOD__ ); } else { // autoblock no longer required, delete corresponding autoblock(s) $dbw->delete( 'ipblocks', - array( 'ipb_parent_block_id' => $this->getId() ), + [ 'ipb_parent_block_id' => $this->getId() ], __METHOD__ ); } @@ -548,7 +548,7 @@ class Block { if ( $affected ) { $auto_ipd_ids = $this->doRetroactiveAutoblock(); - return array( 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ); + return [ 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ]; } return false; @@ -571,7 +571,7 @@ class Block { $uid = $this->target instanceof User ? $this->target->getID() : 0; } - $a = array( + $a = [ 'ipb_address' => (string)$this->target, 'ipb_user' => $uid, 'ipb_by' => $this->getBy(), @@ -589,7 +589,7 @@ class Block { 'ipb_block_email' => $this->prevents( 'sendemail' ), 'ipb_allow_usertalk' => !$this->prevents( 'editownusertalk' ), 'ipb_parent_block_id' => $this->mParentBlockId - ); + ]; return $a; } @@ -598,14 +598,14 @@ class Block { * @return array */ protected function getAutoblockUpdateArray() { - return array( + return [ 'ipb_by' => $this->getBy(), 'ipb_by_text' => $this->getByName(), 'ipb_reason' => $this->mReason, 'ipb_create_account' => $this->prevents( 'createaccount' ), 'ipb_deleted' => (int)$this->mHideName, // typecast required for SQLite 'ipb_allow_usertalk' => !$this->prevents( 'editownusertalk' ), - ); + ]; } /** @@ -615,13 +615,13 @@ class Block { * @return array Block IDs of retroactive autoblocks made */ protected function doRetroactiveAutoblock() { - $blockIds = array(); + $blockIds = []; # If autoblock is enabled, autoblock the LAST IP(s) used if ( $this->isAutoblocking() && $this->getType() == self::TYPE_USER ) { wfDebug( "Doing retroactive autoblocks for " . $this->getTarget() . "\n" ); $continue = Hooks::run( - 'PerformRetroactiveAutoblock', array( $this, &$blockIds ) ); + 'PerformRetroactiveAutoblock', [ $this, &$blockIds ] ); if ( $continue ) { self::defaultRetroactiveAutoblock( $this, $blockIds ); @@ -647,13 +647,13 @@ class Block { $dbr = wfGetDB( DB_SLAVE ); - $options = array( 'ORDER BY' => 'rc_timestamp DESC' ); - $conds = array( 'rc_user_text' => (string)$block->getTarget() ); + $options = [ 'ORDER BY' => 'rc_timestamp DESC' ]; + $conds = [ 'rc_user_text' => (string)$block->getTarget() ]; // Just the last IP used. $options['LIMIT'] = 1; - $res = $dbr->select( 'recentchanges', array( 'rc_ip' ), $conds, + $res = $dbr->select( 'recentchanges', [ 'rc_ip' ], $conds, __METHOD__, $options ); if ( !$res->numRows() ) { @@ -734,7 +734,7 @@ class Block { } # Allow hooks to cancel the autoblock. - if ( !Hooks::run( 'AbortAutoblock', array( $autoblockIP, &$this ) ) ) { + if ( !Hooks::run( 'AbortAutoblock', [ $autoblockIP, &$this ] ) ) { wfDebug( "Autoblock aborted by hook.\n" ); return false; } @@ -839,13 +839,13 @@ class Block { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'ipblocks', - array( /* SET */ + [ /* SET */ 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ), 'ipb_expiry' => $dbw->timestamp( $this->mExpiry ), - ), - array( /* WHERE */ + ], + [ /* WHERE */ 'ipb_address' => (string)$this->getTarget() - ), + ], __METHOD__ ); } @@ -993,7 +993,7 @@ class Block { if ( $this->mAuto ) { return Html::rawElement( 'span', - array( 'class' => 'mw-autoblockid' ), + [ 'class' => 'mw-autoblockid' ], wfMessage( 'autoblockid', $this->mId ) ); } else { @@ -1027,7 +1027,7 @@ class Block { function ( IDatabase $dbw, $fname ) { $dbw->delete( 'ipblocks', - array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), + [ 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ], $fname ); } @@ -1068,7 +1068,7 @@ class Block { } elseif ( in_array( $type, - array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) + [ Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ] ) ) { $block = new Block(); $block->fromMaster( $fromMaster ); @@ -1096,10 +1096,10 @@ class Block { */ public static function getBlocksForIPList( array $ipChain, $isAnon, $fromMaster = false ) { if ( !count( $ipChain ) ) { - return array(); + return []; } - $conds = array(); + $conds = []; foreach ( array_unique( $ipChain ) as $ipaddr ) { # Discard invalid IP addresses. Since XFF can be spoofed and we do not # necessarily trust the header given to us, make sure that we are only @@ -1120,7 +1120,7 @@ class Block { } if ( !count( $conds ) ) { - return array(); + return []; } if ( $fromMaster ) { @@ -1130,10 +1130,10 @@ class Block { } $conds = $db->makeList( $conds, LIST_OR ); if ( !$isAnon ) { - $conds = array( $conds, 'ipb_anon_only' => 0 ); + $conds = [ $conds, 'ipb_anon_only' => 0 ]; } $selectFields = array_merge( - array( 'ipb_range_start', 'ipb_range_end' ), + [ 'ipb_range_start', 'ipb_range_end' ], Block::selectFields() ); $rows = $db->select( 'ipblocks', @@ -1142,7 +1142,7 @@ class Block { __METHOD__ ); - $blocks = array(); + $blocks = []; foreach ( $rows as $row ) { $block = self::newFromRow( $row ); if ( !$block->isExpired() ) { @@ -1189,18 +1189,18 @@ class Block { return strcmp( $bWeight, $aWeight ); // highest weight first } ); - $blocksListExact = array( + $blocksListExact = [ 'hard' => false, 'disable_create' => false, 'other' => false, 'auto' => false - ); - $blocksListRange = array( + ]; + $blocksListRange = [ 'hard' => false, 'disable_create' => false, 'other' => false, 'auto' => false - ); + ]; $ipChain = array_reverse( $ipChain ); /** @var Block $block */ @@ -1227,7 +1227,7 @@ class Block { } // We found closest exact match in the ip list, so go to the next Block break; - } elseif ( array_filter( $blocksListExact ) == array() + } elseif ( array_filter( $blocksListExact ) == [] && $block->getRangeStart() <= $checkipHex && $block->getRangeEnd() >= $checkipHex ) { @@ -1245,7 +1245,7 @@ class Block { } } - if ( array_filter( $blocksListExact ) == array() ) { + if ( array_filter( $blocksListExact ) == [] ) { $blocksList = &$blocksListRange; } else { $blocksList = &$blocksListExact; @@ -1280,12 +1280,12 @@ class Block { # We may have been through this before if ( $target instanceof User ) { if ( IP::isValid( $target->getName() ) ) { - return array( $target, self::TYPE_IP ); + return [ $target, self::TYPE_IP ]; } else { - return array( $target, self::TYPE_USER ); + return [ $target, self::TYPE_USER ]; } } elseif ( $target === null ) { - return array( null, null ); + return [ null, null ]; } $target = trim( $target ); @@ -1293,14 +1293,14 @@ class Block { if ( IP::isValid( $target ) ) { # We can still create a User if it's an IP address, but we need to turn # off validation checking (which would exclude IP addresses) - return array( + return [ User::newFromName( IP::sanitizeIP( $target ), false ), Block::TYPE_IP - ); + ]; } elseif ( IP::isValidBlock( $target ) ) { # Can't create a User from an IP range - return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE ); + return [ IP::sanitizeRange( $target ), Block::TYPE_RANGE ]; } # Consider the possibility that this is not a username at all @@ -1316,15 +1316,15 @@ class Block { # Note that since numbers are valid usernames, a $target of "12345" will be # considered a User. If you want to pass a block ID, prepend a hash "#12345", # since hash characters are not valid in usernames or titles generally. - return array( $userObj, Block::TYPE_USER ); + return [ $userObj, Block::TYPE_USER ]; } elseif ( preg_match( '/^#\d+$/', $target ) ) { # Autoblock reference in the form "#12345" - return array( substr( $target, 1 ), Block::TYPE_AUTO ); + return [ substr( $target, 1 ), Block::TYPE_AUTO ]; } else { # WTF? - return array( null, null ); + return [ null, null ]; } } @@ -1346,7 +1346,7 @@ class Block { * @todo FIXME: This should be an integral part of the Block member variables */ public function getTargetAndType() { - return array( $this->getTarget(), $this->getType() ); + return [ $this->getTarget(), $this->getType() ]; } /** @@ -1418,7 +1418,7 @@ class Block { $intended = $this->getTarget(); $lang = $context->getLanguage(); - return array( + return [ $this->mAuto ? 'autoblockedtext' : 'blockedtext', $link, $reason, @@ -1428,6 +1428,6 @@ class Block { $lang->formatExpiry( $this->mExpiry ), (string)$intended, $lang->userTimeAndDate( $this->mTimestamp, $context->getUser() ), - ); + ]; } } diff --git a/includes/Category.php b/includes/Category.php index 3860172570..6209a1a9ea 100644 --- a/includes/Category.php +++ b/includes/Category.php @@ -52,9 +52,9 @@ class Category { if ( $this->mName === null && $this->mID === null ) { throw new MWException( __METHOD__ . ' has both names and IDs null' ); } elseif ( $this->mID === null ) { - $where = array( 'cat_title' => $this->mName ); + $where = [ 'cat_title' => $this->mName ]; } elseif ( $this->mName === null ) { - $where = array( 'cat_id' => $this->mID ); + $where = [ 'cat_id' => $this->mID ]; } else { # Already initialized return true; @@ -63,7 +63,7 @@ class Category { $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'category', - array( 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ), + [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ], $where, __METHOD__ ); @@ -257,8 +257,8 @@ class Category { $dbr = wfGetDB( DB_SLAVE ); - $conds = array( 'cl_to' => $this->getName(), 'cl_from = page_id' ); - $options = array( 'ORDER BY' => 'cl_sortkey' ); + $conds = [ 'cl_to' => $this->getName(), 'cl_from = page_id' ]; + $options = [ 'ORDER BY' => 'cl_sortkey' ]; if ( $limit ) { $options['LIMIT'] = $limit; @@ -270,9 +270,9 @@ class Category { $result = TitleArray::newFromResult( $dbr->select( - array( 'page', 'categorylinks' ), - array( 'page_id', 'page_namespace', 'page_title', 'page_len', - 'page_is_redirect', 'page_latest' ), + [ 'page', 'categorylinks' ], + [ 'page_id', 'page_namespace', 'page_title', 'page_len', + 'page_is_redirect', 'page_latest' ], $conds, __METHOD__, $options @@ -314,17 +314,17 @@ class Category { $dbw = wfGetDB( DB_MASTER ); $dbw->startAtomic( __METHOD__ ); - $cond1 = $dbw->conditional( array( 'page_namespace' => NS_CATEGORY ), 1, 'NULL' ); - $cond2 = $dbw->conditional( array( 'page_namespace' => NS_FILE ), 1, 'NULL' ); + $cond1 = $dbw->conditional( [ 'page_namespace' => NS_CATEGORY ], 1, 'NULL' ); + $cond2 = $dbw->conditional( [ 'page_namespace' => NS_FILE ], 1, 'NULL' ); $result = $dbw->selectRow( - array( 'categorylinks', 'page' ), - array( 'pages' => 'COUNT(*)', + [ 'categorylinks', 'page' ], + [ 'pages' => 'COUNT(*)', 'subcats' => "COUNT($cond1)", 'files' => "COUNT($cond2)" - ), - array( 'cl_to' => $this->mName, 'page_id = cl_from' ), + ], + [ 'cl_to' => $this->mName, 'page_id = cl_from' ], __METHOD__, - array( 'LOCK IN SHARE MODE' ) + [ 'LOCK IN SHARE MODE' ] ); if ( $this->mID ) { @@ -333,29 +333,29 @@ class Category { # in the cat_id sequence. The row may or may not be "affected". $dbw->update( 'category', - array( + [ 'cat_pages' => $result->pages, 'cat_subcats' => $result->subcats, 'cat_files' => $result->files - ), - array( 'cat_title' => $this->mName ), + ], + [ 'cat_title' => $this->mName ], __METHOD__ ); } else { $dbw->upsert( 'category', - array( + [ 'cat_title' => $this->mName, 'cat_pages' => $result->pages, 'cat_subcats' => $result->subcats, 'cat_files' => $result->files - ), - array( 'cat_title' ), - array( + ], + [ 'cat_title' ], + [ 'cat_pages' => $result->pages, 'cat_subcats' => $result->subcats, 'cat_files' => $result->files - ), + ], __METHOD__ ); } diff --git a/includes/CategoryFinder.php b/includes/CategoryFinder.php index d779141052..3f0528ebe0 100644 --- a/includes/CategoryFinder.php +++ b/includes/CategoryFinder.php @@ -44,22 +44,22 @@ */ class CategoryFinder { /** @var int[] The original article IDs passed to the seed function */ - protected $articles = array(); + protected $articles = []; /** @var array Array of DBKEY category names for categories that don't have a page */ - protected $deadend = array(); + protected $deadend = []; /** @var array Array of [ID => array()] */ - protected $parents = array(); + protected $parents = []; /** @var array Array of article/category IDs */ - protected $next = array(); + protected $next = []; /** @var array Array of DBKEY category names */ - protected $targets = array(); + protected $targets = []; /** @var array */ - protected $name2id = array(); + protected $name2id = []; /** @var string "AND" or "OR" */ protected $mode; @@ -80,7 +80,7 @@ class CategoryFinder { $this->mode = $mode; # Set the list of target categories; convert them to DBKEY form first - $this->targets = array(); + $this->targets = []; foreach ( $categories as $c ) { $ct = Title::makeTitleSafe( NS_CATEGORY, $c ); if ( $ct ) { @@ -102,7 +102,7 @@ class CategoryFinder { } # Now check if this applies to the individual articles - $ret = array(); + $ret = []; foreach ( $this->articles as $article ) { $conds = $this->targets; @@ -129,7 +129,7 @@ class CategoryFinder { * @param array $path Used to check for recursion loops * @return bool Does this match the conditions? */ - private function check( $id, &$conds, $path = array() ) { + private function check( $id, &$conds, $path = [] ) { // Check for loops and stop! if ( in_array( $id, $path ) ) { return false; @@ -155,7 +155,7 @@ class CategoryFinder { # This key is in the category list! if ( $this->mode == 'OR' ) { # One found, that's enough! - $conds = array(); + $conds = []; return true; } else { # Assuming "AND" as default @@ -187,11 +187,11 @@ class CategoryFinder { private function scanNextLayer() { # Find all parents of the article currently in $this->next - $layer = array(); + $layer = []; $res = $this->dbr->select( /* FROM */ 'categorylinks', /* SELECT */ '*', - /* WHERE */ array( 'cl_from' => $this->next ), + /* WHERE */ [ 'cl_from' => $this->next ], __METHOD__ . '-1' ); foreach ( $res as $o ) { @@ -199,7 +199,7 @@ class CategoryFinder { # Update parent tree if ( !isset( $this->parents[$o->cl_from] ) ) { - $this->parents[$o->cl_from] = array(); + $this->parents[$o->cl_from] = []; } $this->parents[$o->cl_from][$k] = $o; @@ -216,14 +216,14 @@ class CategoryFinder { $layer[$k] = $k; } - $this->next = array(); + $this->next = []; # Find the IDs of all category pages in $layer, if they exist if ( count( $layer ) > 0 ) { $res = $this->dbr->select( /* FROM */ 'page', - /* SELECT */ array( 'page_id', 'page_title' ), - /* WHERE */ array( 'page_namespace' => NS_CATEGORY, 'page_title' => $layer ), + /* SELECT */ [ 'page_id', 'page_title' ], + /* WHERE */ [ 'page_namespace' => NS_CATEGORY, 'page_title' => $layer ], __METHOD__ . '-2' ); foreach ( $res as $o ) { diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 2ceeed2795..b912603611 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -84,14 +84,14 @@ class CategoryViewer extends ContextSource { * @param array $until An array with 3 keys for until of each section (since 1.17) * @param array $query */ - function __construct( $title, IContextSource $context, $from = array(), - $until = array(), $query = array() + function __construct( $title, IContextSource $context, $from = [], + $until = [], $query = [] ) { $this->title = $title; $this->setContext( $context ); - $this->getOutput()->addModuleStyles( array( + $this->getOutput()->addModuleStyles( [ 'mediawiki.action.view.categoryPage.styles' - ) ); + ] ); $this->from = $from; $this->until = $until; $this->limit = $context->getConfig()->get( 'CategoryPagingLimit' ); @@ -138,7 +138,7 @@ class CategoryViewer extends ContextSource { } $lang = $this->getLanguage(); - $langAttribs = array( 'lang' => $lang->getHtmlCode(), 'dir' => $lang->getDir() ); + $langAttribs = [ 'lang' => $lang->getHtmlCode(), 'dir' => $lang->getDir() ]; # put a div around the headings which are in the user language $r = Html::openElement( 'div', $langAttribs ) . $r . ''; @@ -146,10 +146,10 @@ class CategoryViewer extends ContextSource { } function clearCategoryState() { - $this->articles = array(); - $this->articles_start_char = array(); - $this->children = array(); - $this->children_start_char = array(); + $this->articles = []; + $this->articles_start_char = []; + $this->children = []; + $this->children_start_char = []; if ( $this->showGallery ) { // Note that null for mode is taken to mean use default. $mode = $this->getRequest()->getVal( 'gallerymode', null ); @@ -162,8 +162,8 @@ class CategoryViewer extends ContextSource { $this->gallery->setHideBadImages(); } else { - $this->imgsNoGallery = array(); - $this->imgsNoGallery_start_char = array(); + $this->imgsNoGallery = []; + $this->imgsNoGallery_start_char = []; } } @@ -190,7 +190,7 @@ class CategoryViewer extends ContextSource { function generateLink( $type, Title $title, $isRedirect, $html = null ) { $link = null; - Hooks::run( 'CategoryViewer::generateLink', array( $type, $title, $html, &$link ) ); + Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] ); if ( $link === null ) { $link = Linker::link( $title, $html ); } @@ -284,24 +284,24 @@ class CategoryViewer extends ContextSource { function doCategoryQuery() { $dbr = wfGetDB( DB_SLAVE, 'category' ); - $this->nextPage = array( + $this->nextPage = [ 'page' => null, 'subcat' => null, 'file' => null, - ); - $this->prevPage = array( + ]; + $this->prevPage = [ 'page' => null, 'subcat' => null, 'file' => null, - ); + ]; - $this->flip = array( 'page' => false, 'subcat' => false, 'file' => false ); + $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ]; - foreach ( array( 'page', 'subcat', 'file' ) as $type ) { + foreach ( [ 'page', 'subcat', 'file' ] as $type ) { # Get the sortkeys for start/end, if applicable. Note that if # the collation in the database differs from the one # set in $wgCategoryCollation, pagination might go totally haywire. - $extraConds = array( 'cl_type' => $type ); + $extraConds = [ 'cl_type' => $type ]; if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) { $extraConds[] = 'cl_sortkey >= ' . $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) ); @@ -312,28 +312,28 @@ class CategoryViewer extends ContextSource { } $res = $dbr->select( - array( 'page', 'categorylinks', 'category' ), - array( 'page_id', 'page_title', 'page_namespace', 'page_len', + [ 'page', 'categorylinks', 'category' ], + [ 'page_id', 'page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files', - 'cl_sortkey_prefix', 'cl_collation' ), - array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ), + 'cl_sortkey_prefix', 'cl_collation' ], + array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ), __METHOD__, - array( - 'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ), + [ + 'USE INDEX' => [ 'categorylinks' => 'cl_sortkey' ], 'LIMIT' => $this->limit + 1, 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey', - ), - array( - 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ), - 'category' => array( 'LEFT JOIN', array( + ], + [ + 'categorylinks' => [ 'INNER JOIN', 'cl_from = page_id' ], + 'category' => [ 'LEFT JOIN', [ 'cat_title = page_title', 'page_namespace' => NS_CATEGORY - ) ) - ) + ] ] + ] ); - Hooks::run( 'CategoryViewer::doCategoryQuery', array( $type, $res ) ); + Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] ); $count = 0; foreach ( $res as $row ) { @@ -517,8 +517,8 @@ class CategoryViewer extends ContextSource { } $pageLang = $this->title->getPageLanguage(); - $attribs = array( 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(), - 'class' => 'mw-content-' . $pageLang->getDir() ); + $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-' . $pageLang->getDir() ]; $list = Html::rawElement( 'div', $attribs, $list ); return $list; @@ -541,15 +541,15 @@ class CategoryViewer extends ContextSource { static function columnList( $articles, $articles_start_char ) { $columns = array_combine( $articles, $articles_start_char ); - $ret = Html::openElement( 'div', array( 'class' => 'mw-category' ) ); + $ret = Html::openElement( 'div', [ 'class' => 'mw-category' ] ); - $colContents = array(); + $colContents = []; # Kind of like array_flip() here, but we keep duplicates in an # array instead of dropping them. foreach ( $columns as $article => $char ) { if ( !isset( $colContents[$char] ) ) { - $colContents[$char] = array(); + $colContents[$char] = []; } $colContents[$char][] = $article; } @@ -612,7 +612,7 @@ class CategoryViewer extends ContextSource { $prevLink = Linker::linkKnown( $this->addFragmentToTitle( $this->title, $type ), $prevLink, - array(), + [], $prevQuery ); } @@ -626,7 +626,7 @@ class CategoryViewer extends ContextSource { $nextLink = Linker::linkKnown( $this->addFragmentToTitle( $this->title, $type ), $nextLink, - array(), + [], $lastQuery ); } diff --git a/includes/Collation.php b/includes/Collation.php index 7fa5c6e477..7a3623d7d7 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -52,14 +52,14 @@ abstract class Collation { case 'xx-uca-et': return new CollationEt; default: - $match = array(); + $match = []; if ( preg_match( '/^uca-([a-z@=-]+)$/', $collationName, $match ) ) { return new IcuCollation( $match[1] ); } # Provide a mechanism for extensions to hook in. $collationObject = null; - Hooks::run( 'Collation::factory', array( $collationName, &$collationObject ) ); + Hooks::run( 'Collation::factory', [ $collationName, &$collationObject ] ); if ( $collationObject instanceof Collation ) { return $collationObject; @@ -180,23 +180,23 @@ class IcuCollation extends Collation { * is pretty useless for sorting Chinese text anyway. Japanese and Korean * blocks are not included here, because they are smaller and more useful. */ - private static $cjkBlocks = array( - array( 0x2E80, 0x2EFF ), // CJK Radicals Supplement - array( 0x2F00, 0x2FDF ), // Kangxi Radicals - array( 0x2FF0, 0x2FFF ), // Ideographic Description Characters - array( 0x3000, 0x303F ), // CJK Symbols and Punctuation - array( 0x31C0, 0x31EF ), // CJK Strokes - array( 0x3200, 0x32FF ), // Enclosed CJK Letters and Months - array( 0x3300, 0x33FF ), // CJK Compatibility - array( 0x3400, 0x4DBF ), // CJK Unified Ideographs Extension A - array( 0x4E00, 0x9FFF ), // CJK Unified Ideographs - array( 0xF900, 0xFAFF ), // CJK Compatibility Ideographs - array( 0xFE30, 0xFE4F ), // CJK Compatibility Forms - array( 0x20000, 0x2A6DF ), // CJK Unified Ideographs Extension B - array( 0x2A700, 0x2B73F ), // CJK Unified Ideographs Extension C - array( 0x2B740, 0x2B81F ), // CJK Unified Ideographs Extension D - array( 0x2F800, 0x2FA1F ), // CJK Compatibility Ideographs Supplement - ); + private static $cjkBlocks = [ + [ 0x2E80, 0x2EFF ], // CJK Radicals Supplement + [ 0x2F00, 0x2FDF ], // Kangxi Radicals + [ 0x2FF0, 0x2FFF ], // Ideographic Description Characters + [ 0x3000, 0x303F ], // CJK Symbols and Punctuation + [ 0x31C0, 0x31EF ], // CJK Strokes + [ 0x3200, 0x32FF ], // Enclosed CJK Letters and Months + [ 0x3300, 0x33FF ], // CJK Compatibility + [ 0x3400, 0x4DBF ], // CJK Unified Ideographs Extension A + [ 0x4E00, 0x9FFF ], // CJK Unified Ideographs + [ 0xF900, 0xFAFF ], // CJK Compatibility Ideographs + [ 0xFE30, 0xFE4F ], // CJK Compatibility Forms + [ 0x20000, 0x2A6DF ], // CJK Unified Ideographs Extension B + [ 0x2A700, 0x2B73F ], // CJK Unified Ideographs Extension C + [ 0x2B740, 0x2B81F ], // CJK Unified Ideographs Extension D + [ 0x2F800, 0x2FA1F ], // CJK Compatibility Ideographs Supplement + ]; /** * Additional characters (or character groups) to be considered separate @@ -219,80 +219,80 @@ class IcuCollation extends Collation { * Empty arrays are intended; this signifies that the data for the language is * available and that there are, in fact, no additional letters to consider. */ - private static $tailoringFirstLetters = array( + private static $tailoringFirstLetters = [ // Verified by native speakers - 'be' => array( "Ё" ), - 'be-tarask' => array( "Ё" ), - 'cy' => array( "Ch", "Dd", "Ff", "Ng", "Ll", "Ph", "Rh", "Th" ), - 'en' => array(), - 'fa' => array( "آ", "ء", "ه" ), - 'fi' => array( "Å", "Ä", "Ö" ), - 'fr' => array(), - 'hu' => array( "Cs", "Dz", "Dzs", "Gy", "Ly", "Ny", "Ö", "Sz", "Ty", "Ü", "Zs" ), - 'is' => array( "Á", "Ð", "É", "Í", "Ó", "Ú", "Ý", "Þ", "Æ", "Ö", "Å" ), - 'it' => array(), - 'lv' => array( "Č", "Ģ", "Ķ", "Ļ", "Ņ", "Š", "Ž" ), - 'pl' => array( "Ą", "Ć", "Ę", "Ł", "Ń", "Ó", "Ś", "Ź", "Ż" ), - 'pt' => array(), - 'ru' => array(), - 'sv' => array( "Å", "Ä", "Ö" ), - 'sv@collation=standard' => array( "Å", "Ä", "Ö" ), - 'uk' => array( "Ґ", "Ь" ), - 'vi' => array( "Ă", "Â", "Đ", "Ê", "Ô", "Ơ", "Ư" ), + 'be' => [ "Ё" ], + 'be-tarask' => [ "Ё" ], + 'cy' => [ "Ch", "Dd", "Ff", "Ng", "Ll", "Ph", "Rh", "Th" ], + 'en' => [], + 'fa' => [ "آ", "ء", "ه" ], + 'fi' => [ "Å", "Ä", "Ö" ], + 'fr' => [], + 'hu' => [ "Cs", "Dz", "Dzs", "Gy", "Ly", "Ny", "Ö", "Sz", "Ty", "Ü", "Zs" ], + 'is' => [ "Á", "Ð", "É", "Í", "Ó", "Ú", "Ý", "Þ", "Æ", "Ö", "Å" ], + 'it' => [], + 'lv' => [ "Č", "Ģ", "Ķ", "Ļ", "Ņ", "Š", "Ž" ], + 'pl' => [ "Ą", "Ć", "Ę", "Ł", "Ń", "Ó", "Ś", "Ź", "Ż" ], + 'pt' => [], + 'ru' => [], + 'sv' => [ "Å", "Ä", "Ö" ], + 'sv@collation=standard' => [ "Å", "Ä", "Ö" ], + 'uk' => [ "Ґ", "Ь" ], + 'vi' => [ "Ă", "Â", "Đ", "Ê", "Ô", "Ơ", "Ư" ], // Not verified, but likely correct - 'af' => array(), - 'ast' => array( "Ch", "Ll", "Ñ" ), - 'az' => array( "Ç", "Ə", "Ğ", "İ", "Ö", "Ş", "Ü" ), - 'bg' => array(), - 'br' => array( "Ch", "C'h" ), - 'bs' => array( "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ), - 'ca' => array(), - 'co' => array(), - 'cs' => array( "Č", "Ch", "Ř", "Š", "Ž" ), - 'da' => array( "Æ", "Ø", "Å" ), - 'de' => array(), - 'dsb' => array( "Č", "Ć", "Dź", "Ě", "Ch", "Ł", "Ń", "Ŕ", "Š", "Ś", "Ž", "Ź" ), - 'el' => array(), - 'eo' => array( "Ĉ", "Ĝ", "Ĥ", "Ĵ", "Ŝ", "Ŭ" ), - 'es' => array( "Ñ" ), - 'et' => array( "Š", "Ž", "Õ", "Ä", "Ö", "Ü", "W" ), // added W for CollationEt (xx-uca-et) - 'eu' => array( "Ñ" ), - 'fo' => array( "Á", "Ð", "Í", "Ó", "Ú", "Ý", "Æ", "Ø", "Å" ), - 'fur' => array( "À", "Á", "Â", "È", "Ì", "Ò", "Ù" ), - 'fy' => array(), - 'ga' => array(), - 'gd' => array(), - 'gl' => array( "Ch", "Ll", "Ñ" ), - 'hr' => array( "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ), - 'hsb' => array( "Č", "Dź", "Ě", "Ch", "Ł", "Ń", "Ř", "Š", "Ć", "Ž" ), - 'kk' => array( "Ү", "І" ), - 'kl' => array( "Æ", "Ø", "Å" ), - 'ku' => array( "Ç", "Ê", "Î", "Ş", "Û" ), - 'ky' => array( "Ё" ), - 'la' => array(), - 'lb' => array(), - 'lt' => array( "Č", "Š", "Ž" ), - 'mk' => array(), - 'mo' => array( "Ă", "Â", "Î", "Ş", "Ţ" ), - 'mt' => array( "Ċ", "Ġ", "Għ", "Ħ", "Ż" ), - 'nl' => array(), - 'no' => array( "Æ", "Ø", "Å" ), - 'oc' => array(), - 'rm' => array(), - 'ro' => array( "Ă", "Â", "Î", "Ş", "Ţ" ), - 'rup' => array( "Ă", "Â", "Î", "Ľ", "Ń", "Ş", "Ţ" ), - 'sco' => array(), - 'sk' => array( "Ä", "Č", "Ch", "Ô", "Š", "Ž" ), - 'sl' => array( "Č", "Š", "Ž" ), - 'smn' => array( "Á", "Č", "Đ", "Ŋ", "Š", "Ŧ", "Ž", "Æ", "Ø", "Å", "Ä", "Ö" ), - 'sq' => array( "Ç", "Dh", "Ë", "Gj", "Ll", "Nj", "Rr", "Sh", "Th", "Xh", "Zh" ), - 'sr' => array(), - 'tk' => array( "Ç", "Ä", "Ž", "Ň", "Ö", "Ş", "Ü", "Ý" ), - 'tl' => array( "Ñ", "Ng" ), - 'tr' => array( "Ç", "Ğ", "İ", "Ö", "Ş", "Ü" ), - 'tt' => array( "Ә", "Ө", "Ү", "Җ", "Ң", "Һ" ), - 'uz' => array( "Ch", "G'", "Ng", "O'", "Sh" ), - ); + 'af' => [], + 'ast' => [ "Ch", "Ll", "Ñ" ], + 'az' => [ "Ç", "Ə", "Ğ", "İ", "Ö", "Ş", "Ü" ], + 'bg' => [], + 'br' => [ "Ch", "C'h" ], + 'bs' => [ "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ], + 'ca' => [], + 'co' => [], + 'cs' => [ "Č", "Ch", "Ř", "Š", "Ž" ], + 'da' => [ "Æ", "Ø", "Å" ], + 'de' => [], + 'dsb' => [ "Č", "Ć", "Dź", "Ě", "Ch", "Ł", "Ń", "Ŕ", "Š", "Ś", "Ž", "Ź" ], + 'el' => [], + 'eo' => [ "Ĉ", "Ĝ", "Ĥ", "Ĵ", "Ŝ", "Ŭ" ], + 'es' => [ "Ñ" ], + 'et' => [ "Š", "Ž", "Õ", "Ä", "Ö", "Ü", "W" ], // added W for CollationEt (xx-uca-et) + 'eu' => [ "Ñ" ], + 'fo' => [ "Á", "Ð", "Í", "Ó", "Ú", "Ý", "Æ", "Ø", "Å" ], + 'fur' => [ "À", "Á", "Â", "È", "Ì", "Ò", "Ù" ], + 'fy' => [], + 'ga' => [], + 'gd' => [], + 'gl' => [ "Ch", "Ll", "Ñ" ], + 'hr' => [ "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ], + 'hsb' => [ "Č", "Dź", "Ě", "Ch", "Ł", "Ń", "Ř", "Š", "Ć", "Ž" ], + 'kk' => [ "Ү", "І" ], + 'kl' => [ "Æ", "Ø", "Å" ], + 'ku' => [ "Ç", "Ê", "Î", "Ş", "Û" ], + 'ky' => [ "Ё" ], + 'la' => [], + 'lb' => [], + 'lt' => [ "Č", "Š", "Ž" ], + 'mk' => [], + 'mo' => [ "Ă", "Â", "Î", "Ş", "Ţ" ], + 'mt' => [ "Ċ", "Ġ", "Għ", "Ħ", "Ż" ], + 'nl' => [], + 'no' => [ "Æ", "Ø", "Å" ], + 'oc' => [], + 'rm' => [], + 'ro' => [ "Ă", "Â", "Î", "Ş", "Ţ" ], + 'rup' => [ "Ă", "Â", "Î", "Ľ", "Ń", "Ş", "Ţ" ], + 'sco' => [], + 'sk' => [ "Ä", "Č", "Ch", "Ô", "Š", "Ž" ], + 'sl' => [ "Č", "Š", "Ž" ], + 'smn' => [ "Á", "Č", "Đ", "Ŋ", "Š", "Ŧ", "Ž", "Æ", "Ø", "Å", "Ä", "Ö" ], + 'sq' => [ "Ç", "Dh", "Ë", "Gj", "Ll", "Nj", "Rr", "Sh", "Th", "Xh", "Zh" ], + 'sr' => [], + 'tk' => [ "Ç", "Ä", "Ž", "Ň", "Ö", "Ş", "Ü", "Ý" ], + 'tl' => [ "Ñ", "Ng" ], + 'tr' => [ "Ç", "Ğ", "İ", "Ö", "Ş", "Ü" ], + 'tt' => [ "Ә", "Ө", "Ү", "Җ", "Ң", "Һ" ], + 'uz' => [ "Ch", "G'", "Ng", "O'", "Sh" ], + ]; const RECORD_LENGTH = 14; @@ -349,7 +349,7 @@ class IcuCollation extends Collation { // Do a binary search to find the correct letter to sort under $min = ArrayUtils::findLowerBound( - array( $this, 'getSortKeyByLetterIndex' ), + [ $this, 'getSortKeyByLetterIndex' ], $this->getFirstLetterCount(), 'strcmp', $sortKey ); @@ -393,7 +393,7 @@ class IcuCollation extends Collation { $letters = array_diff( $letters, self::$tailoringFirstLetters['-' . $this->locale] ); } // Apply digit transforms - $digits = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ); + $digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ]; $letters = array_diff( $letters, $digits ); foreach ( $digits as $digit ) { $letters[] = $this->digitTransformLanguage->formatNum( $digit, true ); @@ -415,7 +415,7 @@ class IcuCollation extends Collation { * * We also take this opportunity to remove primary collisions. */ - $letterMap = array(); + $letterMap = []; foreach ( $letters as $letter ) { $key = $this->getPrimarySortKey( $letter ); if ( isset( $letterMap[$key] ) ) { @@ -465,7 +465,7 @@ class IcuCollation extends Collation { */ $prev = false; - $duplicatePrefixes = array(); + $duplicatePrefixes = []; foreach ( $letterMap as $key => $value ) { // Remove terminator byte. Otherwise the prefix // comparison will get hung up on that. @@ -497,11 +497,11 @@ class IcuCollation extends Collation { unset( $letterMap[$badKey] ); // This code assumes that unsetting does not change sort order. } - $data = array( + $data = [ 'chars' => array_values( $letterMap ), 'keys' => array_keys( $letterMap ), 'version' => self::FIRST_LETTER_VERSION, - ); + ]; // Reduce memory usage before caching unset( $letterMap ); @@ -573,7 +573,7 @@ class IcuCollation extends Collation { $versionPrefix = substr( $icuVersion, 0, 3 ); // Source: http://site.icu-project.org/download - $map = array( + $map = [ '50.' => '6.2', '49.' => '6.1', '4.8' => '6.0', @@ -584,7 +584,7 @@ class IcuCollation extends Collation { '3.8' => '5.0', '3.6' => '5.0', '3.4' => '4.1', - ); + ]; if ( isset( $map[$versionPrefix] ) ) { return $map[$versionPrefix]; @@ -623,7 +623,7 @@ class CollationEt extends IcuCollation { private static function mangle( $string ) { return str_replace( - array( 'w', 'W' ), + [ 'w', 'W' ], 'ᴡ', // U+1D21 'LATIN LETTER SMALL CAPITAL W' $string ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e3c77131d8..08538eebf2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -67,9 +67,9 @@ $wgConf = new SiteConfiguration; * callable. * @since 1.23 */ -$wgConfigRegistry = array( +$wgConfigRegistry = [ 'main' => 'GlobalVarConfig::newInstance' -); +]; /** * MediaWiki version number @@ -363,7 +363,7 @@ $wgUploadStashScalerBaseUrl = false; * URLs. * @since 1.5 */ -$wgActionPaths = array(); +$wgActionPaths = []; /**@}*/ @@ -427,7 +427,7 @@ $wgImgAuthDetails = false; * * @see $wgFileBackends */ -$wgImgAuthUrlPathMap = array(); +$wgImgAuthUrlPathMap = []; /** * File repository structures @@ -516,7 +516,7 @@ $wgLocalFileRepo = false; /** * @see $wgLocalFileRepo */ -$wgForeignFileRepos = array(); +$wgForeignFileRepos = []; /** * Use Commons as a remote file repository. Essentially a wrapper, when this @@ -533,7 +533,7 @@ $wgUseInstantCommons = false; * Example: * $wgForeignUploadTargets = array( 'shared' ); */ -$wgForeignUploadTargets = array(); +$wgForeignUploadTargets = []; /** * File backend structure configuration. @@ -566,7 +566,7 @@ $wgForeignUploadTargets = array(); * a foreign wiki's directory in order to render a page on given wiki. The extension * would need a fully qualified backend that is defined on all wikis in the wiki farm. */ -$wgFileBackends = array(); +$wgFileBackends = []; /** * Array of configuration arrays for each lock manager. @@ -578,7 +578,7 @@ $wgFileBackends = array(); * Additional parameters are specific to the lock manager class used. * These settings should be global to all wikis. */ -$wgLockManagers = array(); +$wgLockManagers = []; /** * Show Exif data, on by default if available. @@ -660,7 +660,7 @@ $wgAllowCopyUploads = false; * * @since 1.20 */ -$wgCopyUploadsDomains = array(); +$wgCopyUploadsDomains = []; /** * Enable copy uploads from Special:Upload. $wgAllowCopyUploads must also be @@ -788,14 +788,14 @@ $wgRepositoryBaseUrl = "https://commons.wikimedia.org/wiki/File:"; * such as odt or doc, and untrusted users are allowed to upload files, then * your wiki will be vulnerable to cross-site request forgery (CSRF). */ -$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'webp' ); +$wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'webp' ]; /** * Files with these extensions will never be allowed as uploads. * An array of file extensions to blacklist. You should append to this array * if you want to blacklist additional files. */ -$wgFileBlacklist = array( +$wgFileBlacklist = [ # HTML may contain cookie-stealing JavaScript and web bugs 'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht', # PHP scripts may execute arbitrary code on the server @@ -803,13 +803,13 @@ $wgFileBlacklist = array( # Other types that may be interpreted by some servers 'shtml', 'jhtml', 'pl', 'py', 'cgi', # May contain harmful executables for Windows victims - 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' ); + 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' ]; /** * Files with these MIME types will never be allowed as uploads * if $wgVerifyMimeType is enabled. */ -$wgMimeTypeBlacklist = array( +$wgMimeTypeBlacklist = [ # HTML may contain cookie-stealing JavaScript and web bugs 'text/html', 'text/javascript', 'text/x-javascript', 'application/x-shellscript', # PHP scripts may execute arbitrary code on the server @@ -820,7 +820,7 @@ $wgMimeTypeBlacklist = array( 'text/scriptlet', 'application/x-msdownload', # Windows metafile, client-side vulnerability on some systems 'application/x-msmetafile', -); +]; /** * Allow Java archive uploads. @@ -867,20 +867,20 @@ $wgUploadSizeWarning = false; * to use this for further restrictions, like disabling direct * [[media:...]] links for non-trusted formats. */ -$wgTrustedMediaFormats = array( +$wgTrustedMediaFormats = [ MEDIATYPE_BITMAP, // all bitmap formats MEDIATYPE_AUDIO, // all audio formats MEDIATYPE_VIDEO, // all plain video formats "image/svg+xml", // svg (only needed if inline rendering of svg is not supported) "application/pdf", // PDF files # "application/x-shockwave-flash", //flash/shockwave movie -); +]; /** * Plugins for media file type handling. * Each entry in the array maps a MIME type to a class name */ -$wgMediaHandlers = array( +$wgMediaHandlers = [ 'image/jpeg' => 'JpegHandler', 'image/png' => 'PNGHandler', 'image/gif' => 'GIFHandler', @@ -894,7 +894,7 @@ $wgMediaHandlers = array( 'image/vnd.djvu' => 'DjVuHandler', // official 'image/x.djvu' => 'DjVuHandler', // compat 'image/x-djvu' => 'DjVuHandler', // compat -); +]; /** * Plugins for page content model handling. @@ -903,7 +903,7 @@ $wgMediaHandlers = array( * * @since 1.21 */ -$wgContentHandlers = array( +$wgContentHandlers = [ // the usual case CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler', // dumb version, no syntax highlighting @@ -914,7 +914,7 @@ $wgContentHandlers = array( CONTENT_MODEL_CSS => 'CssContentHandler', // plain text, for use by extensions, etc. CONTENT_MODEL_TEXT => 'TextContentHandler', -); +]; /** * Whether to enable server-side image thumbnailing. If false, images will @@ -942,7 +942,7 @@ $wgImageMagickConvertCommand = '/usr/bin/convert'; * Array of max pixel areas for interlacing per MIME type * @since 1.27 */ -$wgMaxInterlacingAreas = array(); +$wgMaxInterlacingAreas = []; /** * Sharpening parameter to ImageMagick @@ -1003,7 +1003,7 @@ $wgExiftool = '/usr/bin/exiftool'; * If set to an array, the first item is a PHP callable and any further items * are passed as parameters after $srcPath, $dstPath, $width, $height */ -$wgSVGConverters = array( +$wgSVGConverters = [ 'ImageMagick' => '$path/convert -background "#ffffff00" -thumbnail $widthx$height\! $input PNG:$output', 'sodipodi' => '$path/sodipodi -z -w $width -f $input -e $output', @@ -1012,8 +1012,8 @@ $wgSVGConverters = array( . '$output $input', 'rsvg' => '$path/rsvg-convert -w $width -h $height -o $output $input', 'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output', - 'ImagickExt' => array( 'SvgHandler::rasterizeImagickExt' ), -); + 'ImagickExt' => [ 'SvgHandler::rasterizeImagickExt' ], +]; /** * Pick a converter defined in $wgSVGConverters @@ -1178,20 +1178,20 @@ $wgAntivirus = null; * output. The relevant part should be matched as group one (\1). * If not defined or the pattern does not match, the full message is shown to the user. */ -$wgAntivirusSetup = array( +$wgAntivirusSetup = [ # setup for clamav - 'clamav' => array( + 'clamav' => [ 'command' => 'clamscan --no-summary ', - 'codemap' => array( + 'codemap' => [ "0" => AV_NO_VIRUS, # no virus "1" => AV_VIRUS_FOUND, # virus found "52" => AV_SCAN_ABORTED, # unsupported file format (probably immune) "*" => AV_SCAN_FAILED, # else scan failed - ), + ], 'messagepattern' => '/.*?:(.*)/sim', - ), -); + ], +]; /** * Determines if a failed virus scan (AV_SCAN_FAILED) will cause the file to be rejected. @@ -1240,13 +1240,13 @@ $wgTrivialMimeDetection = false; * Additional XML types we can allow via MIME-detection. * array = ( 'rootElement' => 'associatedMimeType' ) */ -$wgXMLMimeTypes = array( +$wgXMLMimeTypes = [ 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml', 'svg' => 'image/svg+xml', 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram', 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml? 'html' => 'text/html', // application/xhtml+xml? -); +]; /** * Limit images on image description pages to a user-selectable limit. In order @@ -1256,27 +1256,27 @@ $wgXMLMimeTypes = array( * change it if you alter the array (see bug 8858). * This is the list of settings the user can choose from: */ -$wgImageLimits = array( - array( 320, 240 ), - array( 640, 480 ), - array( 800, 600 ), - array( 1024, 768 ), - array( 1280, 1024 ) -); +$wgImageLimits = [ + [ 320, 240 ], + [ 640, 480 ], + [ 800, 600 ], + [ 1024, 768 ], + [ 1280, 1024 ] +]; /** * Adjust thumbnails on image pages according to a user setting. In order to * reduce disk usage, the values can only be selected from a list. This is the * list of settings the user can choose from: */ -$wgThumbLimits = array( +$wgThumbLimits = [ 120, 150, 180, 200, 250, 300 -); +]; /** * When defined, is an array of image widths used as buckets for thumbnail generation. @@ -1316,7 +1316,7 @@ $wgThumbnailMinimumBucketDistance = 50; * @since 1.25 */ -$wgUploadThumbnailRenderMap = array(); +$wgUploadThumbnailRenderMap = []; /** * The method through which the thumbnails will be prerendered for the entries in @@ -1357,14 +1357,14 @@ $wgUseTinyRGBForJPGThumbnails = false; /** * Default parameters for the "" tag */ -$wgGalleryOptions = array( +$wgGalleryOptions = [ 'imagesPerRow' => 0, // Default number of images per-row in the gallery. 0 -> Adapt to screensize 'imageWidth' => 120, // Width of the cells containing images in galleries (in "px") 'imageHeight' => 120, // Height of the cells containing images in galleries (in "px") 'captionLength' => 25, // Length of caption to truncate (in characters) 'showBytes' => true, // Show the filesize in bytes in categories 'mode' => 'traditional', -); +]; /** * Adjust width of upright images when parameter 'upright' is used @@ -1631,7 +1631,7 @@ $wgEnotifUseRealName = false; * Array of usernames who will be sent a notification email for every change * which occurs on a wiki. Users will not be notified of their own changes. */ -$wgUsersNotifiedOnAllChanges = array(); +$wgUsersNotifiedOnAllChanges = []; /** @} */ # end of email settings @@ -1787,7 +1787,7 @@ $wgSharedPrefix = false; /** * @see $wgSharedDB */ -$wgSharedTables = array( 'user', 'user_properties' ); +$wgSharedTables = [ 'user', 'user_properties' ]; /** * @see $wgSharedDB @@ -1857,7 +1857,7 @@ $wgDBservers = false; * The LBFactoryMulti class is provided for this purpose, please see * includes/db/LBFactoryMulti.php for configuration information. */ -$wgLBFactoryConf = array( 'class' => 'LBFactorySimple' ); +$wgLBFactoryConf = [ 'class' => 'LBFactorySimple' ]; /** * After a state-changing request is done by a client, this determines @@ -1944,7 +1944,7 @@ $wgDBOracleDRCP = false; * account. * Array numeric key => database name */ -$wgLocalDatabases = array(); +$wgLocalDatabases = []; /** * If lag is higher than $wgSlaveLagWarning, show a warning in some special @@ -1989,7 +1989,7 @@ $wgCompressRevisions = false; * * CAUTION: Access to database might lead to code execution */ -$wgExternalStores = array(); +$wgExternalStores = []; /** * An array of external MySQL servers. @@ -2005,7 +2005,7 @@ $wgExternalStores = array(); * Used by LBFactorySimple, may be ignored if $wgLBFactoryConf is set to * another class. */ -$wgExternalServers = array(); +$wgExternalServers = []; /** * The place to put new revisions, false to put them in the local text table. @@ -2169,34 +2169,34 @@ $wgLanguageConverterCacheType = CACHE_ANYTHING; * class name which will be used. Alternatively, a "factory" parameter may be * given, giving a callable function which will generate a suitable cache object. */ -$wgObjectCaches = array( - CACHE_NONE => array( 'class' => 'EmptyBagOStuff' ), - CACHE_DB => array( 'class' => 'SqlBagOStuff', 'loggroup' => 'SQLBagOStuff' ), +$wgObjectCaches = [ + CACHE_NONE => [ 'class' => 'EmptyBagOStuff' ], + CACHE_DB => [ 'class' => 'SqlBagOStuff', 'loggroup' => 'SQLBagOStuff' ], - CACHE_ANYTHING => array( 'factory' => 'ObjectCache::newAnything' ), - CACHE_ACCEL => array( 'factory' => 'ObjectCache::getLocalServerInstance' ), - CACHE_MEMCACHED => array( 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ), + CACHE_ANYTHING => [ 'factory' => 'ObjectCache::newAnything' ], + CACHE_ACCEL => [ 'factory' => 'ObjectCache::getLocalServerInstance' ], + CACHE_MEMCACHED => [ 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ], - 'db-replicated' => array( + 'db-replicated' => [ 'class' => 'ReplicatedBagOStuff', - 'readFactory' => array( + 'readFactory' => [ 'class' => 'SqlBagOStuff', - 'args' => array( array( 'slaveOnly' => true ) ) - ), - 'writeFactory' => array( + 'args' => [ [ 'slaveOnly' => true ] ] + ], + 'writeFactory' => [ 'class' => 'SqlBagOStuff', - 'args' => array( array( 'slaveOnly' => false ) ) - ), + 'args' => [ [ 'slaveOnly' => false ] ] + ], 'loggroup' => 'SQLBagOStuff' - ), + ], - 'apc' => array( 'class' => 'APCBagOStuff' ), - 'xcache' => array( 'class' => 'XCacheBagOStuff' ), - 'wincache' => array( 'class' => 'WinCacheBagOStuff' ), - 'memcached-php' => array( 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ), - 'memcached-pecl' => array( 'class' => 'MemcachedPeclBagOStuff', 'loggroup' => 'memcached' ), - 'hash' => array( 'class' => 'HashBagOStuff' ), -); + 'apc' => [ 'class' => 'APCBagOStuff' ], + 'xcache' => [ 'class' => 'XCacheBagOStuff' ], + 'wincache' => [ 'class' => 'WinCacheBagOStuff' ], + 'memcached-php' => [ 'class' => 'MemcachedPhpBagOStuff', 'loggroup' => 'memcached' ], + 'memcached-pecl' => [ 'class' => 'MemcachedPeclBagOStuff', 'loggroup' => 'memcached' ], + 'hash' => [ 'class' => 'HashBagOStuff' ], +]; /** * Main Wide-Area-Network cache type. This should be a cache with fast access, @@ -2231,13 +2231,13 @@ $wgMainWANCache = false; * * @since 1.26 */ -$wgWANObjectCaches = array( - CACHE_NONE => array( +$wgWANObjectCaches = [ + CACHE_NONE => [ 'class' => 'WANObjectCache', 'cacheId' => CACHE_NONE, 'pool' => 'mediawiki-main-none', - 'relayerConfig' => array( 'class' => 'EventRelayerNull' ) - ) + 'relayerConfig' => [ 'class' => 'EventRelayerNull' ] + ] /* Example of a simple single data-center cache: 'memcached-php' => array( 'class' => 'WANObjectCache', @@ -2246,7 +2246,7 @@ $wgWANObjectCaches = array( 'relayerConfig' => array( 'class' => 'EventRelayerNull' ) ) */ -); +]; /** * Main object stash type. This should be a fast storage system for storing @@ -2332,7 +2332,7 @@ $wgMemCachedDebug = false; /** * The list of MemCached servers and port numbers */ -$wgMemCachedServers = array( '127.0.0.1:11211' ); +$wgMemCachedServers = [ '127.0.0.1:11211' ]; /** * Use persistent connections to MemCached, which are shared across multiple @@ -2388,13 +2388,13 @@ $wgAdaptiveMessageCache = false; * manualRecache: Set this to true to disable cache updates on web requests. * Use maintenance/rebuildLocalisationCache.php instead. */ -$wgLocalisationCacheConf = array( +$wgLocalisationCacheConf = [ 'class' => 'LocalisationCache', 'store' => 'detect', 'storeClass' => false, 'storeDirectory' => false, 'manualRecache' => false, -); +]; /** * Allow client-side caching of pages @@ -2619,7 +2619,7 @@ $wgForcedRawSMaxage = 300; * * For a list of trusted servers which *aren't* purged, see $wgSquidServersNoPurge. */ -$wgSquidServers = array(); +$wgSquidServers = []; /** * As above, except these servers aren't purged on page changes; use to set a @@ -2627,7 +2627,7 @@ $wgSquidServers = array(); * CIDR blocks. * @since 1.23 Supports CIDR ranges */ -$wgSquidServersNoPurge = array(); +$wgSquidServersNoPurge = []; /** * Whether to use a Host header in purge requests sent to the proxy servers @@ -2701,7 +2701,7 @@ $wgSquidPurgeUseHostHeader = true; * * @see $wgHTCPMulticastTTL */ -$wgHTCPRouting = array(); +$wgHTCPRouting = []; /** * HTCP multicast TTL. @@ -2753,7 +2753,7 @@ $wgLangObjCacheSize = 10; * $wgGrammarForms['en']['genitive']['car'] = 'car\'s'; * @endcode */ -$wgGrammarForms = array(); +$wgGrammarForms = []; /** * Treat language links as magic connectors, not inline links @@ -2778,12 +2778,12 @@ $wgHideInterlanguageLinks = false; * placed in the system message "interlanguage-link-sitename-xyz" where xyz is * the prefix in this array. */ -$wgExtraInterlanguageLinkPrefixes = array(); +$wgExtraInterlanguageLinkPrefixes = []; /** * List of language names or overrides for default names in Names.php */ -$wgExtraLanguageNames = array(); +$wgExtraLanguageNames = []; /** * List of language codes that don't correspond to an actual language. @@ -2791,7 +2791,7 @@ $wgExtraLanguageNames = array(); * This array makes them not appear as a selectable language on the installer, * and excludes them when running the transstat.php script. */ -$wgDummyLanguageCodes = array( +$wgDummyLanguageCodes = [ 'als' => 'gsw', 'bat-smg' => 'sgs', 'be-x-old' => 'be-tarask', @@ -2805,7 +2805,7 @@ $wgDummyLanguageCodes = array( 'zh-classical' => 'lzh', 'zh-min-nan' => 'nan', 'zh-yue' => 'yue', -); +]; /** * Character set for use in the article edit box. Language-specific encodings @@ -2866,7 +2866,7 @@ $wgLegacyEncoding = false; * regexps : "/regexp/" matching problematic browsers. These browsers will * be served encoded unicode in the edit box instead of real unicode. */ -$wgBrowserBlackList = array( +$wgBrowserBlackList = [ /** * Netscape 2-4 detection * The minor version may contain strings such as "Gold" or "SGoldC-SGI" @@ -2901,7 +2901,7 @@ $wgBrowserBlackList = array( * https://it.wikipedia.org/w/index.php?title=Luciano_Ligabue&diff=prev&oldid=8857361 */ '/^Mozilla\/4\.0 \(compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;\)/' -); +]; /** * If set to true, the MediaWiki 1.4 to 1.5 schema conversion will @@ -2969,7 +2969,7 @@ $wgDefaultLanguageVariant = false; * $wgDisabledVariants[] = 'zh-my'; * @endcode */ -$wgDisabledVariants = array(); +$wgDisabledVariants = []; /** * Like $wgArticlePath, but on multi-variant wikis, this provides a @@ -3016,7 +3016,7 @@ $wgLoginLanguageSelector = false; * $wgForceUIMsgAsContentMsg = array( 'mainpage', 'portal-url' ); * @endcode */ -$wgForceUIMsgAsContentMsg = array(); +$wgForceUIMsgAsContentMsg = []; /** * Fake out the timezone that the server thinks it's in. This will be used for @@ -3162,7 +3162,7 @@ $wgWellFormedXml = true; * * This is ignored if $wgMimeType is set to a non-XML MIME type. */ -$wgXhtmlNamespaces = array(); +$wgXhtmlNamespaces = []; /** * Site notice shown at the top of each page @@ -3202,7 +3202,7 @@ $wgFallbackSkin = 'fallback'; * available skins in user preferences. If you want to remove a skin entirely, * remove it from the skins/ directory and its entry from LocalSettings.php. */ -$wgSkipSkins = array(); +$wgSkipSkins = []; /** * @deprecated since 1.23; use $wgSkipSkins instead @@ -3325,21 +3325,21 @@ $wgExperimentalHtmlIds = false; * Otherwise they will default to the standard 88x31. * @todo Reformat documentation. */ -$wgFooterIcons = array( - "copyright" => array( - "copyright" => array(), // placeholder for the built in copyright icon - ), - "poweredby" => array( - "mediawiki" => array( +$wgFooterIcons = [ + "copyright" => [ + "copyright" => [], // placeholder for the built in copyright icon + ], + "poweredby" => [ + "mediawiki" => [ // Defaults to point at // "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png" // plus srcset for 1.5x, 2x resolution variants. "src" => null, "url" => "//www.mediawiki.org/", "alt" => "Powered by MediaWiki", - ) - ), -); + ] + ], +]; /** * Login / create account link behavior when it's possible for anonymous users @@ -3420,7 +3420,7 @@ $wgMangleFlashPolicy = true; * ); * @endcode */ -$wgResourceModules = array(); +$wgResourceModules = []; /** * Skin-specific styles for resource modules. @@ -3510,7 +3510,7 @@ $wgResourceModules = array(); * ); * @endcode */ -$wgResourceModuleSkinStyles = array(); +$wgResourceModuleSkinStyles = []; /** * Extensions should register foreign module sources here. 'local' is a @@ -3522,7 +3522,7 @@ $wgResourceModuleSkinStyles = array(); * $wgResourceLoaderSources['foo'] = 'http://example.org/w/load.php'; * @endcode */ -$wgResourceLoaderSources = array(); +$wgResourceLoaderSources = []; /** * The default 'remoteBasePath' value for instances of ResourceLoaderFileModule. @@ -3546,16 +3546,16 @@ $wgResourceBasePath = null; * client and MediaWiki. * - client: On the client side (e.g. in the browser cache). */ -$wgResourceLoaderMaxage = array( - 'versioned' => array( +$wgResourceLoaderMaxage = [ + 'versioned' => [ 'server' => 30 * 24 * 60 * 60, // 30 days 'client' => 30 * 24 * 60 * 60, // 30 days - ), - 'unversioned' => array( + ], + 'unversioned' => [ 'server' => 5 * 60, // 5 minutes 'client' => 5 * 60, // 5 minutes - ), -); + ], +]; /** * The default debug mode (on/off) for of ResourceLoader requests. @@ -3690,7 +3690,7 @@ $wgResourceLoaderValidateStaticJS = false; * @endcode * @since 1.22 */ -$wgResourceLoaderLESSVars = array( +$wgResourceLoaderLESSVars = [ /** * Minimum available screen width at which a device can be considered a tablet/desktop * The number is currently based on the device width of a Samsung Galaxy S5 mini and is low @@ -3698,7 +3698,7 @@ $wgResourceLoaderLESSVars = array( * @since 1.27 */ 'deviceWidthTablet' => '720px', -); +]; /** * Default import paths for LESS modules. LESS files referenced in @import @@ -3713,9 +3713,9 @@ $wgResourceLoaderLESSVars = array( * * @since 1.22 */ -$wgResourceLoaderLESSImportPaths = array( +$wgResourceLoaderLESSImportPaths = [ "$IP/resources/src/mediawiki.less/", -); +]; /** * Whether ResourceLoader should attempt to persist modules in localStorage on @@ -3794,7 +3794,7 @@ $wgMetaNamespaceTalk = false; * * @todo Add a note about maintenance/namespaceDupes.php */ -$wgExtraNamespaces = array(); +$wgExtraNamespaces = []; /** * Same as above, but for namespaces with gender distinction. @@ -3802,7 +3802,7 @@ $wgExtraNamespaces = array(); * using $wgExtraNamespaces for the same index. * @since 1.18 */ -$wgExtraGenderNamespaces = array(); +$wgExtraGenderNamespaces = []; /** * Namespace aliases. @@ -3822,7 +3822,7 @@ $wgExtraGenderNamespaces = array(); * ); * @endcode */ -$wgNamespaceAliases = array(); +$wgNamespaceAliases = []; /** * Allowed title characters -- regex character class @@ -3868,7 +3868,7 @@ $wgLocalInterwiki = false; * Note, recent changes feeds use only the first entry in this array (or * $wgLocalInterwiki, if it is set). See $wgRCFeeds */ -$wgLocalInterwikis = array(); +$wgLocalInterwikis = []; /** * Expiry time for cache of interwiki table @@ -3967,13 +3967,13 @@ $wgCapitalLinks = true; * $wgCapitalLinkOverrides[ NS_FILE ] = false; * @endcode */ -$wgCapitalLinkOverrides = array(); +$wgCapitalLinkOverrides = []; /** * Which namespaces should support subpages? * See Language.php for a list of namespaces. */ -$wgNamespacesWithSubpages = array( +$wgNamespacesWithSubpages = [ NS_TALK => true, NS_USER => true, NS_USER_TALK => true, @@ -3986,7 +3986,7 @@ $wgNamespacesWithSubpages = array( NS_HELP => true, NS_HELP_TALK => true, NS_CATEGORY_TALK => true -); +]; /** * Array holding default tracking category names. @@ -4003,7 +4003,7 @@ $wgNamespacesWithSubpages = array( * * @since 1.23 */ -$wgTrackingCategories = array(); +$wgTrackingCategories = []; /** * Array of namespaces which can be deemed to contain valid "content", as far @@ -4011,7 +4011,7 @@ $wgTrackingCategories = array(); * contain "content" which should be considered when generating a count of the * number of articles in the wiki. */ -$wgContentNamespaces = array( NS_MAIN ); +$wgContentNamespaces = [ NS_MAIN ]; /** * Array of namespaces, in addition to the talk namespaces, where signatures @@ -4020,7 +4020,7 @@ $wgContentNamespaces = array( NS_MAIN ); * For example, "traditional" style wikis, where content and discussion are * intermixed, could place NS_MAIN and NS_PROJECT namespaces in this array. */ -$wgExtraSignatureNamespaces = array(); +$wgExtraSignatureNamespaces = []; /** * Max number of redirects to follow when resolving redirects. @@ -4039,7 +4039,7 @@ $wgMaxRedirects = 1; * As of now, this only checks special pages. Redirects to pages in * other namespaces cannot be invalidated by this variable. */ -$wgInvalidRedirectTargets = array( 'Filepath', 'Mypage', 'Mytalk', 'Redirect' ); +$wgInvalidRedirectTargets = [ 'Filepath', 'Mypage', 'Mytalk', 'Redirect' ]; /** @} */ # End of title and interwiki settings } @@ -4070,10 +4070,10 @@ $wgInvalidRedirectTargets = array( 'Filepath', 'Mypage', 'Mytalk', 'Redirect' ); * changed during LocalSettings.php, in particular, it can't be changed during * an extension setup function. */ -$wgParserConf = array( +$wgParserConf = [ 'class' => 'Parser', # 'preprocessorClass' => 'Preprocessor_Hash', -); +]; /** * Maximum indent level of toc. @@ -4120,12 +4120,12 @@ $wgMaxPPExpandDepth = 40; * * @see wfParseUrl */ -$wgUrlProtocols = array( +$wgUrlProtocols = [ 'bitcoin:', 'ftp://', 'ftps://', 'geo:', 'git://', 'gopher://', 'http://', 'https://', 'irc://', 'ircs://', 'magnet:', 'mailto:', 'mms://', 'news:', 'nntp://', 'redis://', 'sftp://', 'sip:', 'sips:', 'sms:', 'ssh://', 'svn://', 'tel:', 'telnet://', 'urn:', 'worldwind://', 'xmpp:', '//' -); +]; /** * If true, removes (by substituting) templates in signatures. @@ -4255,7 +4255,7 @@ $wgNoFollowLinks = true; * Namespaces in which $wgNoFollowLinks doesn't apply. * See Language.php for a list of namespaces. */ -$wgNoFollowNsExceptions = array(); +$wgNoFollowNsExceptions = []; /** * If this is set to an array of domains, external links to these domain names @@ -4271,7 +4271,7 @@ $wgNoFollowNsExceptions = array(); * * Defaults to mediawiki.org for the links included in the software by default. */ -$wgNoFollowDomainExceptions = array( 'mediawiki.org' ); +$wgNoFollowDomainExceptions = [ 'mediawiki.org' ]; /** * Allow DISPLAYTITLE to change title display @@ -4355,9 +4355,9 @@ $wgActiveUserDays = 30; * Key is the provider ID, value is a specification for ObjectFactory * @since 1.27 */ -$wgCentralIdLookupProviders = array( - 'local' => array( 'class' => 'LocalIdLookup' ), -); +$wgCentralIdLookupProviders = [ + 'local' => [ 'class' => 'LocalIdLookup' ], +]; /** * Central ID lookup provider to use by default @@ -4388,41 +4388,41 @@ $wgCentralIdLookupProvider = 'local'; * PHP_INT_MAX constant. * @since 1.26 */ -$wgPasswordPolicy = array( - 'policies' => array( - 'bureaucrat' => array( +$wgPasswordPolicy = [ + 'policies' => [ + 'bureaucrat' => [ 'MinimalPasswordLength' => 8, 'MinimumPasswordLengthToLogin' => 1, 'PasswordCannotMatchUsername' => true, 'PasswordCannotBePopular' => 25, - ), - 'sysop' => array( + ], + 'sysop' => [ 'MinimalPasswordLength' => 8, 'MinimumPasswordLengthToLogin' => 1, 'PasswordCannotMatchUsername' => true, 'PasswordCannotBePopular' => 25, - ), - 'bot' => array( + ], + 'bot' => [ 'MinimalPasswordLength' => 8, 'MinimumPasswordLengthToLogin' => 1, 'PasswordCannotMatchUsername' => true, - ), - 'default' => array( + ], + 'default' => [ 'MinimalPasswordLength' => 1, 'PasswordCannotMatchUsername' => true, 'PasswordCannotMatchBlacklist' => true, 'MaximalPasswordLength' => 4096, - ), - ), - 'checks' => array( + ], + ], + 'checks' => [ 'MinimalPasswordLength' => 'PasswordPolicyChecks::checkMinimalPasswordLength', 'MinimumPasswordLengthToLogin' => 'PasswordPolicyChecks::checkMinimumPasswordLengthToLogin', 'PasswordCannotMatchUsername' => 'PasswordPolicyChecks::checkPasswordCannotMatchUsername', 'PasswordCannotMatchBlacklist' => 'PasswordPolicyChecks::checkPasswordCannotMatchBlacklist', 'MaximalPasswordLength' => 'PasswordPolicyChecks::checkMaximalPasswordLength', 'PasswordCannotBePopular' => 'PasswordPolicyChecks::checkPopularPasswordBlacklist' - ), -); + ], +]; /** * For compatibility with old installations set to false @@ -4483,38 +4483,38 @@ $wgPasswordDefault = 'pbkdf2'; * * @since 1.24 */ -$wgPasswordConfig = array( - 'A' => array( +$wgPasswordConfig = [ + 'A' => [ 'class' => 'MWOldPassword', - ), - 'B' => array( + ], + 'B' => [ 'class' => 'MWSaltedPassword', - ), - 'pbkdf2-legacyA' => array( + ], + 'pbkdf2-legacyA' => [ 'class' => 'LayeredParameterizedPassword', - 'types' => array( + 'types' => [ 'A', 'pbkdf2', - ), - ), - 'pbkdf2-legacyB' => array( + ], + ], + 'pbkdf2-legacyB' => [ 'class' => 'LayeredParameterizedPassword', - 'types' => array( + 'types' => [ 'B', 'pbkdf2', - ), - ), - 'bcrypt' => array( + ], + ], + 'bcrypt' => [ 'class' => 'BcryptPassword', 'cost' => 9, - ), - 'pbkdf2' => array( + ], + 'pbkdf2' => [ 'class' => 'Pbkdf2Password', 'algo' => 'sha256', 'cost' => '10000', 'length' => '128', - ), -); + ], +]; /** * Whether to allow password resets ("enter some identifying data, and we'll send an email @@ -4522,10 +4522,10 @@ $wgPasswordConfig = array( * various bits of data. Setting all of these to false (or the whole variable to false) * has the effect of disabling password resets entirely */ -$wgPasswordResetRoutes = array( +$wgPasswordResetRoutes = [ 'username' => true, 'email' => true, -); +]; /** * Maximum number of Unicode characters in signature @@ -4542,7 +4542,7 @@ $wgMaxNameChars = 255; * Array of usernames which may not be registered or logged in from * Maintenance scripts can still use these */ -$wgReservedUsernames = array( +$wgReservedUsernames = [ 'MediaWiki default', // Default 'Main Page' and MediaWiki: message pages 'Conversion script', // Used for the old Wikipedia software upgrade 'Maintenance script', // Maintenance scripts which perform editing, image import script @@ -4553,7 +4553,7 @@ $wgReservedUsernames = array( 'msg:proxyblocker', // For $wgProxyList and Special:Blockme (removed in 1.22) 'msg:spambot_username', // Used by cleanupSpam.php 'msg:autochange-username', // Used by anon category RC entries (parser functions, Lua & purges) -); +]; /** * Settings added to this array will override the default globals for the user @@ -4561,7 +4561,7 @@ $wgReservedUsernames = array( * For instance, to disable editing on double clicks: * $wgDefaultUserOptions ['editondblclick'] = 0; */ -$wgDefaultUserOptions = array( +$wgDefaultUserOptions = [ 'ccmeonemails' => 0, 'cols' => 80, 'date' => 'default', @@ -4619,12 +4619,12 @@ $wgDefaultUserOptions = array( 'wllimit' => 250, 'useeditwarning' => 1, 'prefershttps' => 1, -); +]; /** * An array of preferences to not show for the user */ -$wgHiddenPrefs = array(); +$wgHiddenPrefs = []; /** * Characters to prevent during new account creations. @@ -4672,21 +4672,21 @@ $wgAuthenticationTokenVersion = null; * * @since 1.27 */ -$wgSessionProviders = array( - 'MediaWiki\\Session\\CookieSessionProvider' => array( +$wgSessionProviders = [ + 'MediaWiki\\Session\\CookieSessionProvider' => [ 'class' => 'MediaWiki\\Session\\CookieSessionProvider', - 'args' => array( array( + 'args' => [ [ 'priority' => 30, 'callUserSetCookiesHook' => true, - ) ), - ), - 'MediaWiki\\Session\\BotPasswordSessionProvider' => array( + ] ], + ], + 'MediaWiki\\Session\\BotPasswordSessionProvider' => [ 'class' => 'MediaWiki\\Session\\BotPasswordSessionProvider', - 'args' => array( array( + 'args' => [ [ 'priority' => 40, - ) ), - ), -); + ] ], + ], +]; /** @} */ # end user accounts } @@ -4724,10 +4724,10 @@ $wgSysopEmailBans = true; * allocated a /19 if a generous HD-Ratio of 0.8 is used, so we will use that * as our limit. As of 2012, blocking the whole world would require a /4 range. */ -$wgBlockCIDRLimit = array( +$wgBlockCIDRLimit = [ 'IPv4' => 16, # Blocks larger than a /16 (64k addresses) will not be allowed 'IPv6' => 19, -); +]; /** * If true, blocked users will not be allowed to login. When using this with @@ -4821,7 +4821,7 @@ $wgHideIdentifiableRedirects = true; * * This replaces $wgWhitelistAccount and $wgWhitelistEdit */ -$wgGroupPermissions = array(); +$wgGroupPermissions = []; /** @cond file_level_code */ // Implicit group for all visitors @@ -4958,12 +4958,12 @@ $wgGroupPermissions['bureaucrat']['noratelimit'] = true; * Improperly setting this could mean that your users will be unable to perform * certain essential tasks, so use at your own risk! */ -$wgRevokePermissions = array(); +$wgRevokePermissions = []; /** * Implicit groups, aren't shown on Special:Listusers or somewhere else */ -$wgImplicitGroups = array( '*', 'user', 'autoconfirmed' ); +$wgImplicitGroups = [ '*', 'user', 'autoconfirmed' ]; /** * A map of group names that the user is in, to group names that those users @@ -4986,12 +4986,12 @@ $wgImplicitGroups = array( '*', 'user', 'autoconfirmed' ); * This allows users in the '*' group (i.e. any user) to remove themselves from * any group that they happen to be in. */ -$wgGroupsAddToSelf = array(); +$wgGroupsAddToSelf = []; /** * @see $wgGroupsAddToSelf */ -$wgGroupsRemoveFromSelf = array(); +$wgGroupsRemoveFromSelf = []; /** * Set of available actions that can be restricted via action=protect @@ -5000,7 +5000,7 @@ $wgGroupsRemoveFromSelf = array(); * Title::getRestrictionTypes() will remove restrictions that are not * applicable to a specific title (create and upload) */ -$wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ); +$wgRestrictionTypes = [ 'create', 'edit', 'move', 'upload' ]; /** * Rights which can be required for each protection level (via action=protect) @@ -5013,7 +5013,7 @@ $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ); * - 'autoconfirmed' is quietly rewritten to 'editsemiprotected' for backwards compatibility * - 'sysop' is quietly rewritten to 'editprotected' for backwards compatibility */ -$wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' ); +$wgRestrictionLevels = [ '', 'autoconfirmed', 'sysop' ]; /** * Restriction levels that can be used with cascading protection @@ -5024,7 +5024,7 @@ $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' ); * 'autoconfirmed' is quietly rewritten to 'editsemiprotected' for backwards compatibility. * 'sysop' is quietly rewritten to 'editprotected' for backwards compatibility. */ -$wgCascadingRestrictionLevels = array( 'sysop' ); +$wgCascadingRestrictionLevels = [ 'sysop' ]; /** * Restriction levels that should be considered "semiprotected" @@ -5038,7 +5038,7 @@ $wgCascadingRestrictionLevels = array( 'sysop' ); * 'autoconfirmed' is quietly rewritten to 'editsemiprotected' for backwards compatibility. * 'sysop' is not changed, since it really shouldn't be here. */ -$wgSemiprotectedRestrictionLevels = array( 'autoconfirmed' ); +$wgSemiprotectedRestrictionLevels = [ 'autoconfirmed' ]; /** * Set the minimum permissions required to edit pages in each @@ -5047,7 +5047,7 @@ $wgSemiprotectedRestrictionLevels = array( 'autoconfirmed' ); * * @note NS_MEDIAWIKI is implicitly restricted to 'editinterface'. */ -$wgNamespaceProtection = array(); +$wgNamespaceProtection = []; /** * Pages in namespaces in this array can not be used as templates. @@ -5058,7 +5058,7 @@ $wgNamespaceProtection = array(); * Among other things, this may be useful to enforce read-restrictions * which may otherwise be bypassed by using the template mechanism. */ -$wgNonincludableNamespaces = array(); +$wgNonincludableNamespaces = []; /** * Number of seconds an account is required to age before it's given the @@ -5116,12 +5116,12 @@ $wgAutoConfirmCount = 0; * If $wgEmailAuthentication is off, APCOND_EMAILCONFIRMED will be true for any * user who has provided an e-mail address. */ -$wgAutopromote = array( - 'autoconfirmed' => array( '&', - array( APCOND_EDITCOUNT, &$wgAutoConfirmCount ), - array( APCOND_AGE, &$wgAutoConfirmAge ), - ), -); +$wgAutopromote = [ + 'autoconfirmed' => [ '&', + [ APCOND_EDITCOUNT, &$wgAutoConfirmCount ], + [ APCOND_AGE, &$wgAutoConfirmAge ], + ], +]; /** * Automatically add a usergroup to any user who matches certain conditions. @@ -5141,9 +5141,9 @@ $wgAutopromote = array( * @see $wgAutopromote * @since 1.18 */ -$wgAutopromoteOnce = array( - 'onEdit' => array(), -); +$wgAutopromoteOnce = [ + 'onEdit' => [], +]; /** * Put user rights log entries for autopromotion in recent changes? @@ -5173,18 +5173,18 @@ $wgAutopromoteOnceLogInRC = true; * $wgRemoveGroups['sysop'] = array( 'sysop', 'bot' ); * @endcode */ -$wgAddGroups = array(); +$wgAddGroups = []; /** * @see $wgAddGroups */ -$wgRemoveGroups = array(); +$wgRemoveGroups = []; /** * A list of available rights, in addition to the ones defined by the core. * For extensions only. */ -$wgAvailableRights = array(); +$wgAvailableRights = []; /** * Optional to restrict deletion of pages with higher revision counts @@ -5219,12 +5219,12 @@ $wgAccountCreationThrottle = 0; * * @note Each regex needs a beginning/end delimiter, eg: # or / */ -$wgSpamRegex = array(); +$wgSpamRegex = []; /** * Same as the above except for edit summaries */ -$wgSummarySpamRegex = array(); +$wgSummarySpamRegex = []; /** * Whether to use DNS blacklists in $wgDnsBlacklistUrls to check for open @@ -5256,13 +5256,13 @@ $wgEnableDnsBlacklist = false; * eventual domain search suffixes. * @since 1.16 */ -$wgDnsBlacklistUrls = array( 'http.dnsbl.sorbs.net.' ); +$wgDnsBlacklistUrls = [ 'http.dnsbl.sorbs.net.' ]; /** * Proxy whitelist, list of addresses that are assumed to be non-proxy despite * what the other methods might say. */ -$wgProxyWhitelist = array(); +$wgProxyWhitelist = []; /** * Whether to look at the X-Forwarded-For header's list of (potentially spoofed) @@ -5300,74 +5300,74 @@ $wgApplyIpBlocksToXff = false; * * @warning Requires that $wgMainCacheType is set to something persistent */ -$wgRateLimits = array( +$wgRateLimits = [ // Page edits - 'edit' => array( - 'ip' => array( 8, 60 ), - 'newbie' => array( 8, 60 ), - ), + 'edit' => [ + 'ip' => [ 8, 60 ], + 'newbie' => [ 8, 60 ], + ], // Page moves - 'move' => array( - 'newbie' => array( 2, 120 ), - 'user' => array( 8, 60 ), - ), + 'move' => [ + 'newbie' => [ 2, 120 ], + 'user' => [ 8, 60 ], + ], // File uploads - 'upload' => array( - 'ip' => array( 8, 60 ), - 'newbie' => array( 8, 60 ), - ), + 'upload' => [ + 'ip' => [ 8, 60 ], + 'newbie' => [ 8, 60 ], + ], // Page rollbacks - 'rollback' => array( - 'user' => array( 10, 60 ), - 'newbie' => array( 5, 120 ) - ), + 'rollback' => [ + 'user' => [ 10, 60 ], + 'newbie' => [ 5, 120 ] + ], // Triggering password resets emails - 'mailpassword' => array( - 'ip' => array( 5, 3600 ), - ), + 'mailpassword' => [ + 'ip' => [ 5, 3600 ], + ], // Emailing other users using MediaWiki - 'emailuser' => array( - 'ip' => array( 5, 86400 ), - 'newbie' => array( 5, 86400 ), - 'user' => array( 20, 86400 ), - ), + 'emailuser' => [ + 'ip' => [ 5, 86400 ], + 'newbie' => [ 5, 86400 ], + 'user' => [ 20, 86400 ], + ], // Purging pages - 'purge' => array( - 'ip' => array( 30, 60 ), - 'user' => array( 30, 60 ), - ), + 'purge' => [ + 'ip' => [ 30, 60 ], + 'user' => [ 30, 60 ], + ], // Purges of link tables - 'linkpurge' => array( - 'ip' => array( 30, 60 ), - 'user' => array( 30, 60 ), - ), + 'linkpurge' => [ + 'ip' => [ 30, 60 ], + 'user' => [ 30, 60 ], + ], // Files rendered via thumb.php or thumb_handler.php - 'renderfile' => array( - 'ip' => array( 700, 30 ), - 'user' => array( 700, 30 ), - ), + 'renderfile' => [ + 'ip' => [ 700, 30 ], + 'user' => [ 700, 30 ], + ], // Same as above but for non-standard thumbnails - 'renderfile-nonstandard' => array( - 'ip' => array( 70, 30 ), - 'user' => array( 70, 30 ), - ), + 'renderfile-nonstandard' => [ + 'ip' => [ 70, 30 ], + 'user' => [ 70, 30 ], + ], // Stashing edits into cache before save - 'stashedit' => array( - 'ip' => array( 30, 60 ), - 'newbie' => array( 30, 60 ), - ), + 'stashedit' => [ + 'ip' => [ 30, 60 ], + 'newbie' => [ 30, 60 ], + ], // Adding or removing change tags - 'changetag' => array( - 'ip' => array( 8, 60 ), - 'newbie' => array( 8, 60 ), - ), -); + 'changetag' => [ + 'ip' => [ 8, 60 ], + 'newbie' => [ 8, 60 ], + ], +]; /** * Array of IPs which should be excluded from rate limits. * This may be useful for whitelisting NAT gateways for conferences, etc. */ -$wgRateLimitsExcludedIPs = array(); +$wgRateLimitsExcludedIPs = []; /** * Log IP addresses in the recentchanges table; can be accessed only by @@ -5387,7 +5387,7 @@ $wgQueryPageDefaultLimit = 50; * * @warning Requires memcached. */ -$wgPasswordAttemptThrottle = array( 'count' => 5, 'seconds' => 300 ); +$wgPasswordAttemptThrottle = [ 'count' => 5, 'seconds' => 300 ]; /** * @var Array Map of (grant => right => boolean) @@ -5399,7 +5399,7 @@ $wgPasswordAttemptThrottle = array( 'count' => 5, 'seconds' => 300 ); * nothing if that user does not actually have that right to begin with. * @since 1.27 */ -$wgGrantPermissions = array(); +$wgGrantPermissions = []; // @TODO: clean up grants // @TODO: auto-include read/editsemiprotected rights? @@ -5493,7 +5493,7 @@ $wgGrantPermissions['createaccount']['createaccount'] = true; * @var Array Map of grants to their UI grouping * @since 1.27 */ -$wgGrantPermissionGroups = array( +$wgGrantPermissionGroups = [ // Hidden grants are implicitly present 'basic' => 'hidden', @@ -5522,7 +5522,7 @@ $wgGrantPermissionGroups = array( 'createaccount' => 'administration', 'highvolume' => 'high-volume', -); +]; /** * @var bool Whether to enable bot passwords @@ -5568,7 +5568,7 @@ $wgSecretKey = false; * - A string, in that case this is the path to a file * containing the list of IP addresses, one per line */ -$wgProxyList = array(); +$wgProxyList = []; /** @} */ # end of proxy scanner settings @@ -5588,7 +5588,7 @@ $wgCookieExpiration = 180 * 86400; * * @var string[] */ -$wgExtendedLoginCookies = array( 'UserID', 'Token' ); +$wgExtendedLoginCookies = [ 'UserID', 'Token' ]; /** * Default login cookie lifetime, in seconds. Setting @@ -5643,7 +5643,7 @@ $wgCookieHttpOnly = true; /** * A list of cookies that vary the cache (for use by extensions) */ -$wgCacheVaryCookies = array(); +$wgCacheVaryCookies = []; /** * Override to customise the session name @@ -5726,38 +5726,38 @@ $wgDebugDumpSql = false; * * @since 1.26 */ -$wgTrxProfilerLimits = array( +$wgTrxProfilerLimits = [ // HTTP GET/HEAD requests. // Master queries should not happen on GET requests - 'GET' => array( + 'GET' => [ 'masterConns' => 0, 'writes' => 0, 'readQueryTime' => 5 - ), + ], // HTTP POST requests. // Master reads and writes will happen for a subset of these. - 'POST' => array( + 'POST' => [ 'readQueryTime' => 5, 'writeQueryTime' => 1, 'maxAffected' => 500 - ), - 'POST-nonwrite' => array( + ], + 'POST-nonwrite' => [ 'masterConns' => 0, 'writes' => 0, 'readQueryTime' => 5 - ), + ], // Background job runner - 'JobRunner' => array( + 'JobRunner' => [ 'readQueryTime' => 30, 'writeQueryTime' => 5, 'maxAffected' => 1000 - ), + ], // Command-line scripts - 'Maintenance' => array( + 'Maintenance' => [ 'writeQueryTime' => 5, 'maxAffected' => 1000 - ) -); + ] +]; /** * Map of string log group names to log destinations. @@ -5789,7 +5789,7 @@ $wgTrxProfilerLimits = array( * ); * @endcode */ -$wgDebugLogGroups = array(); +$wgDebugLogGroups = []; /** * Default service provider for creating Psr\Log\LoggerInterface instances. @@ -5812,9 +5812,9 @@ $wgDebugLogGroups = array(); * @var array $wgMWLoggerDefaultSpi * @see MwLogger */ -$wgMWLoggerDefaultSpi = array( +$wgMWLoggerDefaultSpi = [ 'class' => '\\MediaWiki\\Logger\\LegacySpi', -); +]; /** * Display debug data at the bottom of the main content area. @@ -5953,10 +5953,10 @@ $wgSiteStatsAsyncFactor = false; * * Use full paths. */ -$wgParserTestFiles = array( +$wgParserTestFiles = [ "$IP/tests/parser/parserTests.txt", "$IP/tests/parser/extraParserTests.txt" -); +]; /** * Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit). @@ -6022,10 +6022,10 @@ $wgOpenSearchTemplate = false; * * Placeholders: {searchTerms} */ -$wgOpenSearchTemplates = array( +$wgOpenSearchTemplates = [ 'application/x-suggestions+json' => false, 'application/x-suggestions+xml' => false, -); +]; /** * Enable OpenSearch suggestions requested by MediaWiki. Set this to @@ -6066,9 +6066,9 @@ $wgDisableSearchUpdate = false; * $wgNamespacesToBeSearchedDefault[NS_PROJECT] = true; * @endcode */ -$wgNamespacesToBeSearchedDefault = array( +$wgNamespacesToBeSearchedDefault = [ NS_MAIN => true, -); +]; /** * Disable the internal MySQL-based search, to allow it to be @@ -6153,9 +6153,9 @@ $wgDiff = '/usr/bin/diff'; * Internally only Category: pages apply, but using this extensions (e.g. Semantic MediaWiki) * can specify namespaces of pages they have special treatment for */ -$wgPreviewOnOpenNamespaces = array( +$wgPreviewOnOpenNamespaces = [ NS_CATEGORY => true -); +]; /** * Enable the UniversalEditButton for browsers that support it @@ -6240,12 +6240,12 @@ $wgGitBin = '/usr/bin/git'; * * @since 1.20 */ -$wgGitRepositoryViewers = array( +$wgGitRepositoryViewers = [ 'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' => 'https://git.wikimedia.org/tree/%r/%H', 'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://git.wikimedia.org/tree/%r/%H', -); +]; /** @} */ # End of maintenance } @@ -6289,13 +6289,13 @@ $wgRCFilterByAge = false; * List of Limits options to list in the Special:Recentchanges and * Special:Recentchangeslinked pages. */ -$wgRCLinkLimits = array( 50, 100, 250, 500 ); +$wgRCLinkLimits = [ 50, 100, 250, 500 ]; /** * List of Days options to list in the Special:Recentchanges and * Special:Recentchangeslinked pages. */ -$wgRCLinkDays = array( 1, 3, 7, 14, 30 ); +$wgRCLinkDays = [ 1, 3, 7, 14, 30 ]; /** * Destinations to which notifications about recent changes @@ -6338,16 +6338,16 @@ $wgRCLinkDays = array( 1, 3, 7, 14, 30 ); * ); * @since 1.22 */ -$wgRCFeeds = array(); +$wgRCFeeds = []; /** * Used by RecentChange::getEngine to find the correct engine to use for a given URI scheme. * Keys are scheme names, values are names of engine classes. */ -$wgRCEngines = array( +$wgRCEngines = [ 'redis' => 'RedisPubSubFeedEngine', 'udp' => 'UDPRCFeedEngine', -); +]; /** * Treat category membership changes as a RecentChange. @@ -6424,23 +6424,23 @@ $wgFeedDiffCutoff = 32768; * $wgSiteFeed['atom'] = "http://example.com/somefeed.xml"; * @endcode */ -$wgOverrideSiteFeed = array(); +$wgOverrideSiteFeed = []; /** * Available feeds objects. * Should probably only be defined when a page is syndicated ie when * $wgOut->isSyndicated() is true. */ -$wgFeedClasses = array( +$wgFeedClasses = [ 'rss' => 'RSSFeed', 'atom' => 'AtomFeed', -); +]; /** * Which feed types should we provide by default? This can include 'rss', * 'atom', neither, or both. */ -$wgAdvertisedFeedTypes = array( 'atom' ); +$wgAdvertisedFeedTypes = [ 'atom' ]; /** * Show watching users in recent changes, watchlist and page history views @@ -6511,30 +6511,30 @@ $wgUnwatchedPageThreshold = false; * * @since 1.22 */ -$wgRecentChangesFlags = array( - 'newpage' => array( +$wgRecentChangesFlags = [ + 'newpage' => [ 'letter' => 'newpageletter', 'title' => 'recentchanges-label-newpage', 'legend' => 'recentchanges-legend-newpage', - ), - 'minor' => array( + ], + 'minor' => [ 'letter' => 'minoreditletter', 'title' => 'recentchanges-label-minor', 'legend' => 'recentchanges-legend-minor', 'class' => 'minoredit', - ), - 'bot' => array( + ], + 'bot' => [ 'letter' => 'boteditletter', 'title' => 'recentchanges-label-bot', 'legend' => 'recentchanges-legend-bot', 'class' => 'botedit', - ), - 'unpatrolled' => array( + ], + 'unpatrolled' => [ 'letter' => 'unpatrolledletter', 'title' => 'recentchanges-label-unpatrolled', 'legend' => 'recentchanges-legend-unpatrolled', - ), -); + ], +]; /** @} */ # end RC/watchlist } @@ -6627,7 +6627,7 @@ $wgShowCreditsIfMax = true; * If a user has the 'import' permission but not the 'importupload' permission, * they will only be able to run imports through this transwiki interface. */ -$wgImportSources = array(); +$wgImportSources = []; /** * Optional default target namespace for interwiki imports. @@ -6699,7 +6699,7 @@ $wgExportPagelistLimit = 5000; * A list of callback functions which are called once MediaWiki is fully * initialised */ -$wgExtensionFunctions = array(); +$wgExtensionFunctions = []; /** * Extension messages files. @@ -6727,7 +6727,7 @@ $wgExtensionFunctions = array(); * $wgExtensionMessagesFiles['ConfirmEdit'] = __DIR__.'/ConfirmEdit.i18n.php'; * @endcode */ -$wgExtensionMessagesFiles = array(); +$wgExtensionMessagesFiles = []; /** * Extension messages directories. @@ -6754,14 +6754,14 @@ $wgExtensionMessagesFiles = array(); * @endcode * @since 1.23 */ -$wgMessagesDirs = array(); +$wgMessagesDirs = []; /** * Array of files with list(s) of extension entry points to be used in * maintenance/mergeMessageFileList.php * @since 1.22 */ -$wgExtensionEntryPointListFiles = array(); +$wgExtensionEntryPointListFiles = []; /** * Parser output hooks. @@ -6777,7 +6777,7 @@ $wgExtensionEntryPointListFiles = array(); * function outputHook( $outputPage, $parserOutput, $data ) { ... } * @endcode */ -$wgParserOutputHooks = array(); +$wgParserOutputHooks = []; /** * Whether to include the NewPP limit report as a HTML comment @@ -6792,7 +6792,7 @@ $wgEnableParserLimitReporting = true; * the class name of the skin to load. Use Skin::getSkinNames() as an accessor * if you wish to have access to the full list. */ -$wgValidSkinNames = array(); +$wgValidSkinNames = []; /** * Special page list. This is an associative array mapping the (canonical) names of @@ -6800,12 +6800,12 @@ $wgValidSkinNames = array(); * creating the special page object. In both cases, the result must be an instance of * SpecialPage. */ -$wgSpecialPages = array(); +$wgSpecialPages = []; /** * Array mapping class names to filenames, for autoloading. */ -$wgAutoloadClasses = array(); +$wgAutoloadClasses = []; /** * Switch controlling legacy case-insensitive classloading. @@ -6866,7 +6866,7 @@ $wgAutoloadAttemptLowercase = true; * - license-name: Short name of the license (used as label for the link), such * as "GPL-2.0+" or "MIT" (https://spdx.org/licenses/ for a list of identifiers). */ -$wgExtensionCredits = array(); +$wgExtensionCredits = []; /** * Authentication plugin. @@ -6908,13 +6908,13 @@ $wgAuth = null; * @warning Hook handlers should be registered at file scope. Registering * handlers after file scope can lead to unexpected results due to caching. */ -$wgHooks = array(); +$wgHooks = []; /** * Maps jobs to their handling classes; extensions * can add to this to provide custom jobs */ -$wgJobClasses = array( +$wgJobClasses = [ 'refreshLinks' => 'RefreshLinksJob', 'deleteLinks' => 'DeleteLinksJob', 'htmlCacheUpdate' => 'HTMLCacheUpdateJob', @@ -6932,7 +6932,7 @@ $wgJobClasses = array( 'cdnPurge' => 'CdnPurgeJob', 'enqueue' => 'EnqueueJob', // local queue for multi-DC setups 'null' => 'NullJob' -); +]; /** * Jobs that must be explicitly requested, i.e. aren't run by job runners unless @@ -6945,7 +6945,7 @@ $wgJobClasses = array( * machine on your cluster has 'outside' web access you could restrict uploadFromUrl ) * These settings should be global to all wikis. */ -$wgJobTypesExcludedFromDefaultQueue = array( 'AssembleUploadChunks', 'PublishStashedFile' ); +$wgJobTypesExcludedFromDefaultQueue = [ 'AssembleUploadChunks', 'PublishStashedFile' ]; /** * Map of job types to how many job "work items" should be run per second @@ -6956,7 +6956,7 @@ $wgJobTypesExcludedFromDefaultQueue = array( 'AssembleUploadChunks', 'PublishSta * These settings should be global to all wikis. * @var float[] */ -$wgJobBackoffThrottling = array(); +$wgJobBackoffThrottling = []; /** * Make job runners commit changes for slave-lag prone jobs one job at a time. @@ -6979,25 +6979,25 @@ $wgJobSerialCommitThreshold = false; * Job types that do not have explicit configuration will use the 'default' config. * These settings should be global to all wikis. */ -$wgJobTypeConf = array( - 'default' => array( 'class' => 'JobQueueDB', 'order' => 'random', 'claimTTL' => 3600 ), -); +$wgJobTypeConf = [ + 'default' => [ 'class' => 'JobQueueDB', 'order' => 'random', 'claimTTL' => 3600 ], +]; /** * Which aggregator to use for tracking which queues have jobs. * These settings should be global to all wikis. */ -$wgJobQueueAggregator = array( +$wgJobQueueAggregator = [ 'class' => 'JobQueueAggregatorNull' -); +]; /** * Additional functions to be performed with updateSpecialPages. * Expensive Querypages are already updated. */ -$wgSpecialPageCacheUpdates = array( - 'Statistics' => array( 'SiteStatsUpdate', 'cacheUpdate' ) -); +$wgSpecialPageCacheUpdates = [ + 'Statistics' => [ 'SiteStatsUpdate', 'cacheUpdate' ] +]; /** * Hooks that are used for outputting exceptions. Format is: @@ -7006,7 +7006,7 @@ $wgSpecialPageCacheUpdates = array( * $wgExceptionHooks[] = array( $class, $funcname ) * Hooks should return strings or false */ -$wgExceptionHooks = array(); +$wgExceptionHooks = []; /** * Page property link table invalidation lists. When a page property @@ -7015,9 +7015,9 @@ $wgExceptionHooks = array(); * have been added, so the categorylinks table needs to be rebuilt). * This array can be added to by extensions. */ -$wgPagePropLinkInvalidations = array( +$wgPagePropLinkInvalidations = [ 'hiddencat' => 'categorylinks', -); +]; /** @} */ # End extensions } @@ -7082,7 +7082,7 @@ $wgCategoryCollation = 'uppercase'; * an action, which is a specific kind of event that can exist in that * log type. */ -$wgLogTypes = array( +$wgLogTypes = [ '', 'block', 'protect', @@ -7097,7 +7097,7 @@ $wgLogTypes = array( 'tag', 'managetags', 'contentmodel', -); +]; /** * This restricts log access to those who have a certain right @@ -7106,9 +7106,9 @@ $wgLogTypes = array( * Logs should remain non-transcludable * Format: logtype => permissiontype */ -$wgLogRestrictions = array( +$wgLogRestrictions = [ 'suppress' => 'suppressionlog' -); +]; /** * Show/hide links on Special:Log will be shown for these log types. @@ -7132,10 +7132,10 @@ $wgLogRestrictions = array( * A message of the form log-show-hide-[type] should be added, and will be used * for the link text. */ -$wgFilterLogTypes = array( +$wgFilterLogTypes = [ 'patrol' => true, 'tag' => true, -); +]; /** * Lists the message key string for each log type. The localized messages @@ -7146,7 +7146,7 @@ $wgFilterLogTypes = array( * @since 1.19, if you follow the naming convention log-name-TYPE, * where TYPE is your log type, yoy don't need to use this array. */ -$wgLogNames = array( +$wgLogNames = [ '' => 'all-logs-page', 'block' => 'blocklogpage', 'protect' => 'protectlogpage', @@ -7158,7 +7158,7 @@ $wgLogNames = array( 'patrol' => 'patrol-log-page', 'merge' => 'mergelog', 'suppress' => 'suppressionlog', -); +]; /** * Lists the message key string for descriptive text to be shown at the @@ -7169,7 +7169,7 @@ $wgLogNames = array( * @since 1.19, if you follow the naming convention log-description-TYPE, * where TYPE is your log type, yoy don't need to use this array. */ -$wgLogHeaders = array( +$wgLogHeaders = [ '' => 'alllogstext', 'block' => 'blocklogtext', 'delete' => 'dellogpagetext', @@ -7181,7 +7181,7 @@ $wgLogHeaders = array( 'rights' => 'rightslogtext', 'suppress' => 'suppressionlogtext', 'upload' => 'uploadlogpagetext', -); +]; /** * Lists the message key string for formatting individual events of each @@ -7189,7 +7189,7 @@ $wgLogHeaders = array( * * Extensions with custom log types may add to this array. */ -$wgLogActions = array(); +$wgLogActions = []; /** * The same as above, but here values are names of classes, @@ -7197,7 +7197,7 @@ $wgLogActions = array(); * @see LogPage::actionText * @see LogFormatter */ -$wgLogActionsHandlers = array( +$wgLogActionsHandlers = [ 'block/block' => 'BlockLogFormatter', 'block/reblock' => 'BlockLogFormatter', 'block/unblock' => 'BlockLogFormatter', @@ -7231,7 +7231,7 @@ $wgLogActionsHandlers = array( 'upload/overwrite' => 'UploadLogFormatter', 'upload/revert' => 'UploadLogFormatter', 'upload/upload' => 'UploadLogFormatter', -); +]; /** * Maintain a log of newusers at Log/newusers? @@ -7285,7 +7285,7 @@ $wgMaxRedirectLinksRetrieved = 500; * 'foo' => false The action is disabled; show an error message * Unsetting core actions will probably cause things to complain loudly. */ -$wgActions = array( +$wgActions = [ 'credits' => true, 'delete' => true, 'edit' => true, @@ -7305,7 +7305,7 @@ $wgActions = array( 'unwatch' => true, 'view' => true, 'watch' => true, -); +]; /** @} */ # end actions } @@ -7336,7 +7336,7 @@ $wgDefaultRobotPolicy = 'index,follow'; * $wgNamespaceRobotPolicies = array( NS_TALK => 'noindex' ); * @endcode */ -$wgNamespaceRobotPolicies = array(); +$wgNamespaceRobotPolicies = []; /** * Robot policies per article. These override the per-namespace robot policies. @@ -7364,7 +7364,7 @@ $wgNamespaceRobotPolicies = array(); * ); * @endcode */ -$wgArticleRobotPolicies = array(); +$wgArticleRobotPolicies = []; /** * An array of namespace keys in which the __INDEX__/__NOINDEX__ magic words @@ -7455,7 +7455,7 @@ $wgDebugAPI = false; * Extension modules may override the core modules. * See ApiMain::$Modules for a list of the core modules. */ -$wgAPIModules = array(); +$wgAPIModules = []; /** * API format module extensions. @@ -7464,7 +7464,7 @@ $wgAPIModules = array(); * * See ApiMain::$Formats for a list of the core format modules. */ -$wgAPIFormatModules = array(); +$wgAPIFormatModules = []; /** * API Query meta module extensions. @@ -7473,7 +7473,7 @@ $wgAPIFormatModules = array(); * * See ApiQuery::$QueryMetaModules for a list of the core meta modules. */ -$wgAPIMetaModules = array(); +$wgAPIMetaModules = []; /** * API Query prop module extensions. @@ -7482,7 +7482,7 @@ $wgAPIMetaModules = array(); * * See ApiQuery::$QueryPropModules for a list of the core prop modules. */ -$wgAPIPropModules = array(); +$wgAPIPropModules = []; /** * API Query list module extensions. @@ -7491,7 +7491,7 @@ $wgAPIPropModules = array(); * * See ApiQuery::$QueryListModules for a list of the core list modules. */ -$wgAPIListModules = array(); +$wgAPIListModules = []; /** * Maximum amount of rows to scan in a DB query in the API @@ -7533,11 +7533,11 @@ $wgAPICacheHelpTimeout = 60 * 60; * The ApiQueryQueryPages module should skip pages that are redundant to true * API queries. */ -$wgAPIUselessQueryPages = array( +$wgAPIUselessQueryPages = [ 'MIMEsearch', // aiprop=mime 'LinkSearch', // list=exturlusage 'FileDuplicateSearch', // prop=duplicatefiles -); +]; /** * Enable AJAX framework @@ -7549,7 +7549,7 @@ $wgUseAjax = true; * Extensions acting as Ajax callbacks must register here * @deprecated (officially) since 1.27; use the API instead */ -$wgAjaxExportList = array(); +$wgAjaxExportList = []; /** * Enable AJAX check for file overwrite, pre-upload @@ -7587,14 +7587,14 @@ $wgAjaxEditStash = true; * ); * @endcode */ -$wgCrossSiteAJAXdomains = array(); +$wgCrossSiteAJAXdomains = []; /** * Domains that should not be allowed to make AJAX requests, * even if they match one of the domains allowed by $wgCrossSiteAJAXdomains * Uses the same syntax as $wgCrossSiteAJAXdomains */ -$wgCrossSiteAJAXdomainExceptions = array(); +$wgCrossSiteAJAXdomainExceptions = []; /** @} */ # End AJAX and API } @@ -7694,7 +7694,7 @@ $wgHTTPProxy = false; * proxy if it is configured. * @since 1.25 */ -$wgLocalVirtualHosts = array(); +$wgLocalVirtualHosts = []; /** * Timeout for connections done internally (in seconds) @@ -7821,7 +7821,7 @@ $wgUploadMaintenance = false; * * @since 1.21 */ -$wgNamespaceContentModels = array(); +$wgNamespaceContentModels = []; /** * How to react if a plain text version of a non-text Content object is requested using @@ -7860,11 +7860,11 @@ $wgContentHandlerUseDB = true; * * @since 1.21 */ -$wgTextModelsToParse = array( +$wgTextModelsToParse = [ CONTENT_MODEL_WIKITEXT, // Just for completeness, wikitext will always be parsed. CONTENT_MODEL_JAVASCRIPT, // Make categories etc work, people put them into comments. CONTENT_MODEL_CSS, // Make categories etc work, people put them into comments. -); +]; /** * Whether the user must enter their password to change their e-mail address @@ -7878,9 +7878,9 @@ $wgRequirePasswordforEmailChange = true; * * @since 1.20 */ -$wgSiteTypes = array( +$wgSiteTypes = [ 'mediawiki' => 'MediaWikiSite', -); +]; /** * Whether the page_props table has a pp_sortkey column. Set to false in case @@ -7942,16 +7942,16 @@ $wgPageLanguageUseDB = false; * @var array * @since 1.25 */ -$wgVirtualRestConfig = array( - 'modules' => array(), - 'global' => array( +$wgVirtualRestConfig = [ + 'modules' => [], + 'global' => [ # Timeout in seconds 'timeout' => 360, # 'domain' is set to $wgCanonicalServer in Setup.php 'forwardCookies' => false, 'HTTPProxy' => null - ) -); + ] +]; /** * Controls whether zero-result search queries with suggestions should display results for @@ -7997,11 +7997,11 @@ $wgMaxUserDBWriteDuration = false; * * @since 1.27 */ -$wgEventRelayerConfig = array( - 'default' => array( +$wgEventRelayerConfig = [ + 'default' => [ 'class' => 'EventRelayerNull', - ) -); + ] +]; /** * For really cool vim folding this needs to be at the end: diff --git a/includes/EditPage.php b/includes/EditPage.php index caeb57cd2a..5ebb44a763 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -490,7 +490,7 @@ class EditPage { function edit() { global $wgOut, $wgRequest, $wgUser; // Allow extensions to modify/prevent this form or submission - if ( !Hooks::run( 'AlternateEdit', array( $this ) ) ) { + if ( !Hooks::run( 'AlternateEdit', [ $this ] ) ) { return; } @@ -589,9 +589,9 @@ class EditPage { } if ( !$this->mTitle->getArticleID() ) { - Hooks::run( 'EditFormPreloadText', array( &$this->textbox1, &$this->mTitle ) ); + Hooks::run( 'EditFormPreloadText', [ &$this->textbox1, &$this->mTitle ] ); } else { - Hooks::run( 'EditFormInitialText', array( $this ) ); + Hooks::run( 'EditFormInitialText', [ $this ] ); } } @@ -618,7 +618,7 @@ class EditPage { ); } # Ignore some permissions errors when a user is just previewing/viewing diffs - $remove = array(); + $remove = []; foreach ( $permErrors as $error ) { if ( ( $this->preview || $this->diff ) && ( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' ) @@ -678,7 +678,7 @@ class EditPage { protected function displayViewSourcePage( Content $content, $errorMessage = '' ) { global $wgOut; - Hooks::run( 'EditPage::showReadOnlyForm:initial', array( $this, &$wgOut ) ); + Hooks::run( 'EditPage::showReadOnlyForm:initial', [ $this, &$wgOut ] ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->setPageTitle( wfMessage( @@ -711,10 +711,10 @@ class EditPage { } $wgOut->addHTML( $this->editFormTextBeforeContent ); - $this->showTextbox( $text, 'wpTextbox1', array( 'readonly' ) ); + $this->showTextbox( $text, 'wpTextbox1', [ 'readonly' ] ); $wgOut->addHTML( $this->editFormTextAfterContent ); - $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ), + $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'templatesUsed' ], Linker::formatTemplates( $this->getTemplates() ) ) ); $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' ); @@ -768,7 +768,7 @@ class EditPage { $name = $this->mTitle->getSkinFromCssJsSubpage(); $skins = array_merge( array_keys( Skin::getSkinNames() ), - array( 'common' ) + [ 'common' ] ); return !in_array( $name, $skins ) && in_array( strtolower( $name ), $skins ); @@ -922,7 +922,7 @@ class EditPage { $changeTags = $request->getVal( 'wpChangeTags' ); if ( is_null( $changeTags ) || $changeTags === '' ) { - $this->changeTags = array(); + $this->changeTags = []; } else { $this->changeTags = array_filter( array_map( 'trim', explode( ',', $changeTags ) ) ); @@ -979,7 +979,7 @@ class EditPage { throw new ErrorPageError( 'editpage-notsupportedcontentformat-title', 'editpage-notsupportedcontentformat-text', - array( $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) ) + [ $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) ] ); } @@ -994,7 +994,7 @@ class EditPage { $this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' ); // Allow extensions to modify form data - Hooks::run( 'EditPage::importFormData', array( $this, $request ) ); + Hooks::run( 'EditPage::importFormData', [ $this, $request ] ); } @@ -1073,7 +1073,7 @@ class EditPage { $preload = $wgRequest->getVal( 'preload', // Custom preload text for new sections $this->section === 'new' ? 'MediaWiki:addsection-preload' : '' ); - $params = $wgRequest->getArray( 'preloadparams', array() ); + $params = $wgRequest->getArray( 'preloadparams', [] ); $content = $this->getPreloadedContent( $preload, $params ); } @@ -1272,7 +1272,7 @@ class EditPage { * * @since 1.21 */ - protected function getPreloadedContent( $preload, $params = array() ) { + protected function getPreloadedContent( $preload, $params = [] ) { global $wgUser; if ( !empty( $this->mPreloadContent ) ) { @@ -1372,9 +1372,9 @@ class EditPage { } $response = RequestContext::getMain()->getRequest()->response(); - $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, array( + $response->setCookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, [ 'httpOnly' => false, - ) ); + ] ); } /** @@ -1390,7 +1390,7 @@ class EditPage { $bot = $wgUser->isAllowed( 'bot' ) && $this->bot; $status = $this->internalAttemptSave( $resultDetails, $bot ); - Hooks::run( 'EditPage::attemptSave:after', array( $this, $status, $resultDetails ) ); + Hooks::run( 'EditPage::attemptSave:after', [ $this, $status, $resultDetails ] ); return $status; } @@ -1454,7 +1454,7 @@ class EditPage { // Give extensions a chance to modify URL query on update Hooks::run( 'ArticleUpdateBeforeRedirect', - array( $this->mArticle, &$sectionanchor, &$extraQuery ) + [ $this->mArticle, &$sectionanchor, &$extraQuery ] ); if ( $resultDetails['redirect'] ) { @@ -1518,7 +1518,7 @@ class EditPage { protected function runPostMergeFilters( Content $content, Status $status, User $user ) { // Run old style post-section-merge edit filter if ( !ContentHandler::runLegacyHooks( 'EditFilterMerged', - array( $this, $content, &$this->hookError, $this->summary ) ) + [ $this, $content, &$this->hookError, $this->summary ] ) ) { # Error messages etc. could be handled within the hook... $status->fatal( 'hookaborted' ); @@ -1533,8 +1533,8 @@ class EditPage { // Run new style post-section-merge edit filter if ( !Hooks::run( 'EditFilterMergedContent', - array( $this->mArticle->getContext(), $content, $status, $this->summary, - $user, $this->minoredit ) ) + [ $this->mArticle->getContext(), $content, $status, $this->summary, + $user, $this->minoredit ] ) ) { # Error messages etc. could be handled within the hook... if ( $status->isGood() ) { @@ -1623,7 +1623,7 @@ class EditPage { $status = Status::newGood(); - if ( !Hooks::run( 'EditPage::attemptSave', array( $this ) ) ) { + if ( !Hooks::run( 'EditPage::attemptSave', [ $this ] ) ) { wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" ); $status->fatal( 'hookaborted' ); $status->value = self::AS_HOOK_ERROR; @@ -1700,7 +1700,7 @@ class EditPage { } if ( !Hooks::run( 'EditFilter', - array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) ) + [ $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ] ) ) { # Error messages etc. could be handled within the hook... $status->fatal( 'hookaborted' ); @@ -2023,7 +2023,7 @@ class EditPage { // but don't show it for errors from extension hooks $errors = $doEditStatus->getErrorsArray(); if ( in_array( $errors[0][0], - array( 'edit-gone-missing', 'edit-conflict', 'edit-already-exists' ) ) + [ 'edit-gone-missing', 'edit-conflict', 'edit-already-exists' ] ) ) { $this->isConflict = true; // Destroys data doEdit() put in $status->value but who cares @@ -2065,10 +2065,10 @@ class EditPage { $log->setPerformer( $user ); $log->setTarget( $this->mTitle ); $log->setComment( $reason ); - $log->setParameters( array( + $log->setParameters( [ '4::oldmodel' => $oldModel, '5::newmodel' => $newModel - ) ); + ] ); $logid = $log->insert(); $log->publish( $logid ); } @@ -2188,7 +2188,7 @@ class EditPage { */ protected static function matchSpamRegexInternal( $text, $regexes ) { foreach ( $regexes as $regex ) { - $matches = array(); + $matches = []; if ( preg_match( $regex, $text, $matches ) ) { return $matches[0]; } @@ -2285,13 +2285,13 @@ class EditPage { # there must be a description url to show a hint to shared repo if ( $descUrl ) { if ( !$this->mTitle->exists() ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", array( + $wgOut->wrapWikiMsg( "
\n$1\n
", [ 'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl - ) ); + ] ); } else { - $wgOut->wrapWikiMsg( "
\n$1\n
", array( + $wgOut->wrapWikiMsg( "
\n$1\n
", [ 'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl - ) ); + ] ); } } } @@ -2307,7 +2307,7 @@ class EditPage { $block = Block::newFromTarget( $user, $user ); if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist $wgOut->wrapWikiMsg( "
\n$1\n
", - array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) ); + [ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] ); } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { # Show log extract if the user is currently blocked LogEventsList::showLogExtract( @@ -2315,14 +2315,14 @@ class EditPage { 'block', MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(), '', - array( + [ 'lim' => 1, 'showIfEmpty' => false, - 'msgKey' => array( + 'msgKey' => [ 'blocked-notice-logextract', $user->getName() # Support GENDER in notice - ) - ) + ] + ] ); } } @@ -2335,32 +2335,32 @@ class EditPage { $wgOut->wrapWikiMsg( // Suppress the external link icon, consider the help url an internal one "
\n$1\n
", - array( + [ 'newarticletext', $helpLink - ) + ] ); } else { $wgOut->wrapWikiMsg( // Suppress the external link icon, consider the help url an internal one "
\n$1\n
", - array( + [ 'newarticletextanon', $helpLink - ) + ] ); } } # Give a notice if the user is editing a deleted/moved page... if ( !$this->mTitle->exists() ) { - LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle, + LogEventsList::showLogExtract( $wgOut, [ 'delete', 'move' ], $this->mTitle, '', - array( + [ 'lim' => 10, - 'conds' => array( "log_action != 'revision'" ), + 'conds' => [ "log_action != 'revision'" ], 'showIfEmpty' => false, - 'msgKey' => array( 'recreate-moveddeleted-warn' ) - ) + 'msgKey' => [ 'recreate-moveddeleted-warn' ] + ] ); } } @@ -2469,7 +2469,7 @@ class EditPage { $previewOutput = $this->getPreviewText(); } - Hooks::run( 'EditPage::showEditForm:initial', array( &$this, &$wgOut ) ); + Hooks::run( 'EditPage::showEditForm:initial', [ &$this, &$wgOut ] ); $this->setHeaders(); @@ -2501,41 +2501,41 @@ class EditPage { // search for textarea1 and textares2, and allow EditForm to override all uses. $wgOut->addHTML( Html::openElement( 'form', - array( + [ 'id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID, 'method' => 'post', 'action' => $this->getActionURL( $this->getContextTitle() ), 'enctype' => 'multipart/form-data' - ) + ] ) ); if ( is_callable( $formCallback ) ) { wfWarn( 'The $formCallback parameter to ' . __METHOD__ . 'is deprecated' ); - call_user_func_array( $formCallback, array( &$wgOut ) ); + call_user_func_array( $formCallback, [ &$wgOut ] ); } // Add an empty field to trip up spambots $wgOut->addHTML( - Xml::openElement( 'div', array( 'id' => 'antispam-container', 'style' => 'display: none;' ) ) + Xml::openElement( 'div', [ 'id' => 'antispam-container', 'style' => 'display: none;' ] ) . Html::rawElement( 'label', - array( 'for' => 'wpAntiSpam' ), + [ 'for' => 'wpAntiSpam' ], wfMessage( 'simpleantispam-label' )->parse() ) . Xml::element( 'input', - array( + [ 'type' => 'text', 'name' => 'wpAntispam', 'id' => 'wpAntispam', 'value' => '' - ) + ] ) . Xml::closeElement( 'div' ) ); - Hooks::run( 'EditPage::showEditForm:fields', array( &$this, &$wgOut ) ); + Hooks::run( 'EditPage::showEditForm:fields', [ &$this, &$wgOut ] ); // Put these up at the top to ensure they aren't lost on early form submission $this->showFormBeforeText(); @@ -2553,7 +2553,7 @@ class EditPage { '
' . wfMessage( $key, $username, "$comment" )->parse() . Xml::checkLabel( wfMessage( 'recreate' )->text(), 'wpRecreate', 'wpRecreate', false, - array( 'title' => Linker::titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' ) + [ 'title' => Linker::titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' ] ) . '
' ); @@ -2641,13 +2641,13 @@ class EditPage { $wgOut->addHTML( $this->editFormTextAfterTools . "\n" ); - $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ), + $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'templatesUsed' ], Linker::formatTemplates( $this->getTemplates(), $this->preview, $this->section != '' ) ) ); - $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'hiddencats' ), + $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'hiddencats' ], Linker::formatHiddenCategories( $this->page->getHiddenCategories() ) ) ); - $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'limitreport' ), + $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'limitreport' ], self::getPreviewLimitReport( $this->mParserOutput ) ) ); $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' ); @@ -2794,7 +2794,7 @@ class EditPage { // Something went wrong $wgOut->wrapWikiMsg( "
\n$1\n
\n", - array( 'missing-revision', $this->oldid ) ); + [ 'missing-revision', $this->oldid ] ); } } } @@ -2802,17 +2802,17 @@ class EditPage { if ( wfReadOnly() ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( 'readonlywarning', wfReadOnlyReason() ) + [ 'readonlywarning', wfReadOnlyReason() ] ); } elseif ( $wgUser->isAnon() ) { if ( $this->formtype != 'preview' ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( 'anoneditwarning', + [ 'anoneditwarning', // Log-in link '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}', // Sign-up link - '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}' ) + '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}' ] ); } else { $wgOut->wrapWikiMsg( "
\n$1
", @@ -2825,7 +2825,7 @@ class EditPage { if ( $this->isWrongCaseCssJsPage ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ) + [ 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ] ); } if ( $this->getTitle()->isSubpageOf( $wgUser->getUserPage() ) ) { @@ -2833,14 +2833,14 @@ class EditPage { if ( $this->isCssSubpage && $wgAllowUserCss ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( 'usercssyoucanpreview' ) + [ 'usercssyoucanpreview' ] ); } if ( $this->isJsSubpage && $wgAllowUserJs ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( 'userjsyoucanpreview' ) + [ 'userjsyoucanpreview' ] ); } } @@ -2849,7 +2849,7 @@ class EditPage { } if ( $this->mTitle->isProtected( 'edit' ) && - MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== array( '' ) + MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ] ) { # Is the title semi-protected? if ( $this->mTitle->isSemiProtected() ) { @@ -2859,7 +2859,7 @@ class EditPage { $noticeMsg = 'protectedpagewarning'; } LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', - array( 'lim' => 1, 'msgKey' => array( $noticeMsg ) ) ); + [ 'lim' => 1, 'msgKey' => [ $noticeMsg ] ] ); } if ( $this->mTitle->isCascadeProtected() ) { # Is this page under cascading protection from some source pages? @@ -2874,14 +2874,14 @@ class EditPage { } } $notice .= ''; - $wgOut->wrapWikiMsg( $notice, array( 'cascadeprotectedwarning', $cascadeSourcesCount ) ); + $wgOut->wrapWikiMsg( $notice, [ 'cascadeprotectedwarning', $cascadeSourcesCount ] ); } if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) { LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', - array( 'lim' => 1, + [ 'lim' => 1, 'showIfEmpty' => false, - 'msgKey' => array( 'titleprotectedwarning' ), - 'wrap' => "
\n$1
" ) ); + 'msgKey' => [ 'titleprotectedwarning' ], + 'wrap' => "
\n$1
" ] ); } if ( $this->kblength === false ) { @@ -2890,20 +2890,20 @@ class EditPage { if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( + [ 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) - ) + ] ); } else { if ( !wfMessage( 'longpage-hint' )->isDisabled() ) { $wgOut->wrapWikiMsg( "
\n$1\n
", - array( + [ 'longpage-hint', $wgLang->formatSize( strlen( $this->textbox1 ) ), strlen( $this->textbox1 ) - ) + ] ); } } @@ -2931,24 +2931,24 @@ class EditPage { $inputAttrs = null, $spanLabelAttrs = null ) { // Note: the maxlength is overridden in JS to 255 and to make it use UTF-8 bytes, not characters. - $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : array() ) + array( + $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [ 'id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1', 'size' => 60, 'spellcheck' => 'true', - ) + Linker::tooltipAndAccesskeyAttribs( 'summary' ); + ] + Linker::tooltipAndAccesskeyAttribs( 'summary' ); - $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : array() ) + array( + $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [ 'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary', 'id' => "wpSummaryLabel" - ); + ]; $label = null; if ( $labelText ) { $label = Xml::tags( 'label', - $inputAttrs['id'] ? array( 'for' => $inputAttrs['id'] ) : null, + $inputAttrs['id'] ? [ 'for' => $inputAttrs['id'] ] : null, $labelText ); $label = Xml::tags( 'span', $spanLabelAttrs, $label ); @@ -2956,7 +2956,7 @@ class EditPage { $input = Html::input( 'wpSummary', $summary, 'text', $inputAttrs ); - return array( $label, $input ); + return [ $label, $input ]; } /** @@ -2983,8 +2983,8 @@ class EditPage { list( $label, $input ) = $this->getSummaryInput( $summary, $labelText, - array( 'class' => $summaryClass ), - array() + [ 'class' => $summaryClass ], + [] ); $wgOut->addHTML( "{$label} {$input}" ); } @@ -3014,7 +3014,7 @@ class EditPage { $summary = wfMessage( $message )->parse() . Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview ); - return Xml::tags( 'div', array( 'class' => 'mw-summary-preview' ), $summary ); + return Xml::tags( 'div', [ 'class' => 'mw-summary-preview' ], $summary ); } protected function showFormBeforeText() { @@ -3072,11 +3072,11 @@ HTML */ protected function showTextbox1( $customAttribs = null, $textoverride = null ) { if ( $this->wasDeletedSinceLastEdit() && $this->formtype == 'save' ) { - $attribs = array( 'style' => 'display:none;' ); + $attribs = [ 'style' => 'display:none;' ]; } else { - $classes = array(); // Textarea CSS + $classes = []; // Textarea CSS if ( $this->mTitle->isProtected( 'edit' ) && - MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== array( '' ) + MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ] ) { # Is the title semi-protected? if ( $this->mTitle->isSemiProtected() ) { @@ -3091,7 +3091,7 @@ HTML } } - $attribs = array( 'tabindex' => 1 ); + $attribs = [ 'tabindex' => 1 ]; if ( is_array( $customAttribs ) ) { $attribs += $customAttribs; @@ -3113,10 +3113,10 @@ HTML } protected function showTextbox2() { - $this->showTextbox( $this->textbox2, 'wpTextbox2', array( 'tabindex' => 6, 'readonly' ) ); + $this->showTextbox( $this->textbox2, 'wpTextbox2', [ 'tabindex' => 6, 'readonly' ] ); } - protected function showTextbox( $text, $name, $customAttribs = array() ) { + protected function showTextbox( $text, $name, $customAttribs = [] ) { global $wgOut, $wgUser; $wikitext = $this->safeUnicodeOutput( $text ); @@ -3128,7 +3128,7 @@ HTML $wikitext .= "\n"; } - $attribs = $customAttribs + array( + $attribs = $customAttribs + [ 'accesskey' => ',', 'id' => $name, 'cols' => $wgUser->getIntOption( 'cols' ), @@ -3136,7 +3136,7 @@ HTML // Avoid PHP notices when appending preferences // (appending allows customAttribs['style'] to still work). 'style' => '' - ); + ]; $pageLang = $this->mTitle->getPageLanguage(); $attribs['lang'] = $pageLang->getHtmlCode(); @@ -3147,12 +3147,12 @@ HTML protected function displayPreviewArea( $previewOutput, $isOnTop = false ) { global $wgOut; - $classes = array(); + $classes = []; if ( $isOnTop ) { $classes[] = 'ontop'; } - $attribs = array( 'id' => 'wikiPreview', 'class' => implode( ' ', $classes ) ); + $attribs = [ 'id' => 'wikiPreview', 'class' => implode( ' ', $classes ) ]; if ( $this->formtype != 'preview' ) { $attribs['style'] = 'display: none;'; @@ -3165,8 +3165,8 @@ HTML } else { // Empty content container for LivePreview $pageViewLang = $this->mTitle->getPageViewLanguage(); - $attribs = array( 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(), - 'class' => 'mw-content-' . $pageViewLang->getDir() ); + $attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(), + 'class' => 'mw-content-' . $pageViewLang->getDir() ]; $wgOut->addHTML( Html::rawElement( 'div', $attribs ) ); } @@ -3200,7 +3200,7 @@ HTML } # This hook seems slightly odd here, but makes things more # consistent for extensions. - Hooks::run( 'OutputPageBeforeHTML', array( &$wgOut, &$text ) ); + Hooks::run( 'OutputPageBeforeHTML', [ &$wgOut, &$text ] ); $wgOut->addHTML( $text ); if ( $this->mTitle->getNamespace() == NS_CATEGORY ) { $this->mArticle->closeShowCategory(); @@ -3238,8 +3238,8 @@ HTML $this->summary, $this->edittime ); if ( $newContent ) { - ContentHandler::runLegacyHooks( 'EditPageGetDiffText', array( $this, &$newContent ) ); - Hooks::run( 'EditPageGetDiffContent', array( $this, &$newContent ) ); + ContentHandler::runLegacyHooks( 'EditPageGetDiffText', [ $this, &$newContent ] ); + Hooks::run( 'EditPageGetDiffContent', [ $this, &$newContent ] ); $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts ); @@ -3291,7 +3291,7 @@ HTML */ protected function showTosSummary() { $msg = 'editpage-tos-summary'; - Hooks::run( 'EditPageTosSummary', array( $this->mTitle, &$msg ) ); + Hooks::run( 'EditPageTosSummary', [ $this->mTitle, &$msg ] ); if ( !wfMessage( $msg )->isDisabled() ) { global $wgOut; $wgOut->addHTML( '
' ); @@ -3327,15 +3327,15 @@ HTML public static function getCopyrightWarning( $title, $format = 'plain' ) { global $wgRightsText; if ( $wgRightsText ) { - $copywarnMsg = array( 'copyrightwarning', + $copywarnMsg = [ 'copyrightwarning', '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]', - $wgRightsText ); + $wgRightsText ]; } else { - $copywarnMsg = array( 'copyrightwarning2', - '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' ); + $copywarnMsg = [ 'copyrightwarning2', + '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' ]; } // Allow for site and per-namespace customization of contribution/copyright notice. - Hooks::run( 'EditPageCopyrightWarning', array( $title, &$copywarnMsg ) ); + Hooks::run( 'EditPageCopyrightWarning', [ $title, &$copywarnMsg ] ); return "
\n" . call_user_func_array( 'wfMessage', $copywarnMsg )->$format() . "\n
"; @@ -3353,24 +3353,24 @@ HTML return ''; } - $limitReport = Html::rawElement( 'div', array( 'class' => 'mw-limitReportExplanation' ), + $limitReport = Html::rawElement( 'div', [ 'class' => 'mw-limitReportExplanation' ], wfMessage( 'limitreport-title' )->parseAsBlock() ); // Show/hide animation doesn't work correctly on a table, so wrap it in a div. - $limitReport .= Html::openElement( 'div', array( 'class' => 'preview-limit-report-wrapper' ) ); + $limitReport .= Html::openElement( 'div', [ 'class' => 'preview-limit-report-wrapper' ] ); - $limitReport .= Html::openElement( 'table', array( + $limitReport .= Html::openElement( 'table', [ 'class' => 'preview-limit-report wikitable' - ) ) . + ] ) . Html::openElement( 'tbody' ); foreach ( $output->getLimitReportData() as $key => $value ) { if ( Hooks::run( 'ParserLimitReportFormat', - array( $key, &$value, &$limitReport, true, true ) + [ $key, &$value, &$limitReport, true, true ] ) ) { $keyMsg = wfMessage( $key ); - $valueMsg = wfMessage( array( "$key-value-html", "$key-value" ) ); + $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] ); if ( !$valueMsg->exists() ) { $valueMsg = new RawMessage( '$1' ); } @@ -3400,7 +3400,7 @@ HTML } $checkboxes = $this->getCheckboxes( $tabindex, - array( 'minor' => $this->minoredit, 'watch' => $this->watchthis ) ); + [ 'minor' => $this->minoredit, 'watch' => $this->watchthis ] ); $wgOut->addHTML( "
" . implode( $checkboxes, "\n" ) . "
\n" ); // Show copyright warning. @@ -3413,18 +3413,18 @@ HTML $cancel = $this->getCancelLink(); if ( $cancel !== '' ) { $cancel .= Html::element( 'span', - array( 'class' => 'mw-editButtons-pipe-separator' ), + [ 'class' => 'mw-editButtons-pipe-separator' ], wfMessage( 'pipe-separator' )->text() ); } $message = wfMessage( 'edithelppage' )->inContentLanguage()->text(); $edithelpurl = Skin::makeInternalOrExternalUrl( $message ); - $attrs = array( + $attrs = [ 'target' => 'helpwindow', 'href' => $edithelpurl, - ); + ]; $edithelp = Html::linkButton( wfMessage( 'edithelp' )->text(), - $attrs, array( 'mw-ui-quiet' ) ) . + $attrs, [ 'mw-ui-quiet' ] ) . wfMessage( 'word-separator' )->escaped() . wfMessage( 'newwindow' )->parse(); @@ -3432,7 +3432,7 @@ HTML $wgOut->addHTML( " {$edithelp}\n" ); $wgOut->addHTML( "
\n" ); - Hooks::run( 'EditPage::showStandardInputs:options', array( $this, $wgOut, &$tabindex ) ); + Hooks::run( 'EditPage::showStandardInputs:options', [ $this, $wgOut, &$tabindex ] ); $wgOut->addHTML( "\n" ); } @@ -3444,7 +3444,7 @@ HTML protected function showConflict() { global $wgOut; - if ( Hooks::run( 'EditPageBeforeConflictDiff', array( &$this, &$wgOut ) ) ) { + if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) { $stats = $wgOut->getContext()->getStats(); $stats->increment( 'edit.failures.conflict' ); @@ -3470,16 +3470,16 @@ HTML * @return string */ public function getCancelLink() { - $cancelParams = array(); + $cancelParams = []; if ( !$this->isConflict && $this->oldid > 0 ) { $cancelParams['oldid'] = $this->oldid; } - $attrs = array( 'id' => 'mw-editform-cancel' ); + $attrs = [ 'id' => 'mw-editform-cancel' ]; return Linker::linkKnown( $this->getContextTitle(), wfMessage( 'cancel' )->parse(), - Html::buttonAttributes( $attrs, array( 'mw-ui-quiet' ) ), + Html::buttonAttributes( $attrs, [ 'mw-ui-quiet' ] ), $cancelParams ); } @@ -3494,7 +3494,7 @@ HTML * @return string */ protected function getActionURL( Title $title ) { - return $title->getLocalURL( array( 'action' => $this->action ) ); + return $title->getLocalURL( [ 'action' => $this->action ] ); } /** @@ -3530,8 +3530,8 @@ HTML protected function getLastDelete() { $dbr = wfGetDB( DB_SLAVE ); $data = $dbr->selectRow( - array( 'logging', 'user' ), - array( + [ 'logging', 'user' ], + [ 'log_type', 'log_action', 'log_timestamp', @@ -3542,15 +3542,15 @@ HTML 'log_params', 'log_deleted', 'user_name' - ), array( + ], [ 'log_namespace' => $this->mTitle->getNamespace(), 'log_title' => $this->mTitle->getDBkey(), 'log_type' => 'delete', 'log_action' => 'delete', 'user_id=log_user' - ), + ], __METHOD__, - array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ) + [ 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ] ); // Quick paranoid permission checks... if ( is_object( $data ) ) { @@ -3600,7 +3600,7 @@ HTML $previewHTML = ''; if ( !Hooks::run( 'AlternateEditPreview', - array( $this, &$content, &$previewHTML, &$this->mParserOutput ) ) + [ $this, &$content, &$previewHTML, &$this->mParserOutput ] ) ) { return $previewHTML; } @@ -3669,7 +3669,7 @@ HTML $content = $content->addSectionHeader( $this->summary ); } - $hook_args = array( $this, &$content ); + $hook_args = [ $this, &$content ]; ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args ); Hooks::run( 'EditPageGetPreviewContent', $hook_args ); @@ -3723,8 +3723,8 @@ HTML $wgOut->parse( $note, true, /* interface */true ) . $conflict . "\n"; $pageViewLang = $this->mTitle->getPageViewLanguage(); - $attribs = array( 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(), - 'class' => 'mw-content-' . $pageViewLang->getDir() ); + $attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(), + 'class' => 'mw-content-' . $pageViewLang->getDir() ]; $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML ); return $previewhead . $previewHTML . $this->previewTextAfterContent; @@ -3735,7 +3735,7 @@ HTML */ function getTemplates() { if ( $this->preview || $this->section != '' ) { - $templates = array(); + $templates = []; if ( !isset( $this->mParserOutput ) ) { return $templates; } @@ -3776,78 +3776,78 @@ HTML * * Images are defined in ResourceLoaderEditToolbarModule. */ - $toolarray = array( - array( + $toolarray = [ + [ 'id' => 'mw-editbutton-bold', 'open' => '\'\'\'', 'close' => '\'\'\'', 'sample' => wfMessage( 'bold_sample' )->text(), 'tip' => wfMessage( 'bold_tip' )->text(), - ), - array( + ], + [ 'id' => 'mw-editbutton-italic', 'open' => '\'\'', 'close' => '\'\'', 'sample' => wfMessage( 'italic_sample' )->text(), 'tip' => wfMessage( 'italic_tip' )->text(), - ), - array( + ], + [ 'id' => 'mw-editbutton-link', 'open' => '[[', 'close' => ']]', 'sample' => wfMessage( 'link_sample' )->text(), 'tip' => wfMessage( 'link_tip' )->text(), - ), - array( + ], + [ 'id' => 'mw-editbutton-extlink', 'open' => '[', 'close' => ']', 'sample' => wfMessage( 'extlink_sample' )->text(), 'tip' => wfMessage( 'extlink_tip' )->text(), - ), - array( + ], + [ 'id' => 'mw-editbutton-headline', 'open' => "\n== ", 'close' => " ==\n", 'sample' => wfMessage( 'headline_sample' )->text(), 'tip' => wfMessage( 'headline_tip' )->text(), - ), - $imagesAvailable ? array( + ], + $imagesAvailable ? [ 'id' => 'mw-editbutton-image', 'open' => '[[' . $wgContLang->getNsText( NS_FILE ) . ':', 'close' => ']]', 'sample' => wfMessage( 'image_sample' )->text(), 'tip' => wfMessage( 'image_tip' )->text(), - ) : false, - $imagesAvailable ? array( + ] : false, + $imagesAvailable ? [ 'id' => 'mw-editbutton-media', 'open' => '[[' . $wgContLang->getNsText( NS_MEDIA ) . ':', 'close' => ']]', 'sample' => wfMessage( 'media_sample' )->text(), 'tip' => wfMessage( 'media_tip' )->text(), - ) : false, - array( + ] : false, + [ 'id' => 'mw-editbutton-nowiki', 'open' => "", 'close' => "", 'sample' => wfMessage( 'nowiki_sample' )->text(), 'tip' => wfMessage( 'nowiki_tip' )->text(), - ), - $showSignature ? array( + ], + $showSignature ? [ 'id' => 'mw-editbutton-signature', 'open' => '--~~~~', 'close' => '', 'sample' => '', 'tip' => wfMessage( 'sig_tip' )->text(), - ) : false, - array( + ] : false, + [ 'id' => 'mw-editbutton-hr', 'open' => "\n----\n", 'close' => '', 'sample' => '', 'tip' => wfMessage( 'hr_tip' )->text(), - ) - ); + ] + ]; $script = 'mw.loader.using("mediawiki.toolbar", function () {'; foreach ( $toolarray as $tool ) { @@ -3855,7 +3855,7 @@ HTML continue; } - $params = array( + $params = [ // Images are defined in ResourceLoaderEditToolbarModule false, // Note that we use the tip both for the ALT tag and the TITLE tag of the image. @@ -3867,7 +3867,7 @@ HTML $tool['close'], $tool['sample'], $tool['id'], - ); + ]; $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', @@ -3881,7 +3881,7 @@ HTML $toolbar = '
'; - Hooks::run( 'EditPageBeforeEditToolbar', array( &$toolbar ) ); + Hooks::run( 'EditPageBeforeEditToolbar', [ &$toolbar ] ); return $toolbar; } @@ -3899,26 +3899,26 @@ HTML public function getCheckboxes( &$tabindex, $checked ) { global $wgUser, $wgUseMediaWikiUIEverywhere; - $checkboxes = array(); + $checkboxes = []; // don't show the minor edit checkbox if it's a new page or section if ( !$this->isNew ) { $checkboxes['minor'] = ''; $minorLabel = wfMessage( 'minoredit' )->parse(); if ( $wgUser->isAllowed( 'minoredit' ) ) { - $attribs = array( + $attribs = [ 'tabindex' => ++$tabindex, 'accesskey' => wfMessage( 'accesskey-minoredit' )->text(), 'id' => 'wpMinoredit', - ); + ]; $minorEditHtml = Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) . " "; if ( $wgUseMediaWikiUIEverywhere ) { - $checkboxes['minor'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) . + $checkboxes['minor'] = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) . $minorEditHtml . Html::closeElement( 'div' ); } else { @@ -3930,25 +3930,25 @@ HTML $watchLabel = wfMessage( 'watchthis' )->parse(); $checkboxes['watch'] = ''; if ( $wgUser->isLoggedIn() ) { - $attribs = array( + $attribs = [ 'tabindex' => ++$tabindex, 'accesskey' => wfMessage( 'accesskey-watch' )->text(), 'id' => 'wpWatchthis', - ); + ]; $watchThisHtml = Xml::check( 'wpWatchthis', $checked['watch'], $attribs ) . " "; if ( $wgUseMediaWikiUIEverywhere ) { - $checkboxes['watch'] = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) . + $checkboxes['watch'] = Html::openElement( 'div', [ 'class' => 'mw-ui-checkbox' ] ) . $watchThisHtml . Html::closeElement( 'div' ); } else { $checkboxes['watch'] = $watchThisHtml; } } - Hooks::run( 'EditPageBeforeEditChecks', array( &$this, &$checkboxes, &$tabindex ) ); + Hooks::run( 'EditPageBeforeEditChecks', [ &$this, &$checkboxes, &$tabindex ] ); return $checkboxes; } @@ -3961,35 +3961,35 @@ HTML * @return array */ public function getEditButtons( &$tabindex ) { - $buttons = array(); + $buttons = []; - $attribs = array( + $attribs = [ 'id' => 'wpSave', 'name' => 'wpSave', 'tabindex' => ++$tabindex, - ) + Linker::tooltipAndAccesskeyAttribs( 'save' ); + ] + Linker::tooltipAndAccesskeyAttribs( 'save' ); $buttons['save'] = Html::submitButton( wfMessage( 'savearticle' )->text(), - $attribs, array( 'mw-ui-constructive' ) ); + $attribs, [ 'mw-ui-constructive' ] ); ++$tabindex; // use the same for preview and live preview - $attribs = array( + $attribs = [ 'id' => 'wpPreview', 'name' => 'wpPreview', 'tabindex' => $tabindex, - ) + Linker::tooltipAndAccesskeyAttribs( 'preview' ); + ] + Linker::tooltipAndAccesskeyAttribs( 'preview' ); $buttons['preview'] = Html::submitButton( wfMessage( 'showpreview' )->text(), $attribs ); $buttons['live'] = ''; - $attribs = array( + $attribs = [ 'id' => 'wpDiff', 'name' => 'wpDiff', 'tabindex' => ++$tabindex, - ) + Linker::tooltipAndAccesskeyAttribs( 'diff' ); + ] + Linker::tooltipAndAccesskeyAttribs( 'diff' ); $buttons['diff'] = Html::submitButton( wfMessage( 'showdiff' )->text(), $attribs ); - Hooks::run( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) ); + Hooks::run( 'EditPageBeforeEditButtons', [ &$this, &$buttons, &$tabindex ] ); return $buttons; } @@ -4003,7 +4003,7 @@ HTML $wgOut->prepareErrorPage( wfMessage( 'nosuchsectiontitle' ) ); $res = wfMessage( 'nosuchsectiontext', $this->section )->parseAsBlock(); - Hooks::run( 'EditPageNoSuchSection', array( &$this, &$res ) ); + Hooks::run( 'EditPageNoSuchSection', [ &$this, &$res ] ); $wgOut->addHTML( $res ); $wgOut->returnToMain( false, $this->mTitle ); @@ -4036,7 +4036,7 @@ HTML $wgOut->wrapWikiMsg( '

$1

', "yourtext" ); $this->showTextbox2(); - $wgOut->addReturnTo( $this->getContextTitle(), array( 'action' => 'edit' ) ); + $wgOut->addReturnTo( $this->getContextTitle(), [ 'action' => 'edit' ] ); } /** @@ -4106,7 +4106,7 @@ HTML */ private function makeSafe( $invalue ) { // Armor existing references for reversibility. - $invalue = strtr( $invalue, array( "&#x" => "�" ) ); + $invalue = strtr( $invalue, [ "&#x" => "�" ] ); $bytesleft = 0; $result = ""; @@ -4172,6 +4172,6 @@ HTML } } // reverse the transform that we made for reversibility reasons. - return strtr( $result, array( "�" => "&#x" ) ); + return strtr( $result, [ "�" => "&#x" ] ); } } diff --git a/includes/EventRelayerGroup.php b/includes/EventRelayerGroup.php index 3af756dccb..9dfac795a6 100644 --- a/includes/EventRelayerGroup.php +++ b/includes/EventRelayerGroup.php @@ -7,10 +7,10 @@ */ class EventRelayerGroup { /** @var array[] */ - protected $configByChannel = array(); + protected $configByChannel = []; /** @var EventRelayer[] */ - protected $relayers = array(); + protected $relayers = []; /** @var EventRelayerGroup */ protected static $instance = null; diff --git a/includes/Fallback.php b/includes/Fallback.php index 8e7f4b7e27..4c19dca267 100644 --- a/includes/Fallback.php +++ b/includes/Fallback.php @@ -138,7 +138,7 @@ class Fallback { public static function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) { $needle = preg_quote( $needle, '/' ); - $ar = array(); + $ar = []; preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); if ( isset( $ar[0][1] ) ) { @@ -159,7 +159,7 @@ class Fallback { public static function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) { $needle = preg_quote( $needle, '/' ); - $ar = array(); + $ar = []; preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); if ( isset( $ar[0] ) && count( $ar[0] ) > 0 && diff --git a/includes/FauxRequest.php b/includes/FauxRequest.php index f049d2ece0..c2108f207a 100644 --- a/includes/FauxRequest.php +++ b/includes/FauxRequest.php @@ -33,7 +33,7 @@ use MediaWiki\Session\SessionManager; class FauxRequest extends WebRequest { private $wasPosted = false; private $requestUrl; - protected $cookies = array(); + protected $cookies = []; /** * @param array $data Array of *non*-urlencoded key => value pairs, the @@ -44,7 +44,7 @@ class FauxRequest extends WebRequest { * @param string $protocol 'http' or 'https' * @throws MWException */ - public function __construct( $data = array(), $wasPosted = false, + public function __construct( $data = [], $wasPosted = false, $session = null, $protocol = 'http' ) { $this->requestTime = microtime( true ); @@ -98,7 +98,7 @@ class FauxRequest extends WebRequest { */ public function getQueryValues() { if ( $this->wasPosted ) { - return array(); + return []; } else { return $this->data; } @@ -131,7 +131,7 @@ class FauxRequest extends WebRequest { * @param string|null $prefix Cookie prefix. Defaults to $wgCookiePrefix */ public function setCookie( $key, $value, $prefix = null ) { - $this->setCookies( array( $key => $value ), $prefix ); + $this->setCookies( [ $key => $value ], $prefix ); } /** @@ -177,7 +177,7 @@ class FauxRequest extends WebRequest { * @param string $val */ public function setHeader( $name, $val ) { - $this->setHeaders( array( $name => $val ) ); + $this->setHeaders( [ $name => $val ] ); } /** @@ -229,7 +229,7 @@ class FauxRequest extends WebRequest { * @param array $extWhitelist * @return bool */ - public function checkUrlExtension( $extWhitelist = array() ) { + public function checkUrlExtension( $extWhitelist = [] ) { return true; } diff --git a/includes/Feed.php b/includes/Feed.php index 2133dae48c..8bfe1c7ef9 100644 --- a/includes/Feed.php +++ b/includes/Feed.php @@ -248,12 +248,12 @@ abstract class ChannelFeed extends FeedItem { global $wgRequest; $ctype = $wgRequest->getVal( 'ctype', 'application/xml' ); - $allowedctypes = array( + $allowedctypes = [ 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' - ); + ]; return ( in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml' ); } diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php index b058975b73..d7dbd2292e 100644 --- a/includes/FeedUtils.php +++ b/includes/FeedUtils.php @@ -111,9 +111,9 @@ class FeedUtils { // log entries $completeText = '

' . implode( ' ', array_filter( - array( + [ $actiontext, - Linker::formatComment( $comment ) ) ) ) . "

\n"; + Linker::formatComment( $comment ) ] ) ) . "

\n"; // NOTE: Check permissions for anonymous users, not current user. // No "privileged" version should end up in the cache. @@ -218,13 +218,13 @@ class FeedUtils { * @return string */ protected static function getDiffLink( Title $title, $newid, $oldid = null ) { - $queryParameters = array( 'diff' => $newid ); + $queryParameters = [ 'diff' => $newid ]; if ( $oldid != null ) { $queryParameters['oldid'] = $oldid; } $diffUrl = $title->getFullURL( $queryParameters ); - $diffLink = Html::element( 'a', array( 'href' => $diffUrl ), + $diffLink = Html::element( 'a', [ 'href' => $diffUrl ], wfMessage( 'showdiff' )->inContentLanguage()->text() ); return $diffLink; @@ -239,7 +239,7 @@ class FeedUtils { * @return string Modified HTML */ public static function applyDiffStyle( $text ) { - $styles = array( + $styles = [ 'diff' => 'background-color: white; color:black;', 'diff-otitle' => 'background-color: white; color:black; text-align: center;', 'diff-ntitle' => 'background-color: white; color:black; text-align: center;', @@ -253,7 +253,7 @@ class FeedUtils { . 'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; ' . 'border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;', 'diffchange' => 'font-weight: bold; text-decoration: none;', - ); + ]; foreach ( $styles as $class => $style ) { $text = preg_replace( "/(<[^>]+)class=(['\"])$class\\2([^>]*>)/", diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 8b41ad4c73..98f8283813 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -218,7 +218,7 @@ class FileDeleteForm { } if ( $status->isOK() ) { - Hooks::run( 'FileDeleteComplete', array( &$file, &$oldimage, &$page, &$user, &$reason ) ); + Hooks::run( 'FileDeleteComplete', [ &$file, &$oldimage, &$page, &$user, &$reason ] ); } return $status; @@ -235,7 +235,7 @@ class FileDeleteForm { " . Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(), - 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '3' ) ) . + 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '3' ] ) . " "; } else { @@ -243,13 +243,13 @@ class FileDeleteForm { } $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $wgUser->isWatched( $this->title ); - $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction(), - 'id' => 'mw-img-deleteconfirm' ) ) . + $form = Xml::openElement( 'form', [ 'method' => 'post', 'action' => $this->getAction(), + 'id' => 'mw-img-deleteconfirm' ] ) . Xml::openElement( 'fieldset' ) . Xml::element( 'legend', null, wfMessage( 'filedelete-legend' )->text() ) . Html::hidden( 'wpEditToken', $wgUser->getEditToken( $this->oldimage ) ) . $this->prepareMessage( 'filedelete-intro' ) . - Xml::openElement( 'table', array( 'id' => 'mw-img-deleteconfirm-table' ) ) . + Xml::openElement( 'table', [ 'id' => 'mw-img-deleteconfirm-table' ] ) . " " . Xml::label( wfMessage( 'filedelete-comment' )->text(), 'wpDeleteReasonList' ) . @@ -271,7 +271,7 @@ class FileDeleteForm { " " . Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ), - array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) . + [ 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ] ) . " {$suppress}"; @@ -281,7 +281,7 @@ class FileDeleteForm { " . Xml::checkLabel( wfMessage( 'watchthis' )->text(), - 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) . + 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ) . " "; } @@ -291,11 +291,11 @@ class FileDeleteForm { " . Xml::submitButton( wfMessage( 'filedelete-submit' )->text(), - array( + [ 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit', 'tabindex' => '4' - ) + ] ) . " " . @@ -308,8 +308,8 @@ class FileDeleteForm { $link = Linker::linkKnown( $title, wfMessage( 'filedelete-edit-reasonlist' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); $form .= '

' . $link . '

'; } @@ -398,7 +398,7 @@ class FileDeleteForm { * @return string */ private function getAction() { - $q = array(); + $q = []; $q['action'] = 'delete'; if ( $this->oldimage ) { diff --git a/includes/ForkController.php b/includes/ForkController.php index 4a021ee1e5..2725753498 100644 --- a/includes/ForkController.php +++ b/includes/ForkController.php @@ -30,11 +30,11 @@ * @ingroup Maintenance */ class ForkController { - protected $children = array(), $childNumber = 0; + protected $children = [], $childNumber = 0; protected $termReceived = false; protected $flags = 0, $procsToStart = 0; - protected static $restartableSignals = array( + protected static $restartableSignals = [ SIGFPE, SIGILL, SIGSEGV, @@ -44,7 +44,7 @@ class ForkController { SIGPIPE, SIGXCPU, SIGXFSZ, - ); + ]; /** * Pass this flag to __construct() to cause the class to automatically restart @@ -73,7 +73,7 @@ class ForkController { */ public function start() { // Trap SIGTERM - pcntl_signal( SIGTERM, array( $this, 'handleTermSignal' ), false ); + pcntl_signal( SIGTERM, [ $this, 'handleTermSignal' ], false ); do { // Start child processes diff --git a/includes/FormOptions.php b/includes/FormOptions.php index c91c336762..5e5e8d4011 100644 --- a/includes/FormOptions.php +++ b/includes/FormOptions.php @@ -64,7 +64,7 @@ class FormOptions implements ArrayAccess { * consumeValue() or consumeValues() * - 'type' - one of the type constants (but never AUTO) */ - protected $options = array(); + protected $options = []; # Setting up @@ -76,7 +76,7 @@ class FormOptions implements ArrayAccess { * @param int $type One of the type constants (optional, defaults to AUTO) */ public function add( $name, $default, $type = self::AUTO ) { - $option = array(); + $option = []; $option['default'] = $default; $option['value'] = null; $option['consumed'] = false; @@ -228,7 +228,7 @@ class FormOptions implements ArrayAccess { * @return array Array of option values, or the default values if they are null */ public function consumeValues( $names ) { - $out = array(); + $out = []; foreach ( $names as $name ) { $this->validateName( $name, true ); @@ -278,7 +278,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getUnconsumedValues( $all = false ) { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { if ( !$data['consumed'] ) { @@ -296,7 +296,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getChangedValues() { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { if ( $data['value'] !== null ) { @@ -312,7 +312,7 @@ class FormOptions implements ArrayAccess { * @return array */ public function getAllValues() { - $values = array(); + $values = []; foreach ( $this->options as $name => $data ) { $values[$name] = $this->getValueReal( $data ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a1ea9360cf..ac1dd6d049 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -293,13 +293,13 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { */ function wfMergeErrorArrays( /*...*/ ) { $args = func_get_args(); - $out = array(); + $out = []; foreach ( $args as $errors ) { foreach ( $errors as $params ) { $originalParams = $params; if ( $params[0] instanceof MessageSpecifier ) { $msg = $params[0]; - $params = array_merge( array( $msg->getKey() ), $msg->getParams() ); + $params = array_merge( [ $msg->getKey() ], $msg->getParams() ); } # @todo FIXME: Sometimes get nested arrays for $params, # which leads to E_NOTICEs @@ -342,7 +342,7 @@ function wfArrayInsertAfter( array $array, array $insert, $after ) { * @return array */ function wfObjectToArray( $objOrArray, $recursive = true ) { - $array = array(); + $array = []; if ( is_object( $objOrArray ) ) { $objOrArray = get_object_vars( $objOrArray ); } @@ -429,7 +429,7 @@ function wfUrlencode( $s ) { } if ( is_null( $needle ) ) { - $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' ); + $needle = [ '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F', '%7E' ]; if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) { @@ -440,7 +440,7 @@ function wfUrlencode( $s ) { $s = urlencode( $s ); $s = str_ireplace( $needle, - array( ';', '@', '$', '!', '*', '(', ')', ',', '/', '~', ':' ), + [ ';', '@', '$', '!', '*', '(', ')', ',', '/', '~', ':' ], $s ); @@ -507,7 +507,7 @@ function wfCgiToArray( $query ) { $query = substr( $query, 1 ); } $bits = explode( '&', $query ); - $ret = array(); + $ret = []; foreach ( $bits as $bit ) { if ( $bit === '' ) { continue; @@ -527,7 +527,7 @@ function wfCgiToArray( $query ) { $temp = $value; foreach ( $keys as $k ) { $k = substr( $k, 0, -1 ); - $temp = array( $k => $temp ); + $temp = [ $k => $temp ]; } if ( isset( $ret[$key] ) ) { $ret[$key] = array_merge( $ret[$key], $temp ); @@ -806,7 +806,7 @@ function wfUrlProtocols( $includeProtocolRelative = true ) { // Support old-style $wgUrlProtocols strings, for backwards compatibility // with LocalSettings files from 1.5 if ( is_array( $wgUrlProtocols ) ) { - $protocols = array(); + $protocols = []; foreach ( $wgUrlProtocols as $protocol ) { // Filter out '//' if !$includeProtocolRelative if ( $includeProtocolRelative || $protocol !== '//' ) { @@ -988,9 +988,9 @@ function wfMakeUrlIndexes( $url ) { } if ( $prot == '' ) { - return array( "http:$index", "https:$index" ); + return [ "http:$index", "https:$index" ]; } else { - return array( $index ); + return [ $index ]; } } @@ -1034,7 +1034,7 @@ function wfMatchesDomainList( $url, $domains ) { * - false: same as 'private' * @param array $context Additional logging context data */ -function wfDebug( $text, $dest = 'all', array $context = array() ) { +function wfDebug( $text, $dest = 'all', array $context = [] ) { global $wgDebugRawPage, $wgDebugLogPrefix; global $wgDebugTimestamps, $wgRequestTime; @@ -1128,7 +1128,7 @@ function wfDebugMem( $exact = false ) { * @param array $context Additional logging context data */ function wfDebugLog( - $logGroup, $text, $dest = 'all', array $context = array() + $logGroup, $text, $dest = 'all', array $context = [] ) { $text = trim( $text ); @@ -1145,7 +1145,7 @@ function wfDebugLog( * @param string $text Database error message. * @param array $context Additional logging context data */ -function wfLogDBError( $text, array $context = array() ) { +function wfLogDBError( $text, array $context = [] ) { $logger = LoggerFactory::getInstance( 'wfLogDBError' ); $logger->error( trim( $text ), $context ); } @@ -1207,7 +1207,7 @@ function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) { * @throws MWException * @deprecated since 1.25 Use \MediaWiki\Logger\LegacyLogger::emit or UDPTransport */ -function wfErrorLog( $text, $file, array $context = array() ) { +function wfErrorLog( $text, $file, array $context = [] ) { wfDeprecated( __METHOD__, '1.25' ); $logger = LoggerFactory::getInstance( 'wfErrorLog' ); $context['destination'] = $file; @@ -1256,7 +1256,7 @@ function wfLogProfilingData() { return; } - $ctx = array( 'elapsed' => $request->getElapsedTime() ); + $ctx = [ 'elapsed' => $request->getElapsedTime() ]; if ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { $ctx['forwarded_for'] = $_SERVER['HTTP_X_FORWARDED_FOR']; } @@ -1466,7 +1466,7 @@ function wfMsgReplaceArgs( $message, $args ) { if ( is_array( $args[0] ) ) { $args = array_values( $args[0] ); } - $replacementKeys = array(); + $replacementKeys = []; foreach ( $args as $n => $param ) { $replacementKeys['$' . ( $n + 1 )] = $param; } @@ -1527,7 +1527,7 @@ function wfReportTime() { global $wgRequestTime, $wgShowHostnames; $responseTime = round( ( microtime( true ) - $wgRequestTime ) * 1000 ); - $reportVars = array( 'wgBackendResponseTime' => $responseTime ); + $reportVars = [ 'wgBackendResponseTime' => $responseTime ]; if ( $wgShowHostnames ) { $reportVars['wgHostname'] = wfHostname(); } @@ -1554,7 +1554,7 @@ function wfDebugBacktrace( $limit = 0 ) { } } if ( $disabled ) { - return array(); + return []; } if ( $limit && version_compare( PHP_VERSION, '5.4.0', '>=' ) ) { @@ -1675,7 +1675,7 @@ function wfClientAcceptsGzip( $force = false ) { $result = false; if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { # @todo FIXME: We may want to blacklist some broken browsers - $m = array(); + $m = []; if ( preg_match( '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', $_SERVER['HTTP_ACCEPT_ENCODING'], @@ -1706,7 +1706,7 @@ function wfClientAcceptsGzip( $force = false ) { function wfEscapeWikiText( $text ) { static $repl = null, $repl2 = null; if ( $repl === null ) { - $repl = array( + $repl = [ '"' => '"', '&' => '&', "'" => ''', '<' => '<', '=' => '=', '>' => '>', '[' => '[', ']' => ']', '{' => '{', '|' => '|', '}' => '}', ';' => ';', @@ -1719,10 +1719,10 @@ function wfEscapeWikiText( $text ) { "\n\t" => "\n ", "\r\t" => "\r ", // "\n\t\n" is treated like "\n\n" "\n----" => "\n----", "\r----" => "\r----", '__' => '__', '://' => '://', - ); + ]; // We have to catch everything "\s" matches in PCRE - foreach ( array( 'ISBN', 'RFC', 'PMID' ) as $magic ) { + foreach ( [ 'ISBN', 'RFC', 'PMID' ] as $magic ) { $repl["$magic "] = "$magic "; $repl["$magic\t"] = "$magic "; $repl["$magic\r"] = "$magic "; @@ -1732,7 +1732,7 @@ function wfEscapeWikiText( $text ) { // And handle protocols that don't use "://" global $wgUrlProtocols; - $repl2 = array(); + $repl2 = []; foreach ( $wgUrlProtocols as $prot ) { if ( substr( $prot, -1 ) === ':' ) { $repl2[] = preg_quote( substr( $prot, 0, -1 ), '/' ); @@ -1912,17 +1912,17 @@ function wfClearOutputBuffers() { function wfAcceptToPrefs( $accept, $def = '*/*' ) { # No arg means accept anything (per HTTP spec) if ( !$accept ) { - return array( $def => 1.0 ); + return [ $def => 1.0 ]; } - $prefs = array(); + $prefs = []; $parts = explode( ',', $accept ); foreach ( $parts as $part ) { # @todo FIXME: Doesn't deal with params like 'text/html; level=1' $values = explode( ';', trim( $part ) ); - $match = array(); + $match = []; if ( count( $values ) == 1 ) { $prefs[$values[0]] = 1.0; } elseif ( preg_match( '/q\s*=\s*(\d*\.\d+)/', $values[1], $match ) ) { @@ -1974,7 +1974,7 @@ function mimeTypeMatch( $type, $avail ) { * XXX: generalize to negotiate other stuff */ function wfNegotiateType( $cprefs, $sprefs ) { - $combine = array(); + $combine = []; foreach ( array_keys( $sprefs ) as $type ) { $parts = explode( '/', $type ); @@ -2164,7 +2164,7 @@ function wfTempDir() { return $wgTmpDirectory; } - $tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) ); + $tmpDir = array_map( "getenv", [ 'TMPDIR', 'TMP', 'TEMP' ] ); $tmpDir[] = sys_get_temp_dir(); $tmpDir[] = ini_get( 'upload_tmp_dir' ); @@ -2201,7 +2201,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) { return true; } - $dir = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $dir ); + $dir = str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, $dir ); if ( is_null( $mode ) ) { $mode = $wgDirectoryMode; @@ -2349,7 +2349,7 @@ function wfEscapeShellArg( /*...*/ ) { } // Double the backslashes before the end of the string, because // we will soon add a quote - $m = array(); + $m = []; if ( preg_match( '/^(.*?)(\\\\+)$/', $arg, $m ) ) { $arg = $m[1] . str_replace( '\\', '\\\\', $m[2] ); } @@ -2404,8 +2404,8 @@ function wfShellExecDisabled() { * * @return string Collected stdout as a string */ -function wfShellExec( $cmd, &$retval = null, $environ = array(), - $limits = array(), $options = array() +function wfShellExec( $cmd, &$retval = null, $environ = [], + $limits = [], $options = [] ) { global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime, $wgMaxShellWallClockTime, $wgShellCgroup; @@ -2478,12 +2478,12 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), } wfDebug( "wfShellExec: $cmd\n" ); - $desc = array( - 0 => array( 'file', 'php://stdin', 'r' ), - 1 => array( 'pipe', 'w' ), - 2 => array( 'file', 'php://stderr', 'w' ) ); + $desc = [ + 0 => [ 'file', 'php://stdin', 'r' ], + 1 => [ 'pipe', 'w' ], + 2 => [ 'file', 'php://stderr', 'w' ] ]; if ( $useLogPipe ) { - $desc[3] = array( 'pipe', 'w' ); + $desc[3] = [ 'pipe', 'w' ]; } $pipes = null; $scoped = Profiler::instance()->scopedProfileIn( __FUNCTION__ . '-' . $profileMethod ); @@ -2494,7 +2494,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), return ''; } $outBuffer = $logBuffer = ''; - $emptyArray = array(); + $emptyArray = []; $status = false; $logMsg = false; @@ -2515,7 +2515,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), // Build a table mapping resource IDs to pipe FDs to work around a // PHP 5.3 issue in which stream_select() does not preserve array keys // . - $fds = array(); + $fds = []; foreach ( $pipes as $fd => $pipe ) { $fds[(int)$pipe] = $fd; } @@ -2638,9 +2638,9 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), * this overwrites the global wgMaxShell* limits. * @return string Collected stdout and stderr as a string */ -function wfShellExecWithStderr( $cmd, &$retval = null, $environ = array(), $limits = array() ) { +function wfShellExecWithStderr( $cmd, &$retval = null, $environ = [], $limits = [] ) { return wfShellExec( $cmd, $retval, $environ, $limits, - array( 'duplicateStderr' => true, 'profileMethod' => wfGetCaller() ) ); + [ 'duplicateStderr' => true, 'profileMethod' => wfGetCaller() ] ); } /** @@ -2670,12 +2670,12 @@ function wfInitShellLocale() { * 'wrapper': Path to a PHP wrapper to handle the maintenance script * @return string */ -function wfShellWikiCmd( $script, array $parameters = array(), array $options = array() ) { +function wfShellWikiCmd( $script, array $parameters = [], array $options = [] ) { global $wgPhpCli; // Give site config file a chance to run the script in a wrapper. // The caller may likely want to call wfBasename() on $script. - Hooks::run( 'wfShellWikiCmd', array( &$script, &$parameters, &$options ) ); - $cmd = isset( $options['php'] ) ? array( $options['php'] ) : array( $wgPhpCli ); + Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] ); + $cmd = isset( $options['php'] ) ? [ $options['php'] ] : [ $wgPhpCli ]; if ( isset( $options['wrapper'] ) ) { $cmd[] = $options['wrapper']; } @@ -2912,7 +2912,7 @@ function wfBaseName( $path, $suffix = '' ) { $encSuffix = '(?:' . preg_quote( $suffix, '#' ) . ')?'; } - $matches = array(); + $matches = []; if ( preg_match( "#([^/\\\\]*?){$encSuffix}[/\\\\]*$#", $path, $matches ) ) { return $matches[1]; } else { @@ -3092,7 +3092,7 @@ function wfGetPrecompiledData( $name ) { */ function wfMemcKey( /*...*/ ) { return call_user_func_array( - array( ObjectCache::getLocalClusterInstance(), 'makeKey' ), + [ ObjectCache::getLocalClusterInstance(), 'makeKey' ], func_get_args() ); } @@ -3111,8 +3111,8 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) { $args = array_slice( func_get_args(), 2 ); $keyspace = $prefix ? "$db-$prefix" : $db; return call_user_func_array( - array( ObjectCache::getLocalClusterInstance(), 'makeKeyInternal' ), - array( $keyspace, $args ) + [ ObjectCache::getLocalClusterInstance(), 'makeKeyInternal' ], + [ $keyspace, $args ] ); } @@ -3129,7 +3129,7 @@ function wfForeignMemcKey( $db, $prefix /*...*/ ) { */ function wfGlobalCacheKey( /*...*/ ) { return call_user_func_array( - array( ObjectCache::getLocalClusterInstance(), 'makeGlobalKey' ), + [ ObjectCache::getLocalClusterInstance(), 'makeGlobalKey' ], func_get_args() ); } @@ -3186,7 +3186,7 @@ function wfSplitWikiID( $wiki ) { * * @return DatabaseBase */ -function wfGetDB( $db, $groups = array(), $wiki = false ) { +function wfGetDB( $db, $groups = [], $wiki = false ) { return wfGetLB( $wiki )->getConnection( $db, $groups, $wiki ); } @@ -3217,7 +3217,7 @@ function wfGetLBFactory() { * @param array $options Associative array of options (see RepoGroup::findFile) * @return File|bool File, or false if the file does not exist */ -function wfFindFile( $title, $options = array() ) { +function wfFindFile( $title, $options = [] ) { return RepoGroup::singleton()->findFile( $title, $options ); } @@ -3345,13 +3345,13 @@ function wfWaitForSlaves( } try { - wfGetLBFactory()->waitForReplication( array( + wfGetLBFactory()->waitForReplication( [ 'wiki' => $wiki, 'cluster' => $cluster, 'timeout' => $timeout, // B/C: first argument used to be "max seconds of lag"; ignore such values 'ifWritesSince' => ( $ifWritesSince > 1e9 ) ? $ifWritesSince : null - ) ); + ] ); } catch ( DBReplicationWaitError $e ) { return false; } @@ -3487,7 +3487,7 @@ function wfShorthandToInteger( $string = '', $default = -1 ) { */ function wfBCP47( $code ) { $codeSegment = explode( '-', $code ); - $codeBCP = array(); + $codeBCP = []; foreach ( $codeSegment as $segNo => $seg ) { // when previous segment is x, it is a private segment and should be lc if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) { @@ -3557,7 +3557,7 @@ function wfGetParserCacheStorage() { * @return bool True if no handler aborted the hook * @deprecated 1.25 - use Hooks::run */ -function wfRunHooks( $event, array $args = array(), $deprecatedVersion = null ) { +function wfRunHooks( $event, array $args = [], $deprecatedVersion = null ) { return Hooks::run( $event, $args, $deprecatedVersion ); } @@ -3619,7 +3619,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { # Run the extension hook $bad = false; - if ( !Hooks::run( 'BadImage', array( $name, &$bad ) ) ) { + if ( !Hooks::run( 'BadImage', [ $name, &$bad ] ) ) { return $bad; } @@ -3632,7 +3632,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { $blacklist = wfMessage( 'bad_image_list' )->inContentLanguage()->plain(); // site list } # Build the list now - $badImages = array(); + $badImages = []; $lines = explode( "\n", $blacklist ); foreach ( $lines as $line ) { # List items only @@ -3641,12 +3641,12 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { } # Find all links - $m = array(); + $m = []; if ( !preg_match_all( '/\[\[:?(.*?)\]\]/', $line, $m ) ) { continue; } - $exceptions = array(); + $exceptions = []; $imageDBkey = false; foreach ( $m[1] as $i => $titleText ) { $title = Title::newFromText( $titleText ); @@ -3681,7 +3681,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { */ function wfCanIPUseHTTPS( $ip ) { $canDo = true; - Hooks::run( 'CanIPUseHTTPS', array( $ip, &$canDo ) ); + Hooks::run( 'CanIPUseHTTPS', [ $ip, &$canDo ] ); return !!$canDo; } @@ -3693,7 +3693,7 @@ function wfCanIPUseHTTPS( $ip ) { * @since 1.25 */ function wfIsInfinity( $str ) { - $infinityValues = array( 'infinite', 'indefinite', 'infinity', 'never' ); + $infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ]; return in_array( $str, $infinityValues ); } @@ -3714,7 +3714,7 @@ function wfIsInfinity( $str ) { function wfThumbIsStandard( File $file, array $params ) { global $wgThumbLimits, $wgImageLimits, $wgResponsiveImages; - $multipliers = array( 1 ); + $multipliers = [ 1 ]; if ( $wgResponsiveImages ) { // These available sizes are hardcoded currently elsewhere in MediaWiki. // @see Linker::processResponsiveImages @@ -3727,13 +3727,13 @@ function wfThumbIsStandard( File $file, array $params ) { return false; } - $basicParams = array(); + $basicParams = []; if ( isset( $params['page'] ) ) { $basicParams['page'] = $params['page']; } - $thumbLimits = array(); - $imageLimits = array(); + $thumbLimits = []; + $imageLimits = []; // Expand limits to account for multipliers foreach ( $multipliers as $multiplier ) { $thumbLimits = array_merge( $thumbLimits, array_map( @@ -3743,24 +3743,24 @@ function wfThumbIsStandard( File $file, array $params ) { ); $imageLimits = array_merge( $imageLimits, array_map( function ( $pair ) use ( $multiplier ) { - return array( + return [ round( $pair[0] * $multiplier ), round( $pair[1] * $multiplier ), - ); + ]; }, $wgImageLimits ) ); } // Check if the width matches one of $wgThumbLimits if ( in_array( $params['width'], $thumbLimits ) ) { - $normalParams = $basicParams + array( 'width' => $params['width'] ); + $normalParams = $basicParams + [ 'width' => $params['width'] ]; // Append any default values to the map (e.g. "lossy", "lossless", ...) $handler->normaliseParams( $file, $normalParams ); } else { // If not, then check if the width matchs one of $wgImageLimits $match = false; foreach ( $imageLimits as $pair ) { - $normalParams = $basicParams + array( 'width' => $pair[0], 'height' => $pair[1] ); + $normalParams = $basicParams + [ 'width' => $pair[0], 'height' => $pair[1] ]; // Decide whether the thumbnail should be scaled on width or height. // Also append any default values to the map (e.g. "lossy", "lossless", ...) $handler->normaliseParams( $file, $normalParams ); diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index 494cbfaf8f..87fc0122e7 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -71,7 +71,7 @@ interface HistoryBlob { * Improves compression ratio by concatenating like objects before gzipping */ class ConcatenatedGzipHistoryBlob implements HistoryBlob { - public $mVersion = 0, $mCompressed = false, $mItems = array(), $mDefaultHash = ''; + public $mVersion = 0, $mCompressed = false, $mItems = [], $mDefaultHash = ''; public $mSize = 0; public $mMaxSize = 10000000; public $mMaxCount = 100; @@ -165,7 +165,7 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob { */ function __sleep() { $this->compress(); - return array( 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' ); + return [ 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' ]; } function __wakeup() { @@ -194,7 +194,7 @@ class HistoryBlobStub { * blob. By keeping the last-used one open, we avoid redundant * unserialization and decompression overhead. */ - protected static $blobCache = array(); + protected static $blobCache = []; /** @var int */ public $mOldId; @@ -248,8 +248,8 @@ class HistoryBlobStub { $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'text', - array( 'old_flags', 'old_text' ), - array( 'old_id' => $this->mOldId ) + [ 'old_flags', 'old_text' ], + [ 'old_id' => $this->mOldId ] ); if ( !$row ) { @@ -287,7 +287,7 @@ class HistoryBlobStub { // Save this item for reference; if pulling many // items in a row we'll likely use it again. $obj->uncompress(); - self::$blobCache = array( $this->mOldId => $obj ); + self::$blobCache = [ $this->mOldId => $obj ]; } return $obj->getItem( $this->mHash ); @@ -337,7 +337,7 @@ class HistoryBlobCurStub { */ function getText() { $dbr = wfGetDB( DB_SLAVE ); - $row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) ); + $row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ] ); if ( !$row ) { return false; } @@ -351,7 +351,7 @@ class HistoryBlobCurStub { */ class DiffHistoryBlob implements HistoryBlob { /** @var array Uncompressed item cache */ - public $mItems = array(); + public $mItems = []; /** @var int Total uncompressed size */ public $mSize = 0; @@ -454,18 +454,18 @@ class DiffHistoryBlob implements HistoryBlob { } // Create two diff sequences: one for main text and one for small text - $sequences = array( - 'small' => array( + $sequences = [ + 'small' => [ 'tail' => '', - 'diffs' => array(), - 'map' => array(), - ), - 'main' => array( + 'diffs' => [], + 'map' => [], + ], + 'main' => [ 'tail' => '', - 'diffs' => array(), - 'map' => array(), - ), - ); + 'diffs' => [], + 'map' => [], + ], + ]; $smallFactor = 0.5; $mItemsCount = count( $this->mItems ); @@ -492,8 +492,8 @@ class DiffHistoryBlob implements HistoryBlob { // Knit the sequences together $tail = ''; - $this->mDiffs = array(); - $this->mDiffMap = array(); + $this->mDiffs = []; + $this->mDiffMap = []; foreach ( $sequences as $seq ) { if ( !count( $seq['diffs'] ) ) { continue; @@ -644,16 +644,16 @@ class DiffHistoryBlob implements HistoryBlob { $map .= $i - $prev; $prev = $i; } - $info = array( + $info = [ 'diffs' => $this->mDiffs, 'map' => $map - ); + ]; } if ( isset( $this->mDefaultKey ) ) { $info['default'] = $this->mDefaultKey; } $this->mCompressed = gzdeflate( serialize( $info ) ); - return array( 'mCompressed' ); + return [ 'mCompressed' ]; } function __wakeup() { @@ -681,7 +681,7 @@ class DiffHistoryBlob implements HistoryBlob { // New format $map = explode( ',', $info['map'] ); $cur = 0; - $this->mDiffMap = array(); + $this->mDiffMap = []; foreach ( $map as $i ) { $cur += $i; $this->mDiffMap[] = $cur; diff --git a/includes/Hooks.php b/includes/Hooks.php index cd38a7d45e..b6c194c12a 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -36,7 +36,7 @@ class Hooks { * Array of events mapped to an array of callbacks to be run * when that event is triggered. */ - protected static $handlers = array(); + protected static $handlers = []; /** * Attach an event handler to a given hook. @@ -48,7 +48,7 @@ class Hooks { */ public static function register( $name, $callback ) { if ( !isset( self::$handlers[$name] ) ) { - self::$handlers[$name] = array(); + self::$handlers[$name] = []; } self::$handlers[$name][] = $callback; @@ -98,7 +98,7 @@ class Hooks { global $wgHooks; if ( !self::isRegistered( $name ) ) { - return array(); + return []; } elseif ( !isset( self::$handlers[$name] ) ) { return $wgHooks[$name]; } elseif ( !isset( $wgHooks[$name] ) ) { @@ -128,11 +128,11 @@ class Hooks { * processing to continue. Not returning a value (or explicitly * returning null) is equivalent to returning true. */ - public static function run( $event, array $args = array(), $deprecatedVersion = null ) { + public static function run( $event, array $args = [], $deprecatedVersion = null ) { foreach ( self::getHandlers( $event ) as $hook ) { // Turn non-array values into an array. (Can't use casting because of objects.) if ( !is_array( $hook ) ) { - $hook = array( $hook ); + $hook = [ $hook ]; } if ( !array_filter( $hook ) ) { @@ -163,7 +163,7 @@ class Hooks { } $func = get_class( $object ) . '::' . $method; - $callback = array( $object, $method ); + $callback = [ $object, $method ]; } elseif ( is_string( $hook[0] ) ) { $func = $callback = array_shift( $hook ); } else { diff --git a/includes/Html.php b/includes/Html.php index 5f91dacaba..3b360392d1 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -49,7 +49,7 @@ */ class Html { // List of void elements from HTML5, section 8.1.2 as of 2011-08-12 - private static $voidElements = array( + private static $voidElements = [ 'area', 'base', 'br', @@ -66,11 +66,11 @@ class Html { 'source', 'track', 'wbr', - ); + ]; // Boolean attributes, which may have the value omitted entirely. Manually // collected from the HTML5 spec as of 2011-08-12. - private static $boolAttribs = array( + private static $boolAttribs = [ 'async', 'autofocus', 'autoplay', @@ -99,7 +99,7 @@ class Html { 'typemustmatch', // HTML5 Microdata 'itemscope', - ); + ]; /** * Modifies a set of attributes meant for button elements @@ -109,7 +109,7 @@ class Html { * @see https://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return array $attrs A modified attribute array */ - public static function buttonAttributes( array $attrs, array $modifiers = array() ) { + public static function buttonAttributes( array $attrs, array $modifiers = [] ) { global $wgUseMediaWikiUIEverywhere; if ( $wgUseMediaWikiUIEverywhere ) { if ( isset( $attrs['class'] ) ) { @@ -165,7 +165,7 @@ class Html { * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return string Raw HTML */ - public static function linkButton( $contents, array $attrs, array $modifiers = array() ) { + public static function linkButton( $contents, array $attrs, array $modifiers = [] ) { return self::element( 'a', self::buttonAttributes( $attrs, $modifiers ), $contents @@ -185,7 +185,7 @@ class Html { * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers * @return string Raw HTML */ - public static function submitButton( $contents, array $attrs, array $modifiers = array() ) { + public static function submitButton( $contents, array $attrs, array $modifiers = [] ) { $attrs['type'] = 'submit'; $attrs['value'] = $contents; return self::element( 'input', self::buttonAttributes( $attrs, $modifiers ) ); @@ -210,7 +210,7 @@ class Html { * escaped! * @return string Raw HTML */ - public static function rawElement( $element, $attribs = array(), $contents = '' ) { + public static function rawElement( $element, $attribs = [], $contents = '' ) { global $wgWellFormedXml; $start = self::openElement( $element, $attribs ); if ( in_array( $element, self::$voidElements ) ) { @@ -234,13 +234,13 @@ class Html { * * @return string */ - public static function element( $element, $attribs = array(), $contents = '' ) { - return self::rawElement( $element, $attribs, strtr( $contents, array( + public static function element( $element, $attribs = [], $contents = '' ) { + return self::rawElement( $element, $attribs, strtr( $contents, [ // There's no point in escaping quotes, >, etc. in the contents of // elements. '&' => '&', '<' => '<' - ) ) ); + ] ) ); } /** @@ -252,7 +252,7 @@ class Html { * * @return string */ - public static function openElement( $element, $attribs = array() ) { + public static function openElement( $element, $attribs = [] ) { $attribs = (array)$attribs; // This is not required in HTML5, but let's do it anyway, for // consistency and better compression. @@ -260,7 +260,7 @@ class Html { // Remove invalid input types if ( $element == 'input' ) { - $validTypes = array( + $validTypes = [ 'hidden', 'text', 'password', @@ -286,7 +286,7 @@ class Html { 'search', 'tel', 'color', - ); + ]; if ( isset( $attribs['type'] ) && !in_array( $attribs['type'], $validTypes ) ) { unset( $attribs['type'] ); } @@ -336,36 +336,36 @@ class Html { private static function dropDefaults( $element, array $attribs ) { // Whenever altering this array, please provide a covering test case // in HtmlTest::provideElementsWithAttributesHavingDefaultValues - static $attribDefaults = array( - 'area' => array( 'shape' => 'rect' ), - 'button' => array( + static $attribDefaults = [ + 'area' => [ 'shape' => 'rect' ], + 'button' => [ 'formaction' => 'GET', 'formenctype' => 'application/x-www-form-urlencoded', - ), - 'canvas' => array( + ], + 'canvas' => [ 'height' => '150', 'width' => '300', - ), - 'command' => array( 'type' => 'command' ), - 'form' => array( + ], + 'command' => [ 'type' => 'command' ], + 'form' => [ 'action' => 'GET', 'autocomplete' => 'on', 'enctype' => 'application/x-www-form-urlencoded', - ), - 'input' => array( + ], + 'input' => [ 'formaction' => 'GET', 'type' => 'text', - ), - 'keygen' => array( 'keytype' => 'rsa' ), - 'link' => array( 'media' => 'all' ), - 'menu' => array( 'type' => 'list' ), - 'script' => array( 'type' => 'text/javascript' ), - 'style' => array( + ], + 'keygen' => [ 'keytype' => 'rsa' ], + 'link' => [ 'media' => 'all' ], + 'menu' => [ 'type' => 'list' ], + 'script' => [ 'type' => 'text/javascript' ], + 'style' => [ 'media' => 'all', 'type' => 'text/css', - ), - 'textarea' => array( 'wrap' => 'soft' ), - ); + ], + 'textarea' => [ 'wrap' => 'soft' ], + ]; $element = strtolower( $element ); @@ -509,21 +509,21 @@ class Html { // numbers to be entered in 'type="number"' fields, allow // the special case 'step="any"'. - if ( in_array( $key, array( 'max', 'min', 'pattern', 'required' ) ) + if ( in_array( $key, [ 'max', 'min', 'pattern', 'required' ] ) || $key === 'step' && $value !== 'any' ) { continue; } // http://www.w3.org/TR/html401/index/attributes.html ("space-separated") // http://www.w3.org/TR/html5/index.html#attributes-1 ("space-separated") - $spaceSeparatedListAttributes = array( + $spaceSeparatedListAttributes = [ 'class', // html4, html5 'accesskey', // as of html5, multiple space-separated values allowed // html4-spec doesn't document rel= as space-separated // but has been used like that and is now documented as such // in the html5-spec. 'rel', - ); + ]; // Specific features for attributes that allow a list of space-separated values if ( in_array( $key, $spaceSeparatedListAttributes ) ) { @@ -533,7 +533,7 @@ class Html { // values. Implode/explode to get those into the main array as well. if ( is_array( $value ) ) { // If input wasn't an array, we can skip this step - $newValue = array(); + $newValue = []; foreach ( $value as $k => $v ) { if ( is_string( $v ) ) { // String values should be normal `array( 'foo' )` @@ -556,7 +556,7 @@ class Html { // Normalize spacing by fixing up cases where people used // more than 1 space and/or a trailing/leading space - $value = array_diff( $value, array( '', ' ' ) ); + $value = array_diff( $value, [ '', ' ' ] ); // Remove duplicates and create the string $value = implode( ' ', array_unique( $value ) ); @@ -601,14 +601,14 @@ class Html { // The only difference between this transform and the one by // Sanitizer::encodeAttribute() is '<' is only encoded here if // $wgWellFormedXml is set, and ' is not encoded. - $map = array( + $map = [ '&' => '&', '"' => '"', '>' => '>', "\n" => ' ', "\r" => ' ', "\t" => ' ' - ); + ]; if ( $wgWellFormedXml ) { // This is allowed per spec: // But reportedly it breaks some XML tools? @@ -633,7 +633,7 @@ class Html { public static function inlineScript( $contents ) { global $wgWellFormedXml; - $attrs = array(); + $attrs = []; if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) { $contents = "/**/"; @@ -650,7 +650,7 @@ class Html { * @return string Raw HTML */ public static function linkedScript( $url ) { - $attrs = array( 'src' => $url ); + $attrs = [ 'src' => $url ]; return self::element( 'script', $attrs ); } @@ -671,9 +671,9 @@ class Html { $contents = "/**/"; } - return self::rawElement( 'style', array( + return self::rawElement( 'style', [ 'media' => $media, - ), $contents ); + ], $contents ); } /** @@ -685,11 +685,11 @@ class Html { * @return string Raw HTML */ public static function linkedStyle( $url, $media = 'all' ) { - return self::element( 'link', array( + return self::element( 'link', [ 'rel' => 'stylesheet', 'href' => $url, 'media' => $media, - ) ); + ] ); } /** @@ -703,14 +703,14 @@ class Html { * attributes, passed to Html::element() * @return string Raw HTML */ - public static function input( $name, $value = '', $type = 'text', array $attribs = array() ) { + public static function input( $name, $value = '', $type = 'text', array $attribs = [] ) { $attribs['type'] = $type; $attribs['value'] = $value; $attribs['name'] = $name; - if ( in_array( $type, array( 'text', 'search', 'email', 'password', 'number' ) ) ) { + if ( in_array( $type, [ 'text', 'search', 'email', 'password', 'number' ] ) ) { $attribs = self::getTextInputAttributes( $attribs ); } - if ( in_array( $type, array( 'button', 'reset', 'submit' ) ) ) { + if ( in_array( $type, [ 'button', 'reset', 'submit' ] ) ) { $attribs = self::buttonAttributes( $attribs ); } return self::element( 'input', $attribs ); @@ -724,7 +724,7 @@ class Html { * @param array $attribs Array of additional attributes * @return string Raw HTML */ - public static function check( $name, $checked = false, array $attribs = array() ) { + public static function check( $name, $checked = false, array $attribs = [] ) { if ( isset( $attribs['value'] ) ) { $value = $attribs['value']; unset( $attribs['value'] ); @@ -747,7 +747,7 @@ class Html { * @param array $attribs Array of additional attributes * @return string Raw HTML */ - public static function radio( $name, $checked = false, array $attribs = array() ) { + public static function radio( $name, $checked = false, array $attribs = [] ) { if ( isset( $attribs['value'] ) ) { $value = $attribs['value']; unset( $attribs['value'] ); @@ -770,10 +770,10 @@ class Html { * @param array $attribs Additional attributes * @return string Raw HTML */ - public static function label( $label, $id, array $attribs = array() ) { - $attribs += array( + public static function label( $label, $id, array $attribs = [] ) { + $attribs += [ 'for' => $id - ); + ]; return self::element( 'label', $attribs, $label ); } @@ -786,7 +786,7 @@ class Html { * attributes, passed to Html::element() * @return string Raw HTML */ - public static function hidden( $name, $value, array $attribs = array() ) { + public static function hidden( $name, $value, array $attribs = [] ) { return self::input( $name, $value, 'hidden', $attribs ); } @@ -802,7 +802,7 @@ class Html { * attributes, passed to Html::element() * @return string Raw HTML */ - public static function textarea( $name, $value = '', array $attribs = array() ) { + public static function textarea( $name, $value = '', array $attribs = [] ) { $attribs['name'] = $name; if ( substr( $value, 0, 1 ) == "\n" ) { @@ -822,13 +822,13 @@ class Html { * @param array $params See Html::namespaceSelector() * @return array */ - public static function namespaceSelectorOptions( array $params = array() ) { + public static function namespaceSelectorOptions( array $params = [] ) { global $wgContLang; - $options = array(); + $options = []; if ( !isset( $params['exclude'] ) || !is_array( $params['exclude'] ) ) { - $params['exclude'] = array(); + $params['exclude'] = []; } if ( isset( $params['all'] ) ) { @@ -839,7 +839,7 @@ class Html { // Add all namespaces as options (in the content language) $options += $wgContLang->getFormattedNamespaces(); - $optionsOut = array(); + $optionsOut = []; // Filter out namespaces below 0 and massage labels foreach ( $options as $nsId => $nsName ) { if ( $nsId < NS_MAIN || in_array( $nsId, $params['exclude'] ) ) { @@ -874,8 +874,8 @@ class Html { * - name: [optional], default: 'namespace'. * @return string HTML code to select a namespace. */ - public static function namespaceSelector( array $params = array(), - array $selectAttribs = array() + public static function namespaceSelector( array $params = [], + array $selectAttribs = [] ) { ksort( $selectAttribs ); @@ -894,21 +894,21 @@ class Html { } if ( !isset( $params['disable'] ) || !is_array( $params['disable'] ) ) { - $params['disable'] = array(); + $params['disable'] = []; } // Associative array between option-values and option-labels $options = self::namespaceSelectorOptions( $params ); // Convert $options to HTML - $optionsHtml = array(); + $optionsHtml = []; foreach ( $options as $nsId => $nsName ) { $optionsHtml[] = self::element( - 'option', array( + 'option', [ 'disabled' => in_array( $nsId, $params['disable'] ), 'value' => $nsId, 'selected' => $nsId === $params['selected'], - ), $nsName + ], $nsName ); } @@ -923,9 +923,9 @@ class Html { $ret = ''; if ( isset( $params['label'] ) ) { $ret .= self::element( - 'label', array( + 'label', [ 'for' => isset( $selectAttribs['id'] ) ? $selectAttribs['id'] : null, - ), $params['label'] + ], $params['label'] ) . ' '; } @@ -947,7 +947,7 @@ class Html { * attributes, passed to Html::element() of html tag. * @return string Raw HTML */ - public static function htmlHeader( array $attribs = array() ) { + public static function htmlHeader( array $attribs = [] ) { $ret = ''; global $wgHtml5Version, $wgMimeType, $wgXhtmlNamespaces; @@ -1011,25 +1011,25 @@ class Html { * @return string */ static function infoBox( $text, $icon, $alt, $class = '' ) { - $s = self::openElement( 'div', array( 'class' => "mw-infobox $class" ) ); + $s = self::openElement( 'div', [ 'class' => "mw-infobox $class" ] ); - $s .= self::openElement( 'div', array( 'class' => 'mw-infobox-left' ) ) . + $s .= self::openElement( 'div', [ 'class' => 'mw-infobox-left' ] ) . self::element( 'img', - array( + [ 'src' => $icon, 'alt' => $alt, - ) + ] ) . self::closeElement( 'div' ); - $s .= self::openElement( 'div', array( 'class' => 'mw-infobox-right' ) ) . + $s .= self::openElement( 'div', [ 'class' => 'mw-infobox-right' ] ) . $text . self::closeElement( 'div' ); - $s .= self::element( 'div', array( 'style' => 'clear: left;' ), ' ' ); + $s .= self::element( 'div', [ 'style' => 'clear: left;' ], ' ' ); $s .= self::closeElement( 'div' ); - $s .= self::element( 'div', array( 'style' => 'clear: left;' ), ' ' ); + $s .= self::element( 'div', [ 'style' => 'clear: left;' ], ' ' ); return $s; } @@ -1058,7 +1058,7 @@ class Html { * @return string */ static function srcSet( array $urls ) { - $candidates = array(); + $candidates = []; foreach ( $urls as $density => $url ) { // Cast density to float to strip 'x'. $candidates[] = $url . ' ' . (float)$density . 'x'; diff --git a/includes/HtmlFormatter.php b/includes/HtmlFormatter.php index 2d81b28242..5b8122dcca 100644 --- a/includes/HtmlFormatter.php +++ b/includes/HtmlFormatter.php @@ -27,8 +27,8 @@ class HtmlFormatter { private $doc; private $html; - private $itemsToRemove = array(); - private $elementsToFlatten = array(); + private $itemsToRemove = []; + private $elementsToFlatten = []; protected $removeMedia = false; /** @@ -148,7 +148,7 @@ class HtmlFormatter { }, true ) ) { - return array(); + return []; } $doc = $this->getDoc(); @@ -159,7 +159,7 @@ class HtmlFormatter { // over them in a foreach loop. It will seemingly leave the internal // iterator on the foreach out of wack and results will be quite // strange. Though, making a queue of items to remove seems to work. - $domElemsToRemove = array(); + $domElemsToRemove = []; foreach ( $removals['TAG'] as $tagToRemove ) { $tagToRemoveNodes = $doc->getElementsByTagName( $tagToRemove ); foreach ( $tagToRemoveNodes as $tagToRemoveNode ) { @@ -171,7 +171,7 @@ class HtmlFormatter { $removed = $this->removeElements( $domElemsToRemove ); // Elements with named IDs - $domElemsToRemove = array(); + $domElemsToRemove = []; foreach ( $removals['ID'] as $itemToRemove ) { $itemToRemoveNode = $doc->getElementById( $itemToRemove ); if ( $itemToRemoveNode ) { @@ -181,7 +181,7 @@ class HtmlFormatter { $removed = array_merge( $removed, $this->removeElements( $domElemsToRemove ) ); // CSS Classes - $domElemsToRemove = array(); + $domElemsToRemove = []; $xpath = new DOMXPath( $doc ); foreach ( $removals['CLASS'] as $classToRemove ) { $elements = $xpath->query( '//*[contains(@class, "' . $classToRemove . '")]' ); @@ -217,7 +217,7 @@ class HtmlFormatter { private function removeElements( $elements ) { $list = $elements; if ( $elements instanceof DOMNodeList ) { - $list = array(); + $list = []; foreach ( $elements as $element ) { $list[] = $element; } @@ -242,12 +242,12 @@ class HtmlFormatter { if ( !$replacements ) { // We don't include rules like '"' => '&quot;' because entities had already been // normalized by libxml. Using this function with input not sanitized by libxml is UNSAFE! - $replacements = new ReplacementArray( array( + $replacements = new ReplacementArray( [ '"' => '&quot;', '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', - ) ); + ] ); } $html = $replacements->replace( $html ); @@ -279,7 +279,7 @@ class HtmlFormatter { } if ( $element ) { $body = $this->doc->getElementsByTagName( 'body' )->item( 0 ); - $nodesArray = array(); + $nodesArray = []; foreach ( $body->childNodes as $node ) { $nodesArray[] = $node; } @@ -349,12 +349,12 @@ class HtmlFormatter { * @return array */ protected function parseItemsToRemove() { - $removals = array( - 'ID' => array(), - 'TAG' => array(), - 'CLASS' => array(), - 'TAG_CLASS' => array(), - ); + $removals = [ + 'ID' => [], + 'TAG' => [], + 'CLASS' => [], + 'TAG_CLASS' => [], + ]; foreach ( $this->itemsToRemove as $itemToRemove ) { $type = ''; diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index e1cd5c72fc..600bd7969b 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -60,7 +60,7 @@ class Http { * @param string $caller The method making this request, for profiling * @return string|bool (bool)false on failure or a string on success */ - public static function request( $method, $url, $options = array(), $caller = __METHOD__ ) { + public static function request( $method, $url, $options = [], $caller = __METHOD__ ) { wfDebug( "HTTP: $method: $url\n" ); $options['method'] = strtoupper( $method ); @@ -81,7 +81,7 @@ class Http { $errors = $status->getErrorsByType( 'error' ); $logger = LoggerFactory::getInstance( 'http' ); $logger->warning( $status->getWikiText(), - array( 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ) ); + [ 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ] ); return false; } } @@ -97,14 +97,14 @@ class Http { * @param string $caller The method making this request, for profiling * @return string|bool false on error */ - public static function get( $url, $options = array(), $caller = __METHOD__ ) { + public static function get( $url, $options = [], $caller = __METHOD__ ) { $args = func_get_args(); if ( isset( $args[1] ) && ( is_string( $args[1] ) || is_numeric( $args[1] ) ) ) { // Second was used to be the timeout // And third parameter used to be $options wfWarn( "Second parameter should not be a timeout.", 2 ); $options = isset( $args[2] ) && is_array( $args[2] ) ? - $args[2] : array(); + $args[2] : []; $options['timeout'] = $args[1]; $caller = __METHOD__; } @@ -120,7 +120,7 @@ class Http { * @param string $caller The method making this request, for profiling * @return string|bool false on error */ - public static function post( $url, $options = array(), $caller = __METHOD__ ) { + public static function post( $url, $options = [], $caller = __METHOD__ ) { return Http::request( 'POST', $url, $options, $caller ); } @@ -138,7 +138,7 @@ class Http { } // Extract host part - $matches = array(); + $matches = []; if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) { $host = $matches[1]; // Split up dotwise @@ -214,7 +214,7 @@ class MWHttpRequest { protected $sslVerifyCert = true; protected $caInfo = null; protected $method = "GET"; - protected $reqHeaders = array(); + protected $reqHeaders = []; protected $url; protected $parsedUrl; protected $callback; @@ -226,10 +226,10 @@ class MWHttpRequest { */ protected $cookieJar; - protected $headerList = array(); + protected $headerList = []; protected $respVersion = "0.9"; protected $respStatus = "200 Ok"; - protected $respHeaders = array(); + protected $respHeaders = []; public $status; @@ -250,7 +250,7 @@ class MWHttpRequest { * @param Profiler $profiler An instance of the profiler for profiling, or null */ protected function __construct( - $url, $options = array(), $caller = __METHOD__, $profiler = null + $url, $options = [], $caller = __METHOD__, $profiler = null ) { global $wgHTTPTimeout, $wgHTTPConnectTimeout; @@ -277,8 +277,8 @@ class MWHttpRequest { $this->setUserAgent( $options['userAgent'] ); } - $members = array( "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo", - "method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ); + $members = [ "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo", + "method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ]; foreach ( $members as $o ) { if ( isset( $options[$o] ) ) { @@ -409,7 +409,7 @@ class MWHttpRequest { * @return array */ public function getHeaderList() { - $list = array(); + $list = []; if ( $this->cookieJar ) { $this->reqHeaders['Cookie'] = @@ -480,7 +480,7 @@ class MWHttpRequest { $this->proxySetup(); // set up any proxy as needed if ( !$this->callback ) { - $this->setCallback( array( $this, 'read' ) ); + $this->setCallback( [ $this, 'read' ] ); } if ( !isset( $this->reqHeaders['User-Agent'] ) ) { @@ -731,7 +731,7 @@ class MWHttpRequest { class CurlHttpRequest extends MWHttpRequest { const SUPPORTS_FILE_POSTS = true; - protected $curlOptions = array(); + protected $curlOptions = []; protected $headerText = ""; /** @@ -762,7 +762,7 @@ class CurlHttpRequest extends MWHttpRequest { $this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; $this->curlOptions[CURLOPT_WRITEFUNCTION] = $this->callback; - $this->curlOptions[CURLOPT_HEADERFUNCTION] = array( $this, "readHeader" ); + $this->curlOptions[CURLOPT_HEADERFUNCTION] = [ $this, "readHeader" ]; $this->curlOptions[CURLOPT_MAXREDIRS] = $this->maxRedirects; $this->curlOptions[CURLOPT_ENCODING] = ""; # Enable compression @@ -873,7 +873,7 @@ class CurlHttpRequest extends MWHttpRequest { class PhpHttpRequest extends MWHttpRequest { - private $fopenErrors = array(); + private $fopenErrors = []; /** * @param string $url @@ -895,10 +895,10 @@ class PhpHttpRequest extends MWHttpRequest { * @throws DomainException */ protected function getCertOptions() { - $certOptions = array(); - $certLocations = array(); + $certOptions = []; + $certLocations = []; if ( $this->caInfo ) { - $certLocations = array( 'manual' => $this->caInfo ); + $certLocations = [ 'manual' => $this->caInfo ]; } elseif ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) { // @codingStandardsIgnoreStart Generic.Files.LineLength // Default locations, based on @@ -907,7 +907,7 @@ class PhpHttpRequest extends MWHttpRequest { // PHP 5.6+ gets the CA location from OpenSSL as long as it is not set manually, // so we should leave capath/cafile empty there. // @codingStandardsIgnoreEnd - $certLocations = array_filter( array( + $certLocations = array_filter( [ getenv( 'SSL_CERT_DIR' ), getenv( 'SSL_CERT_PATH' ), '/etc/pki/tls/certs/ca-bundle.crt', # Fedora et al @@ -915,7 +915,7 @@ class PhpHttpRequest extends MWHttpRequest { '/etc/pki/tls/certs/ca-bundle.trust.crt', '/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem', '/System/Library/OpenSSL', # OSX - ) ); + ] ); } foreach ( $certLocations as $key => $cert ) { @@ -943,7 +943,7 @@ class PhpHttpRequest extends MWHttpRequest { */ public function errorHandler( $errno, $errstr ) { $n = count( $this->fopenErrors ) + 1; - $this->fopenErrors += array( "errno$n" => $errno, "errstr$n" => $errstr ); + $this->fopenErrors += [ "errno$n" => $errno, "errstr$n" => $errstr ]; } public function execute() { @@ -970,8 +970,8 @@ class PhpHttpRequest extends MWHttpRequest { } // Set up PHP stream context - $options = array( - 'http' => array( + $options = [ + 'http' => [ 'method' => $this->method, 'header' => implode( "\r\n", $this->getHeaderList() ), 'protocol_version' => '1.1', @@ -981,14 +981,14 @@ class PhpHttpRequest extends MWHttpRequest { // Curl options in case curlwrappers are installed 'curl_verify_ssl_host' => $this->sslVerifyHost ? 2 : 0, 'curl_verify_ssl_peer' => $this->sslVerifyCert, - ), - 'ssl' => array( + ], + 'ssl' => [ 'verify_peer' => $this->sslVerifyCert, 'SNI_enabled' => true, 'ciphers' => 'HIGH:!SSLv2:!SSLv3:-ADH:-kDH:-kECDH:-DSS', 'disable_compression' => true, - ), - ); + ], + ]; if ( $this->proxy ) { $options['http']['proxy'] = $this->urlToTCP( $this->proxy ); @@ -1013,11 +1013,11 @@ class PhpHttpRequest extends MWHttpRequest { $context = stream_context_create( $options ); - $this->headerList = array(); + $this->headerList = []; $reqCount = 0; $url = $this->url; - $result = array(); + $result = []; if ( $this->profiler ) { $profileSection = $this->profiler->scopedProfileIn( @@ -1026,8 +1026,8 @@ class PhpHttpRequest extends MWHttpRequest { } do { $reqCount++; - $this->fopenErrors = array(); - set_error_handler( array( $this, 'errorHandler' ) ); + $this->fopenErrors = []; + set_error_handler( [ $this, 'errorHandler' ] ); $fh = fopen( $url, "r", false, $context ); restore_error_handler(); diff --git a/includes/Licenses.php b/includes/Licenses.php index 0bcbc91b22..da1a8da6b0 100644 --- a/includes/Licenses.php +++ b/includes/Licenses.php @@ -32,7 +32,7 @@ class Licenses extends HTMLFormField { protected $msg; /** @var array */ - protected $licenses = array(); + protected $licenses = []; /** @var string */ protected $html; @@ -56,7 +56,7 @@ class Licenses extends HTMLFormField { * @private */ protected function makeLicenses() { - $levels = array(); + $levels = []; $lines = explode( "\n", $this->msg ); foreach ( $lines as $line ) { @@ -88,7 +88,7 @@ class Licenses extends HTMLFormField { */ protected function trimStars( $str ) { $numStars = strspn( $str, '*' ); - return array( $numStars, ltrim( substr( $str, $numStars ), ' ' ) ); + return [ $numStars, ltrim( substr( $str, $numStars ), ' ' ) ]; } /** @@ -115,17 +115,17 @@ class Licenses extends HTMLFormField { if ( is_array( $val ) ) { $this->html .= $this->outputOption( $key, '', - array( + [ 'disabled' => 'disabled', 'style' => 'color: GrayText', // for MSIE - ), + ], $depth ); $this->makeHtml( $val, $depth + 1 ); } else { $this->html .= $this->outputOption( $val->text, $val->template, - array( 'title' => '{{' . $val->template . '}}' ), + [ 'title' => '{{' . $val->template . '}}' ], $depth ); } @@ -173,13 +173,13 @@ class Licenses extends HTMLFormField { $this->selected = $value; $this->html = $this->outputOption( wfMessage( 'nolicense' )->text(), '', - (bool)$this->selected ? null : array( 'selected' => 'selected' ) ); + (bool)$this->selected ? null : [ 'selected' => 'selected' ] ); $this->makeHtml( $this->getLicenses() ); - $attribs = array( + $attribs = [ 'name' => $this->mName, 'id' => $this->mID - ); + ]; if ( !empty( $this->mParams['disabled'] ) ) { $attibs['disabled'] = 'disabled'; } diff --git a/includes/Linker.php b/includes/Linker.php index f0a2963cbb..8e79d9c38e 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -192,7 +192,7 @@ class Linker { * @return string HTML attribute */ public static function link( - $target, $html = null, $customAttribs = array(), $query = array(), $options = array() + $target, $html = null, $customAttribs = [], $query = [], $options = [] ) { if ( !$target instanceof Title ) { wfWarn( __METHOD__ . ': Requires $target to be a Title object.', 2 ); @@ -210,7 +210,7 @@ class Linker { $ret = null; if ( !Hooks::run( 'LinkBegin', - array( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) ) + [ $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ] ) ) { return $ret; } @@ -227,14 +227,14 @@ class Linker { } } - $oldquery = array(); + $oldquery = []; if ( in_array( "forcearticlepath", $options, true ) && $query ) { $oldquery = $query; - $query = array(); + $query = []; } # Note: we want the href attribute first, for prettiness. - $attribs = array( 'href' => self::linkUrl( $target, $query, $options ) ); + $attribs = [ 'href' => self::linkUrl( $target, $query, $options ) ]; if ( in_array( 'forcearticlepath', $options, true ) && $oldquery ) { $attribs['href'] = wfAppendQuery( $attribs['href'], $oldquery ); } @@ -248,7 +248,7 @@ class Linker { } $ret = null; - if ( Hooks::run( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) { + if ( Hooks::run( 'LinkEnd', [ $dummy, $target, $options, &$html, &$attribs, &$ret ] ) ) { $ret = Html::rawElement( 'a', $attribs, $html ); } @@ -261,8 +261,8 @@ class Linker { * @return string */ public static function linkKnown( - $target, $html = null, $customAttribs = array(), - $query = array(), $options = array( 'known', 'noclasses' ) + $target, $html = null, $customAttribs = [], + $query = [], $options = [ 'known', 'noclasses' ] ) { return self::link( $target, $html, $customAttribs, $query, $options ); } @@ -315,11 +315,11 @@ class Linker { */ private static function linkAttribs( $target, $attribs, $options ) { global $wgUser; - $defaults = array(); + $defaults = []; if ( !in_array( 'noclasses', $options, true ) ) { # Now build the classes. - $classes = array(); + $classes = []; if ( in_array( 'broken', $options, true ) ) { $classes[] = 'new'; @@ -338,7 +338,7 @@ class Linker { $classes[] = $colour; # mw-redirect or stub } } - if ( $classes != array() ) { + if ( $classes != [] ) { $defaults['class'] = implode( ' ', $classes ); } } @@ -358,7 +358,7 @@ class Linker { # Finally, merge the custom attribs with the default ones, and iterate # over that, deleting all "false" attributes. - $ret = array(); + $ret = []; $merged = Sanitizer::mergeAttributes( $defaults, $attribs ); foreach ( $merged as $key => $val ) { # A false value suppresses the attribute, and we don't want the @@ -407,7 +407,7 @@ class Linker { */ public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) { $ret = "{$prefix}{$html}{$trail}"; - if ( !Hooks::run( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) { + if ( !Hooks::run( 'SelfLinkBegin', [ $nt, &$html, &$trail, &$prefix, &$ret ] ) ) { return $ret; } @@ -493,16 +493,16 @@ class Linker { $alt = self::fnamePart( $url ); } $img = ''; - $success = Hooks::run( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) ); + $success = Hooks::run( 'LinkerMakeExternalImage', [ &$url, &$alt, &$img ] ); if ( !$success ) { wfDebug( "Hook LinkerMakeExternalImage changed the output of external image " . "with url {$url} and alt text {$alt} to {$img}\n", true ); return $img; } return Html::element( 'img', - array( + [ 'src' => $url, - 'alt' => $alt ) ); + 'alt' => $alt ] ); } /** @@ -542,13 +542,13 @@ class Linker { * @return string HTML for an image, with links, wrappers, etc. */ public static function makeImageLink( Parser $parser, Title $title, - $file, $frameParams = array(), $handlerParams = array(), $time = false, + $file, $frameParams = [], $handlerParams = [], $time = false, $query = "", $widthOption = null ) { $res = null; $dummy = new DummyLinker; - if ( !Hooks::run( 'ImageBeforeProduceHTML', array( &$dummy, &$title, - &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) { + if ( !Hooks::run( 'ImageBeforeProduceHTML', [ &$dummy, &$title, + &$file, &$frameParams, &$handlerParams, &$time, &$res ] ) ) { return $res; } @@ -659,11 +659,11 @@ class Linker { $s = self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true ); } else { self::processResponsiveImages( $file, $thumb, $hp ); - $params = array( + $params = [ 'alt' => $fp['alt'], 'title' => $fp['title'], 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false, - 'img-class' => $fp['class'] ); + 'img-class' => $fp['class'] ]; if ( isset( $fp['border'] ) ) { $params['img-class'] .= ( $params['img-class'] !== '' ? ' ' : '' ) . 'thumbborder'; } @@ -686,7 +686,7 @@ class Linker { * @return array */ private static function getImageLinkMTOParams( $frameParams, $query = '', $parser = null ) { - $mtoParams = array(); + $mtoParams = []; if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) { $mtoParams['custom-url-link'] = $frameParams['link-url']; if ( isset( $frameParams['link-target'] ) ) { @@ -723,13 +723,13 @@ class Linker { * @return string */ public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt, - $align = 'right', $params = array(), $framed = false, $manualthumb = "" + $align = 'right', $params = [], $framed = false, $manualthumb = "" ) { - $frameParams = array( + $frameParams = [ 'alt' => $alt, 'caption' => $label, 'align' => $align - ); + ]; if ( $framed ) { $frameParams['framed'] = true; } @@ -748,8 +748,8 @@ class Linker { * @param string $query * @return string */ - public static function makeThumbLink2( Title $title, $file, $frameParams = array(), - $handlerParams = array(), $time = false, $query = "" + public static function makeThumbLink2( Title $title, $file, $frameParams = [], + $handlerParams = [], $time = false, $query = "" ) { $exists = $file && $file->exists(); @@ -820,7 +820,7 @@ class Linker { # zoom icon still needs it, so we make a unique query for it. See bug 14771 $url = $title->getLocalURL( $query ); if ( $page ) { - $url = wfAppendQuery( $url, array( 'page' => $page ) ); + $url = wfAppendQuery( $url, [ 'page' => $page ] ); } if ( $manualthumb && !isset( $fp['link-title'] ) @@ -842,23 +842,23 @@ class Linker { if ( !$noscale && !$manualthumb ) { self::processResponsiveImages( $file, $thumb, $hp ); } - $params = array( + $params = [ 'alt' => $fp['alt'], 'title' => $fp['title'], 'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ? $fp['class'] . ' ' : '' ) . 'thumbimage' - ); + ]; $params = self::getImageLinkMTOParams( $fp, $query ) + $params; $s .= $thumb->toHtml( $params ); if ( isset( $fp['framed'] ) ) { $zoomIcon = ""; } else { - $zoomIcon = Html::rawElement( 'div', array( 'class' => 'magnify' ), - Html::rawElement( 'a', array( + $zoomIcon = Html::rawElement( 'div', [ 'class' => 'magnify' ], + Html::rawElement( 'a', [ 'href' => $url, 'class' => 'internal', - 'title' => wfMessage( 'thumbnail-more' )->text() ), + 'title' => wfMessage( 'thumbnail-more' )->text() ], "" ) ); } } @@ -929,7 +929,7 @@ class Linker { $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ); if ( $redir ) { - return self::linkKnown( $title, $encLabel, array(), wfCgiToArray( $query ) ); + return self::linkKnown( $title, $encLabel, [], wfCgiToArray( $query ) ); } $href = self::getUploadUrl( $title, $query ); @@ -939,7 +939,7 @@ class Linker { $encLabel . ''; } - return self::linkKnown( $title, $encLabel, array(), wfCgiToArray( $query ) ); + return self::linkKnown( $title, $encLabel, [], wfCgiToArray( $query ) ); } /** @@ -975,7 +975,7 @@ class Linker { * @return string HTML */ public static function makeMediaLinkObj( $title, $html = '', $time = false ) { - $img = wfFindFile( $title, array( 'time' => $time ) ); + $img = wfFindFile( $title, [ 'time' => $time ] ); return self::makeMediaLinkFile( $title, $img, $html ); } @@ -1005,14 +1005,14 @@ class Linker { } $ret = ''; - $attribs = array( + $attribs = [ 'href' => $url, 'class' => $class, 'title' => $alt - ); + ]; if ( !Hooks::run( 'LinkerMakeMediaLinkFile', - array( $title, $file, &$html, &$attribs, &$ret ) ) ) { + [ $title, $file, &$html, &$attribs, &$ret ] ) ) { wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link " . "with url {$url} and text {$html} to {$ret}\n", true ); return $ret; @@ -1049,7 +1049,7 @@ class Linker { * @return string */ public static function makeExternalLink( $url, $text, $escape = true, - $linktype = '', $attribs = array(), $title = null + $linktype = '', $attribs = [], $title = null ) { global $wgTitle; $class = "external"; @@ -1071,7 +1071,7 @@ class Linker { $attribs['rel'] = Parser::getExternalLinkRel( $url, $title ); $link = ''; $success = Hooks::run( 'LinkerMakeExternalLink', - array( &$url, &$text, &$link, &$attribs, $linktype ) ); + [ &$url, &$text, &$link, &$attribs, $linktype ] ); if ( !$success ) { wfDebug( "Hook LinkerMakeExternalLink changed the output of link " . "with url {$url} and text {$text} to {$link}\n", true ); @@ -1104,7 +1104,7 @@ class Linker { return self::link( $page, htmlspecialchars( $altUserName !== false ? $altUserName : $userName ), - array( 'class' => $classes ) + [ 'class' => $classes ] ); } @@ -1128,13 +1128,13 @@ class Linker { $blockable = !( $flags & self::TOOL_LINKS_NOBLOCK ); $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId; - $items = array(); + $items = []; if ( $talkable ) { $items[] = self::userTalkLink( $userId, $userText ); } if ( $userId ) { // check if the user has an edit - $attribs = array(); + $attribs = []; if ( $redContribsWhenNoEdits ) { if ( intval( $edits ) === 0 && $edits !== 0 ) { $user = User::newFromId( $userId ); @@ -1156,7 +1156,7 @@ class Linker { $items[] = self::emailLink( $userId, $userText ); } - Hooks::run( 'UserToolLinksEdit', array( $userId, $userText, &$items ) ); + Hooks::run( 'UserToolLinksEdit', [ $userId, $userText, &$items ] ); if ( $items ) { return wfMessage( 'word-separator' )->escaped() @@ -1329,7 +1329,7 @@ class Linker { global $wgLang; // Ensure all match positions are defined - $match += array( '', '', '', '' ); + $match += [ '', '', '', '' ]; $pre = $match[1] !== ''; $auto = $match[2]; @@ -1338,7 +1338,7 @@ class Linker { Hooks::run( 'FormatAutocomments', - array( &$comment, $pre, $auto, $post, $title, $local, $wikiId ) + [ &$comment, $pre, $auto, $post, $title, $local, $wikiId ] ); if ( $comment === null ) { @@ -1428,7 +1428,7 @@ class Linker { if ( strpos( $match[1], '%' ) !== false ) { $match[1] = strtr( rawurldecode( $match[1] ), - array( '<' => '<', '>' => '>' ) + [ '<' => '<', '>' => '>' ] ); } @@ -1438,7 +1438,7 @@ class Linker { } else { $text = $match[1]; } - $submatch = array(); + $submatch = []; $thelink = null; if ( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) { # Media link; trail not supported. @@ -1506,7 +1506,7 @@ class Linker { * @return string HTML link */ public static function makeCommentLink( - Title $title, $text, $wikiId = null, $options = array() + Title $title, $text, $wikiId = null, $options = [] ) { if ( $wikiId !== null && !$title->isExternal() ) { $link = Linker::makeExternalLink( @@ -1519,7 +1519,7 @@ class Linker { /* escape = */ false // Already escaped ); } else { - $link = Linker::link( $title, $text, array(), array(), $options ); + $link = Linker::link( $title, $text, [], [], $options ); } return $link; @@ -1560,7 +1560,7 @@ class Linker { # Look at the first character if ( $target != '' && $target[0] === '/' ) { # / at end means we don't want the slash to be shown - $m = array(); + $m = []; $trailingSlashes = preg_match_all( '%(/+)$%', $target, $m ); if ( $trailingSlashes ) { $noslash = $target = substr( $target, 1, -strlen( $m[0][0] ) ); @@ -1807,13 +1807,13 @@ class Linker { $regex = $wgContLang->linkTrail(); $inside = ''; if ( $trail !== '' ) { - $m = array(); + $m = []; if ( preg_match( $regex, $trail, $m ) ) { $inside = $m[1]; $trail = $m[2]; } } - return array( $inside, $trail ); + return [ $inside, $trail ]; } /** @@ -1842,7 +1842,7 @@ class Linker { * @return string */ public static function generateRollback( $rev, IContextSource $context = null, - $options = array( 'verify' ) + $options = [ 'verify' ] ) { if ( $context === null ) { $context = RequestContext::getMain(); @@ -1892,15 +1892,15 @@ class Linker { // Up to the value of $wgShowRollbackEditCount revisions are counted $res = $dbr->select( 'revision', - array( 'rev_user_text', 'rev_deleted' ), + [ 'rev_user_text', 'rev_deleted' ], // $rev->getPage() returns null sometimes - array( 'rev_page' => $rev->getTitle()->getArticleID() ), + [ 'rev_page' => $rev->getTitle()->getArticleID() ], __METHOD__, - array( - 'USE INDEX' => array( 'revision' => 'page_timestamp' ), + [ + 'USE INDEX' => [ 'revision' => 'page_timestamp' ], 'ORDER BY' => 'rev_timestamp DESC', 'LIMIT' => $wgShowRollbackEditCount + 1 - ) + ] ); $editCount = 0; @@ -1945,21 +1945,21 @@ class Linker { global $wgShowRollbackEditCount, $wgMiserMode; // To config which pages are affected by miser mode - $disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' ); + $disableRollbackEditCountSpecialPage = [ 'Recentchanges', 'Watchlist' ]; if ( $context === null ) { $context = RequestContext::getMain(); } $title = $rev->getTitle(); - $query = array( + $query = [ 'action' => 'rollback', 'from' => $rev->getUserText(), - 'token' => $context->getUser()->getEditToken( array( + 'token' => $context->getUser()->getEditToken( [ $title->getPrefixedText(), $rev->getUserText() - ) ), - ); + ] ), + ]; if ( $context->getRequest()->getBool( 'bot' ) ) { $query['bot'] = '1'; $query['hidediff'] = '1'; // bug 15999 @@ -1993,17 +1993,17 @@ class Linker { return self::link( $title, $editCount_output, - array( 'title' => $context->msg( 'tooltip-rollback' )->text() ), + [ 'title' => $context->msg( 'tooltip-rollback' )->text() ], $query, - array( 'known', 'noclasses' ) + [ 'known', 'noclasses' ] ); } else { return self::link( $title, $context->msg( 'rollbacklink' )->escaped(), - array( 'title' => $context->msg( 'tooltip-rollback' )->text() ), + [ 'title' => $context->msg( 'tooltip-rollback' )->text() ], $query, - array( 'known', 'noclasses' ) + [ 'known', 'noclasses' ] ); } } @@ -2058,9 +2058,9 @@ class Linker { if ( $restrictions ) { // Check backwards-compatible messages $msg = null; - if ( $restrictions === array( 'sysop' ) ) { + if ( $restrictions === [ 'sysop' ] ) { $msg = wfMessage( 'template-protected' ); - } elseif ( $restrictions === array( 'autoconfirmed' ) ) { + } elseif ( $restrictions === [ 'autoconfirmed' ] ) { $msg = wfMessage( 'template-semiprotected' ); } if ( $msg && !$msg->isDisabled() ) { @@ -2068,7 +2068,7 @@ class Linker { } else { // Construct the message from restriction-level-* // e.g. restriction-level-sysop, restriction-level-autoconfirmed - $msgs = array(); + $msgs = []; foreach ( $restrictions as $r ) { $msgs[] = wfMessage( "restriction-level-$r" )->parse(); } @@ -2080,15 +2080,15 @@ class Linker { $editLink = self::link( $titleObj, wfMessage( 'editlink' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); } else { $editLink = self::link( $titleObj, wfMessage( 'viewsourcelink' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); } $outText .= '
  • ' . self::link( $titleObj ) @@ -2128,7 +2128,7 @@ class Linker { foreach ( $hiddencats as $titleObj ) { # If it's hidden, it must exist - no need to check with a LinkBatch $outText .= '
  • ' - . self::link( $titleObj, null, array(), array(), 'known' ) + . self::link( $titleObj, null, [], [], 'known' ) . "
  • \n"; } $outText .= ''; @@ -2162,7 +2162,7 @@ class Linker { * @return string Contents of the title attribute (which you must HTML- * escape), or false for no title attribute */ - public static function titleAttrib( $name, $options = null, array $msgParams = array() ) { + public static function titleAttrib( $name, $options = null, array $msgParams = [] ) { $message = wfMessage( "tooltip-$name", $msgParams ); if ( !$message->exists() ) { $tooltip = false; @@ -2252,19 +2252,19 @@ class Linker { if ( $rev->getId() ) { // RevDelete links using revision ID are stable across // page deletion and undeletion; use when possible. - $query = array( + $query = [ 'type' => 'revision', 'target' => $title->getPrefixedDBkey(), 'ids' => $rev->getId() - ); + ]; } else { // Older deleted entries didn't save a revision ID. // We have to refer to these by timestamp, ick! - $query = array( + $query = [ 'type' => 'archive', 'target' => $title->getPrefixedDBkey(), 'ids' => $rev->getTimestamp() - ); + ]; } return Linker::revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ); @@ -2281,15 +2281,15 @@ class Linker { * @return string HTML "" link to Special:Revisiondelete, wrapped in a * span to allow for customization of appearance with CSS */ - public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) { + public static function revDeleteLink( $query = [], $restricted = false, $delete = true ) { $sp = SpecialPage::getTitleFor( 'Revisiondelete' ); $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted'; $html = wfMessage( $msgKey )->escaped(); $tag = $restricted ? 'strong' : 'span'; - $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) ); + $link = self::link( $sp, $html, [], $query, [ 'known', 'noclasses' ] ); return Xml::tags( $tag, - array( 'class' => 'mw-revdelundel-link' ), + [ 'class' => 'mw-revdelundel-link' ], wfMessage( 'parentheses' )->rawParams( $link )->escaped() ); } @@ -2306,7 +2306,7 @@ class Linker { $msgKey = $delete ? 'rev-delundel' : 'rev-showdeleted'; $html = wfMessage( $msgKey )->escaped(); $htmlParentheses = wfMessage( 'parentheses' )->rawParams( $html )->escaped(); - return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), $htmlParentheses ); + return Xml::tags( 'span', [ 'class' => 'mw-revdelundel-link' ], $htmlParentheses ); } /* Deprecated methods */ @@ -2319,14 +2319,14 @@ class Linker { * * @return array */ - public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = array() ) { + public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = [] ) { # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output # no attribute" instead of "output '' as value for attribute", this # would be three lines. - $attribs = array( + $attribs = [ 'title' => self::titleAttrib( $name, 'withaccess', $msgParams ), 'accesskey' => self::accesskey( $name ) - ); + ]; if ( $attribs['title'] === false ) { unset( $attribs['title'] ); } @@ -2350,9 +2350,9 @@ class Linker { if ( $tooltip === false ) { return ''; } - return Xml::expandAttributes( array( + return Xml::expandAttributes( [ 'title' => $tooltip - ) ); + ] ); } } @@ -2371,6 +2371,6 @@ class DummyLinker { * @return mixed */ public function __call( $fname, $args ) { - return call_user_func_array( array( 'Linker', $fname ), $args ); + return call_user_func_array( [ 'Linker', $fname ], $args ); } } diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index 0dd709f1e4..61e34ee9b2 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -37,7 +37,7 @@ class MWNamespace { * forevermore. Historically, they could've probably been lowercased too, * but some things are just too ingrained now. :) */ - private static $alwaysCapitalizedNamespaces = array( NS_SPECIAL, NS_USER, NS_MEDIAWIKI ); + private static $alwaysCapitalizedNamespaces = [ NS_SPECIAL, NS_USER, NS_MEDIAWIKI ]; /** * Throw an exception when trying to get the subject or talk page @@ -72,7 +72,7 @@ class MWNamespace { /** * @since 1.20 */ - Hooks::run( 'NamespaceIsMovable', array( $index, &$result ) ); + Hooks::run( 'NamespaceIsMovable', [ $index, &$result ] ); return $result; } @@ -209,13 +209,13 @@ class MWNamespace { static $namespaces = null; if ( $namespaces === null || $rebuild ) { global $wgExtraNamespaces, $wgCanonicalNamespaceNames; - $namespaces = array( NS_MAIN => '' ) + $wgCanonicalNamespaceNames; + $namespaces = [ NS_MAIN => '' ] + $wgCanonicalNamespaceNames; // Add extension namespaces $namespaces += ExtensionRegistry::getInstance()->getAttribute( 'ExtensionNamespaces' ); if ( is_array( $wgExtraNamespaces ) ) { $namespaces += $wgExtraNamespaces; } - Hooks::run( 'CanonicalNamespaces', array( &$namespaces ) ); + Hooks::run( 'CanonicalNamespaces', [ &$namespaces ] ); } return $namespaces; } @@ -245,7 +245,7 @@ class MWNamespace { public static function getCanonicalIndex( $name ) { static $xNamespaces = false; if ( $xNamespaces === false ) { - $xNamespaces = array(); + $xNamespaces = []; foreach ( self::getCanonicalNamespaces() as $i => $text ) { $xNamespaces[strtolower( $text )] = $i; } @@ -339,11 +339,11 @@ class MWNamespace { */ public static function getContentNamespaces() { global $wgContentNamespaces; - if ( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === array() ) { - return array( NS_MAIN ); + if ( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === [] ) { + return [ NS_MAIN ]; } elseif ( !in_array( NS_MAIN, $wgContentNamespaces ) ) { // always force NS_MAIN to be part of array (to match the algorithm used by isContent) - return array_merge( array( NS_MAIN ), $wgContentNamespaces ); + return array_merge( [ NS_MAIN ], $wgContentNamespaces ); } else { return $wgContentNamespaces; } @@ -472,7 +472,7 @@ class MWNamespace { } // First, get the list of groups that can edit this namespace. - $namespaceGroups = array(); + $namespaceGroups = []; $combine = 'array_merge'; foreach ( (array)$wgNamespaceProtection[$index] as $right ) { if ( $right == 'sysop' ) { @@ -491,7 +491,7 @@ class MWNamespace { // Now, keep only those restriction levels where there is at least one // group that can edit the namespace but would be blocked by the // restriction. - $usableLevels = array( '' ); + $usableLevels = [ '' ]; foreach ( $wgRestrictionLevels as $level ) { $right = $level; if ( $right == 'sysop' ) { diff --git a/includes/MWTimestamp.php b/includes/MWTimestamp.php index 937aedbddc..4964fe6cb4 100644 --- a/includes/MWTimestamp.php +++ b/includes/MWTimestamp.php @@ -32,7 +32,7 @@ class MWTimestamp { /** * Standard gmdate() formats for the different timestamp types. */ - private static $formats = array( + private static $formats = [ TS_UNIX => 'U', TS_MW => 'YmdHis', TS_DB => 'Y-m-d H:i:s', @@ -42,7 +42,7 @@ class MWTimestamp { TS_RFC2822 => 'D, d M Y H:i:s', TS_ORACLE => 'd-m-Y H:i:s.000000', // Was 'd-M-y h.i.s A' . ' +00:00' before r51500 TS_POSTGRES => 'Y-m-d H:i:s', - ); + ]; /** * The actual timestamp being wrapped (DateTime object). @@ -74,8 +74,8 @@ class MWTimestamp { * @throws TimestampException */ public function setTimestamp( $ts = false ) { - $m = array(); - $da = array(); + $m = []; + $da = []; $strtime = ''; // We want to catch 0, '', null... but not date strings starting with a letter. @@ -299,7 +299,7 @@ class MWTimestamp { MWTimestamp $relativeTo = null, User $user = null, Language $lang = null, - array $chosenIntervals = array() + array $chosenIntervals = [] ) { if ( $relativeTo === null ) { $relativeTo = new self; @@ -315,7 +315,7 @@ class MWTimestamp { $diff = $this->diff( $relativeTo ); if ( Hooks::run( 'GetRelativeTimestamp', - array( &$ts, &$diff, $this, $relativeTo, $user, $lang ) + [ &$ts, &$diff, $this, $relativeTo, $user, $lang ] ) ) { $seconds = ( ( ( $diff->days * 24 + $diff->h ) * 60 + $diff->i ) * 60 + $diff->s ); $ts = wfMessage( 'ago', $lang->formatDuration( $seconds, $chosenIntervals ) ) diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 80e60d2a34..12a445bc48 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -97,7 +97,7 @@ class MagicWord { private $mFound = false; static public $mVariableIDsInitialised = false; - static public $mVariableIDs = array( + static public $mVariableIDs = [ '!', 'currentmonth', 'currentmonth1', @@ -175,10 +175,10 @@ class MagicWord { 'contentlanguage', 'numberofadmins', 'cascadingsources', - ); + ]; /* Array of caching hints for ParserCache */ - static public $mCacheTTLs = array( + static public $mCacheTTLs = [ 'currentmonth' => 86400, 'currentmonth1' => 86400, 'currentmonthname' => 86400, @@ -217,9 +217,9 @@ class MagicWord { 'pagesinnamespace' => 3600, 'numberofadmins' => 3600, 'numberingroup' => 3600, - ); + ]; - static public $mDoubleUnderscoreIDs = array( + static public $mDoubleUnderscoreIDs = [ 'notoc', 'nogallery', 'forcetoc', @@ -233,19 +233,19 @@ class MagicWord { 'staticredirect', 'notitleconvert', 'nocontentconvert', - ); + ]; - static public $mSubstIDs = array( + static public $mSubstIDs = [ 'subst', 'safesubst', - ); + ]; - static public $mObjects = array(); + static public $mObjects = []; static public $mDoubleUnderscoreArray = null; /**#@-*/ - function __construct( $id = 0, $syn = array(), $cs = false ) { + function __construct( $id = 0, $syn = [], $cs = false ) { $this->mId = $id; $this->mSynonyms = (array)$syn; $this->mCaseSensitive = $cs; @@ -275,7 +275,7 @@ class MagicWord { static function getVariableIDs() { if ( !self::$mVariableIDsInitialised ) { # Get variable IDs - Hooks::run( 'MagicWordwgVariableIDs', array( &self::$mVariableIDs ) ); + Hooks::run( 'MagicWordwgVariableIDs', [ &self::$mVariableIDs ] ); self::$mVariableIDsInitialised = true; } return self::$mVariableIDs; @@ -310,7 +310,7 @@ class MagicWord { */ static function getDoubleUnderscoreArray() { if ( is_null( self::$mDoubleUnderscoreArray ) ) { - Hooks::run( 'GetDoubleUnderscoreIDs', array( &self::$mDoubleUnderscoreIDs ) ); + Hooks::run( 'GetDoubleUnderscoreIDs', [ &self::$mDoubleUnderscoreIDs ] ); self::$mDoubleUnderscoreArray = new MagicWordArray( self::$mDoubleUnderscoreIDs ); } return self::$mDoubleUnderscoreArray; @@ -321,7 +321,7 @@ class MagicWord { * For use in parser tests */ public static function clearCache() { - self::$mObjects = array(); + self::$mObjects = []; } /** @@ -335,7 +335,7 @@ class MagicWord { $this->mId = $id; $wgContLang->getMagic( $this ); if ( !$this->mSynonyms ) { - $this->mSynonyms = array( 'brionmademeputthishere' ); + $this->mSynonyms = [ 'brionmademeputthishere' ]; throw new MWException( "Error: invalid magic word '$id'" ); } } @@ -348,9 +348,9 @@ class MagicWord { // Sort the synonyms by length, descending, so that the longest synonym // matches in precedence to the shortest $synonyms = $this->mSynonyms; - usort( $synonyms, array( $this, 'compareStringLength' ) ); + usort( $synonyms, [ $this, 'compareStringLength' ] ); - $escSyn = array(); + $escSyn = []; foreach ( $synonyms as $synonym ) { // In case a magic word contains /, like that's going to happen;) $escSyn[] = preg_quote( $synonym, '/' ); @@ -497,7 +497,7 @@ class MagicWord { * @return string */ function matchVariableStartToEnd( $text ) { - $matches = array(); + $matches = []; $matchcount = preg_match( $this->getVariableStartToEndRegex(), $text, $matches ); if ( $matchcount == 0 ) { return null; @@ -529,7 +529,7 @@ class MagicWord { $this->mFound = false; $text = preg_replace_callback( $this->getRegex(), - array( &$this, 'pregRemoveAndRecord' ), + [ &$this, 'pregRemoveAndRecord' ], $text ); @@ -544,7 +544,7 @@ class MagicWord { $this->mFound = false; $text = preg_replace_callback( $this->getRegexStart(), - array( &$this, 'pregRemoveAndRecord' ), + [ &$this, 'pregRemoveAndRecord' ], $text ); @@ -664,8 +664,8 @@ class MagicWord { */ function replaceMultiple( $magicarr, $subject, &$result ) { wfDeprecated( __METHOD__, '1.25' ); - $search = array(); - $replace = array(); + $search = []; + $replace = []; foreach ( $magicarr as $id => $replacement ) { $mw = MagicWord::get( $id ); $search[] = $mw->getRegex(); @@ -711,7 +711,7 @@ class MagicWord { */ class MagicWordArray { /** @var array */ - public $names = array(); + public $names = []; /** @var array */ private $hash; @@ -723,7 +723,7 @@ class MagicWordArray { /** * @param array $names */ - function __construct( $names = array() ) { + function __construct( $names = [] ) { $this->names = $names; } @@ -754,7 +754,7 @@ class MagicWordArray { function getHash() { if ( is_null( $this->hash ) ) { global $wgContLang; - $this->hash = array( 0 => array(), 1 => array() ); + $this->hash = [ 0 => [], 1 => [] ]; foreach ( $this->names as $name ) { $magic = MagicWord::get( $name ); $case = intval( $magic->isCaseSensitive() ); @@ -775,7 +775,7 @@ class MagicWordArray { */ function getBaseRegex() { if ( is_null( $this->baseRegex ) ) { - $this->baseRegex = array( 0 => '', 1 => '' ); + $this->baseRegex = [ 0 => '', 1 => '' ]; foreach ( $this->names as $name ) { $magic = MagicWord::get( $name ); $case = intval( $magic->isCaseSensitive() ); @@ -801,7 +801,7 @@ class MagicWordArray { function getRegex() { if ( is_null( $this->regex ) ) { $base = $this->getBaseRegex(); - $this->regex = array( '', '' ); + $this->regex = [ '', '' ]; if ( $this->baseRegex[0] !== '' ) { $this->regex[0] = "/{$base[0]}/iuS"; } @@ -828,7 +828,7 @@ class MagicWordArray { */ function getRegexStart() { $base = $this->getBaseRegex(); - $newRegex = array( '', '' ); + $newRegex = [ '', '' ]; if ( $base[0] !== '' ) { $newRegex[0] = "/^(?:{$base[0]})/iuS"; } @@ -845,7 +845,7 @@ class MagicWordArray { */ function getVariableStartToEndRegex() { $base = $this->getBaseRegex(); - $newRegex = array( '', '' ); + $newRegex = [ '', '' ]; if ( $base[0] !== '' ) { $newRegex[0] = str_replace( "\\$1", "(.*?)", "/^(?:{$base[0]})$/iuS" ); } @@ -887,7 +887,7 @@ class MagicWordArray { } list( /* $synIndex */, $magicName ) = $parts; $paramValue = next( $m ); - return array( $magicName, $paramValue ); + return [ $magicName, $paramValue ]; } // This shouldn't happen either throw new MWException( __METHOD__ . ': parameter not found' ); @@ -907,13 +907,13 @@ class MagicWordArray { $regexes = $this->getVariableStartToEndRegex(); foreach ( $regexes as $regex ) { if ( $regex !== '' ) { - $m = array(); + $m = []; if ( preg_match( $regex, $text, $m ) ) { return $this->parseMatch( $m ); } } } - return array( false, false ); + return [ false, false ]; } /** @@ -946,20 +946,20 @@ class MagicWordArray { * @return array */ public function matchAndRemove( &$text ) { - $found = array(); + $found = []; $regexes = $this->getRegex(); foreach ( $regexes as $regex ) { if ( $regex === '' ) { continue; } - $matches = array(); + $matches = []; $res = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); if ( $res === false ) { - LoggerFactory::getInstance( 'parser' )->warning( 'preg_match_all returned false', array( + LoggerFactory::getInstance( 'parser' )->warning( 'preg_match_all returned false', [ 'code' => preg_last_error(), 'regex' => $regex, 'text' => $text, - ) ); + ] ); } elseif ( $res ) { foreach ( $matches as $m ) { list( $name, $param ) = $this->parseMatch( $m ); @@ -968,11 +968,11 @@ class MagicWordArray { } $res = preg_replace( $regex, '', $text ); if ( $res === null ) { - LoggerFactory::getInstance( 'parser' )->warning( 'preg_replace returned null', array( + LoggerFactory::getInstance( 'parser' )->warning( 'preg_replace returned null', [ 'code' => preg_last_error(), 'regex' => $regex, 'text' => $text, - ) ); + ] ); } $text = $res; } diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 7f2f737d08..45a13853e4 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -178,7 +178,7 @@ class MediaWiki { } $unused = null; // To pass it by reference - Hooks::run( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) ); + Hooks::run( 'BeforeInitialize', [ &$title, &$unused, &$output, &$user, $request, $this ] ); // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. if ( is_null( $title ) || ( $title->getDBkey() == '' && !$title->isExternal() ) @@ -197,7 +197,7 @@ class MediaWiki { // We have to check here to catch special pages etc. // We will check again in Article::view(). $permErrors = $title->isSpecial( 'RunJobs' ) - ? array() // relies on HMAC key signature alone + ? [] // relies on HMAC key signature alone : $title->getUserPermissionsErrors( 'read', $user ); if ( count( $permErrors ) ) { // Bug 32276: allowing the skin to generate output with $wgTitle or @@ -220,7 +220,7 @@ class MediaWiki { if ( $title->isExternal() ) { $rdfrom = $request->getVal( 'rdfrom' ); if ( $rdfrom ) { - $url = $title->getFullURL( array( 'rdfrom' => $rdfrom ) ); + $url = $title->getFullURL( [ 'rdfrom' => $rdfrom ] ); } else { $query = $request->getValues(); unset( $query['title'] ); @@ -256,7 +256,7 @@ class MediaWiki { $target = $specialPage->getRedirect( $subpage ); // target can also be true. We let that case fall through to normal processing. if ( $target instanceof Title ) { - $query = $specialPage->getRedirectQuery() ?: array(); + $query = $specialPage->getRedirectQuery() ?: []; $request = new DerivativeRequest( $this->context->getRequest(), $query ); $request->setRequestURL( $this->context->getRequest()->getRequestURL() ); $this->context->setRequest( $request ); @@ -267,9 +267,9 @@ class MediaWiki { // Reset action type cache. (Special pages have only view) $this->action = null; $title = $target; - $output->addJsConfigVars( array( + $output->addJsConfigVars( [ 'wgInternalRedirectTargetUrl' => $target->getFullURL( $query ), - ) ); + ] ); $output->addModules( 'mediawiki.action.view.redirect' ); } } @@ -326,8 +326,8 @@ class MediaWiki { if ( $request->getVal( 'action', 'view' ) != 'view' || $request->wasPosted() - || count( $request->getValueNames( array( 'action', 'title' ) ) ) - || !Hooks::run( 'TestCanonicalRedirect', array( $request, $title, $output ) ) + || count( $request->getValueNames( [ 'action', 'title' ] ) ) + || !Hooks::run( 'TestCanonicalRedirect', [ $request, $title, $output ] ) ) { return false; } @@ -423,7 +423,7 @@ class MediaWiki { $ignoreRedirect = $target = false; Hooks::run( 'InitializeArticleMaybeRedirect', - array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) ); + [ &$title, &$request, &$ignoreRedirect, &$target, &$article ] ); $page = $article->getPage(); // reflect any hook changes // Follow redirects only for... redirects. @@ -473,7 +473,7 @@ class MediaWiki { $user = $this->context->getUser(); if ( !Hooks::run( 'MediaWikiPerformAction', - array( $output, $page, $title, $user, $request, $this ) ) + [ $output, $page, $title, $user, $request, $this ] ) ) { return; } @@ -504,7 +504,7 @@ class MediaWiki { return; } - if ( Hooks::run( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) { + if ( Hooks::run( 'UnknownAction', [ $request->getVal( 'action', 'view' ), $page ] ) ) { $output->setStatusCode( 404 ); $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); } @@ -557,7 +557,7 @@ class MediaWiki { $factory->commitMasterChanges( __METHOD__, // Abort if any transaction was too big - array( 'maxWriteDuration' => $config->get( 'MaxUserDBWriteDuration' ) ) + [ 'maxWriteDuration' => $config->get( 'MaxUserDBWriteDuration' ) ] ); // Record ChronologyProtector positions $factory->shutdown(); @@ -572,7 +572,7 @@ class MediaWiki { $request = $context->getRequest(); if ( $request->wasPosted() && $factory->hasOrMadeRecentMasterChanges() ) { $expires = time() + $config->get( 'DataCenterUpdateStickTTL' ); - $options = array( 'prefix' => '' ); + $options = [ 'prefix' => '' ]; $request->response()->setCookie( 'UseDC', 'master', $expires, $options ); $request->response()->setCookie( 'UseCDNCache', 'false', $expires, $options ); } @@ -689,7 +689,7 @@ class MediaWiki { $redirUrl = preg_replace( '#^http://#', 'https://', $oldUrl ); // ATTENTION: This hook is likely to be removed soon due to overall design of the system. - if ( Hooks::run( 'BeforeHttpsRedirect', array( $this->context, &$redirUrl ) ) ) { + if ( Hooks::run( 'BeforeHttpsRedirect', [ $this->context, &$redirUrl ] ) ) { if ( $request->wasPosted() ) { // This is weird and we'd hope it almost never happens. This @@ -809,7 +809,7 @@ class MediaWiki { if ( !$this->config->get( 'RunJobsAsync' ) ) { // Fall back to running the job here while the user waits $runner = new JobRunner( $runJobsLogger ); - $runner->run( array( 'maxJobs' => $n ) ); + $runner->run( [ 'maxJobs' => $n ] ); return; } @@ -822,8 +822,8 @@ class MediaWiki { return; // do not make the site unavailable } - $query = array( 'title' => 'Special:RunJobs', - 'tasks' => 'jobs', 'maxjobs' => $n, 'sigexpiry' => time() + 5 ); + $query = [ 'title' => 'Special:RunJobs', + 'tasks' => 'jobs', 'maxjobs' => $n, 'sigexpiry' => time() + 5 ]; $query['signature'] = SpecialRunJobs::getQuerySignature( $query, $this->config->get( 'SecretKey' ) ); @@ -844,7 +844,7 @@ class MediaWiki { $runJobsLogger->error( "Failed to start cron API (socket error $errno): $errstr" ); // Fall back to running the job here while the user waits $runner = new JobRunner( $runJobsLogger ); - $runner->run( array( 'maxJobs' => $n ) ); + $runner->run( [ 'maxJobs' => $n ] ); return; } diff --git a/includes/MediaWikiVersionFetcher.php b/includes/MediaWikiVersionFetcher.php index 943bc9fcf3..913ae9a50d 100644 --- a/includes/MediaWikiVersionFetcher.php +++ b/includes/MediaWikiVersionFetcher.php @@ -17,7 +17,7 @@ class MediaWikiVersionFetcher { public function fetchVersion() { $defaultSettings = file_get_contents( __DIR__ . '/DefaultSettings.php' ); - $matches = array(); + $matches = []; preg_match( "/wgVersion = '([0-9a-zA-Z\.\-]+)';/", $defaultSettings, $matches ); if ( count( $matches ) !== 2 ) { diff --git a/includes/MergeHistory.php b/includes/MergeHistory.php index a3861eefb6..a92056dda5 100644 --- a/includes/MergeHistory.php +++ b/includes/MergeHistory.php @@ -75,7 +75,7 @@ class MergeHistory { $firstDestTimestamp = $this->dbw->selectField( 'revision', 'MIN(rev_timestamp)', - array( 'rev_page' => $this->dest->getArticleID() ), + [ 'rev_page' => $this->dest->getArticleID() ], __METHOD__ ); $this->maxTimestamp = new MWTimestamp( $firstDestTimestamp ); @@ -89,10 +89,10 @@ class MergeHistory { $lastWorkingTimestamp = $this->dbw->selectField( 'revision', 'MAX(rev_timestamp)', - array( + [ 'rev_timestamp <= ' . $this->dbw->timestamp( $mwTimestamp ), 'rev_page' => $this->source->getArticleID() - ), + ], __METHOD__ ); $mwLastWorkingTimestamp = new MWTimestamp( $lastWorkingTimestamp ); @@ -105,11 +105,11 @@ class MergeHistory { // Get the latest timestamp of the source $lastSourceTimestamp = $this->dbw->selectField( - array( 'page', 'revision' ), + [ 'page', 'revision' ], 'rev_timestamp', - array( 'page_id' => $this->source->getArticleID(), + [ 'page_id' => $this->source->getArticleID(), 'page_latest = rev_id' - ), + ], __METHOD__ ); $lasttimestamp = new MWTimestamp( $lastSourceTimestamp ); @@ -132,9 +132,9 @@ class MergeHistory { */ public function getRevisionCount() { $count = $this->dbw->selectRowCount( 'revision', '1', - array( 'rev_page' => $this->source->getArticleID(), $this->timeWhere ), + [ 'rev_page' => $this->source->getArticleID(), $this->timeWhere ], __METHOD__, - array( 'LIMIT' => self::REVISION_LIMIT + 1 ) + [ 'LIMIT' => self::REVISION_LIMIT + 1 ] ); return $count; @@ -167,7 +167,7 @@ class MergeHistory { // Convert into a Status object if ( $errors ) { foreach ( $errors as $error ) { - call_user_func_array( array( $status, 'fatal' ), $error ); + call_user_func_array( [ $status, 'fatal' ], $error ); } } @@ -256,8 +256,8 @@ class MergeHistory { $this->dbw->update( 'revision', - array( 'rev_page' => $this->dest->getArticleID() ), - array( 'rev_page' => $this->source->getArticleID(), $this->timeWhere ), + [ 'rev_page' => $this->dest->getArticleID() ], + [ 'rev_page' => $this->source->getArticleID(), $this->timeWhere ], __METHOD__ ); @@ -272,9 +272,9 @@ class MergeHistory { $haveRevisions = $this->dbw->selectField( 'revision', 'rev_timestamp', - array( 'rev_page' => $this->source->getArticleID() ), + [ 'rev_page' => $this->source->getArticleID() ], __METHOD__, - array( 'FOR UPDATE' ) + [ 'FOR UPDATE' ] ); if ( !$haveRevisions ) { if ( $reason ) { @@ -300,11 +300,11 @@ class MergeHistory { if ( $redirectContent ) { $redirectPage = WikiPage::factory( $this->source ); - $redirectRevision = new Revision( array( + $redirectRevision = new Revision( [ 'title' => $this->source, 'page' => $this->source->getArticleID(), 'comment' => $reason, - 'content' => $redirectContent ) ); + 'content' => $redirectContent ] ); $redirectRevision->insertOn( $this->dbw ); $redirectPage->updateRevisionOn( $this->dbw, $redirectRevision ); @@ -312,15 +312,15 @@ class MergeHistory { // It should have no other outgoing links... $this->dbw->delete( 'pagelinks', - array( 'pl_from' => $this->dest->getArticleID() ), + [ 'pl_from' => $this->dest->getArticleID() ], __METHOD__ ); $this->dbw->insert( 'pagelinks', - array( + [ 'pl_from' => $this->dest->getArticleID(), 'pl_from_namespace' => $this->dest->getNamespace(), 'pl_namespace' => $this->dest->getNamespace(), - 'pl_title' => $this->dest->getDBkey() ), + 'pl_title' => $this->dest->getDBkey() ], __METHOD__ ); } else { @@ -337,14 +337,14 @@ class MergeHistory { $logEntry->setPerformer( $user ); $logEntry->setComment( $reason ); $logEntry->setTarget( $this->source ); - $logEntry->setParameters( array( + $logEntry->setParameters( [ '4::dest' => $this->dest->getPrefixedText(), '5::mergepoint' => $this->timestampLimit->getTimestamp( TS_MW ) - ) ); + ] ); $logId = $logEntry->insert(); $logEntry->publish( $logId ); - Hooks::run( 'ArticleMergeComplete', array( $this->source, $this->dest ) ); + Hooks::run( 'ArticleMergeComplete', [ $this->source, $this->dest ] ); return $status; } diff --git a/includes/Message.php b/includes/Message.php index c71a953498..4056f38da9 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -188,7 +188,7 @@ class Message implements MessageSpecifier, Serializable { /** * @var array List of parameters which will be substituted into the message. */ - protected $parameters = array(); + protected $parameters = []; /** * Format for the message. @@ -234,7 +234,7 @@ class Message implements MessageSpecifier, Serializable { * * @throws InvalidArgumentException */ - public function __construct( $key, $params = array(), Language $language = null ) { + public function __construct( $key, $params = [], Language $language = null ) { global $wgLang; if ( $key instanceof MessageSpecifier ) { @@ -269,7 +269,7 @@ class Message implements MessageSpecifier, Serializable { * @return string */ public function serialize() { - return serialize( array( + return serialize( [ 'interface' => $this->interface, 'language' => $this->language instanceof StubUserLang ? false : $this->language->getCode(), 'key' => $this->key, @@ -278,7 +278,7 @@ class Message implements MessageSpecifier, Serializable { 'format' => $this->format, 'useDatabase' => $this->useDatabase, 'title' => $this->title, - ) ); + ] ); } /** @@ -780,7 +780,7 @@ class Message implements MessageSpecifier, Serializable { # Replace $* with a list of parameters for &uselang=qqx. if ( strpos( $string, '$*' ) !== false ) { $paramlist = ''; - if ( $this->parameters !== array() ) { + if ( $this->parameters !== [] ) { $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) ); } $string = str_replace( '$*', $paramlist, $string ); @@ -943,7 +943,7 @@ class Message implements MessageSpecifier, Serializable { * @return array Array with a single "raw" key. */ public static function rawParam( $raw ) { - return array( 'raw' => $raw ); + return [ 'raw' => $raw ]; } /** @@ -954,7 +954,7 @@ class Message implements MessageSpecifier, Serializable { * @return array Array with a single "num" key. */ public static function numParam( $num ) { - return array( 'num' => $num ); + return [ 'num' => $num ]; } /** @@ -965,7 +965,7 @@ class Message implements MessageSpecifier, Serializable { * @return int[] Array with a single "duration" key. */ public static function durationParam( $duration ) { - return array( 'duration' => $duration ); + return [ 'duration' => $duration ]; } /** @@ -976,7 +976,7 @@ class Message implements MessageSpecifier, Serializable { * @return string[] Array with a single "expiry" key. */ public static function expiryParam( $expiry ) { - return array( 'expiry' => $expiry ); + return [ 'expiry' => $expiry ]; } /** @@ -987,7 +987,7 @@ class Message implements MessageSpecifier, Serializable { * @return number[] Array with a single "period" key. */ public static function timeperiodParam( $period ) { - return array( 'period' => $period ); + return [ 'period' => $period ]; } /** @@ -998,7 +998,7 @@ class Message implements MessageSpecifier, Serializable { * @return int[] Array with a single "size" key. */ public static function sizeParam( $size ) { - return array( 'size' => $size ); + return [ 'size' => $size ]; } /** @@ -1009,7 +1009,7 @@ class Message implements MessageSpecifier, Serializable { * @return int[] Array with a single "bitrate" key. */ public static function bitrateParam( $bitrate ) { - return array( 'bitrate' => $bitrate ); + return [ 'bitrate' => $bitrate ]; } /** @@ -1020,7 +1020,7 @@ class Message implements MessageSpecifier, Serializable { * @return string[] Array with a single "plaintext" key. */ public static function plaintextParam( $plaintext ) { - return array( 'plaintext' => $plaintext ); + return [ 'plaintext' => $plaintext ]; } /** @@ -1034,7 +1034,7 @@ class Message implements MessageSpecifier, Serializable { * @return string */ protected function replaceParameters( $message, $type = 'before' ) { - $replacementKeys = array(); + $replacementKeys = []; foreach ( $this->parameters as $n => $param ) { list( $paramType, $value ) = $this->extractParam( $param ); if ( $type === $paramType ) { @@ -1057,23 +1057,23 @@ class Message implements MessageSpecifier, Serializable { protected function extractParam( $param ) { if ( is_array( $param ) ) { if ( isset( $param['raw'] ) ) { - return array( 'after', $param['raw'] ); + return [ 'after', $param['raw'] ]; } elseif ( isset( $param['num'] ) ) { // Replace number params always in before step for now. // No support for combined raw and num params - return array( 'before', $this->language->formatNum( $param['num'] ) ); + return [ 'before', $this->language->formatNum( $param['num'] ) ]; } elseif ( isset( $param['duration'] ) ) { - return array( 'before', $this->language->formatDuration( $param['duration'] ) ); + return [ 'before', $this->language->formatDuration( $param['duration'] ) ]; } elseif ( isset( $param['expiry'] ) ) { - return array( 'before', $this->language->formatExpiry( $param['expiry'] ) ); + return [ 'before', $this->language->formatExpiry( $param['expiry'] ) ]; } elseif ( isset( $param['period'] ) ) { - return array( 'before', $this->language->formatTimePeriod( $param['period'] ) ); + return [ 'before', $this->language->formatTimePeriod( $param['period'] ) ]; } elseif ( isset( $param['size'] ) ) { - return array( 'before', $this->language->formatSize( $param['size'] ) ); + return [ 'before', $this->language->formatSize( $param['size'] ) ]; } elseif ( isset( $param['bitrate'] ) ) { - return array( 'before', $this->language->formatBitrate( $param['bitrate'] ) ); + return [ 'before', $this->language->formatBitrate( $param['bitrate'] ) ]; } elseif ( isset( $param['plaintext'] ) ) { - return array( 'after', $this->formatPlaintext( $param['plaintext'] ) ); + return [ 'after', $this->formatPlaintext( $param['plaintext'] ) ]; } else { $warning = 'Invalid parameter for message "' . $this->getKey() . '": ' . htmlspecialchars( serialize( $param ) ); @@ -1081,15 +1081,15 @@ class Message implements MessageSpecifier, Serializable { $e = new Exception; wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() ); - return array( 'before', '[INVALID]' ); + return [ 'before', '[INVALID]' ]; } } elseif ( $param instanceof Message ) { // Message objects should not be before parameters because // then they'll get double escaped. If the message needs to be // escaped, it'll happen right here when we call toString(). - return array( 'after', $param->toString() ); + return [ 'after', $param->toString() ]; } else { - return array( 'before', $param ); + return [ 'before', $param ]; } } @@ -1212,7 +1212,7 @@ class RawMessage extends Message { * * @throws InvalidArgumentException */ - public function __construct( $text, $params = array() ) { + public function __construct( $text, $params = [] ) { if ( !is_string( $text ) ) { throw new InvalidArgumentException( '$text must be a string' ); } diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index d619f2da46..aedfd8fece 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -200,7 +200,7 @@ class MimeMagic { global $IP; # Allow media handling extensions adding MIME-types and MIME-info - Hooks::run( 'MimeMagicInit', array( $this ) ); + Hooks::run( 'MimeMagicInit', [ $this ] ); $types = MM_WELL_KNOWN_MIME_TYPES; @@ -223,11 +223,11 @@ class MimeMagic { $types .= "\n" . $this->mExtraTypes; - $types = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $types ); + $types = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $types ); $types = str_replace( "\t", " ", $types ); - $this->mMimeToExt = array(); - $this->mExtToMime = array(); + $this->mMimeToExt = []; + $this->mExtToMime = []; $lines = explode( "\n", $types ); foreach ( $lines as $s ) { @@ -300,11 +300,11 @@ class MimeMagic { $info .= "\n" . $this->mExtraInfo; - $info = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $info ); + $info = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $info ); $info = str_replace( "\t", " ", $info ); - $this->mMimeTypeAliases = array(); - $this->mMediaTypes = array(); + $this->mMimeTypeAliases = []; + $this->mMediaTypes = []; $lines = explode( "\n", $info ); foreach ( $lines as $s ) { @@ -325,7 +325,7 @@ class MimeMagic { # print "processing MIME INFO line $s
    "; - $match = array(); + $match = []; if ( preg_match( '!\[\s*(\w+)\s*\]!', $s, $match ) ) { $s = preg_replace( '!\[\s*(\w+)\s*\]!', '', $s ); $mtype = trim( strtoupper( $match[1] ) ); @@ -336,7 +336,7 @@ class MimeMagic { $m = explode( ' ', $s ); if ( !isset( $this->mMediaTypes[$mtype] ) ) { - $this->mMediaTypes[$mtype] = array(); + $this->mMediaTypes[$mtype] = []; } foreach ( $m as $mime ) { @@ -485,7 +485,7 @@ class MimeMagic { */ public function isPHPImageType( $mime ) { // As defined by imagegetsize and image_type_to_mime - static $types = array( + static $types = [ 'image/gif', 'image/jpeg', 'image/png', 'image/x-bmp', 'image/xbm', 'image/tiff', 'image/jp2', 'image/jpeg2000', 'image/iff', @@ -493,7 +493,7 @@ class MimeMagic { 'image/vnd.wap.wbmp', 'image/vnd.xiff', 'image/x-photoshop', 'application/x-shockwave-flash', - ); + ]; return in_array( $mime, $types ); } @@ -511,7 +511,7 @@ class MimeMagic { * @return bool */ function isRecognizableExtension( $extension ) { - static $types = array( + static $types = [ // Types recognized by getimagesize() 'gif', 'jpeg', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'tif', 'jpc', 'jp2', @@ -525,7 +525,7 @@ class MimeMagic { // XML formats we sure hope we recognize reliably 'svg', - ); + ]; return in_array( strtolower( $extension ), $types ); } @@ -569,7 +569,7 @@ class MimeMagic { } # Media handling extensions can improve the MIME detected - Hooks::run( 'MimeMagicImproveFromExtension', array( $this, $ext, &$mime ) ); + Hooks::run( 'MimeMagicImproveFromExtension', [ $this, $ext, &$mime ] ); if ( isset( $this->mMimeTypeAliases[$mime] ) ) { $mime = $this->mMimeTypeAliases[$mime]; @@ -651,7 +651,7 @@ class MimeMagic { wfDebug( __METHOD__ . ": analyzing head and tail of $file for magic numbers.\n" ); // Hardcode a few magic number checks... - $headers = array( + $headers = [ // Multimedia... 'MThd' => 'audio/midi', 'OggS' => 'application/ogg', @@ -667,7 +667,7 @@ class MimeMagic { 'MZ' => 'application/octet-stream', // DOS/Windows executable "\xca\xfe\xba\xbe" => 'application/octet-stream', // Mach-O binary "\x7fELF" => 'application/octet-stream', // ELF binary - ); + ]; foreach ( $headers as $magic => $candidate ) { if ( strncmp( $head, $magic, strlen( $magic ) ) == 0 ) { @@ -755,7 +755,7 @@ class MimeMagic { if ( $script_type ) { if ( $script_type !== "UTF-8" && $script_type !== "ASCII" ) { // Quick and dirty fold down to ASCII! - $pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' ); + $pack = [ 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' ]; $chars = unpack( $pack[$script_type], substr( $head, 2 ) ); $head = ''; foreach ( $chars as $codepoint ) { @@ -767,7 +767,7 @@ class MimeMagic { } } - $match = array(); + $match = []; if ( preg_match( '%/?([^\s]+/)(\w+)%', $head, $match ) ) { $mime = "application/x-{$match[2]}"; @@ -806,7 +806,7 @@ class MimeMagic { # Some strings by reference for performance - assuming well-behaved hooks Hooks::run( 'MimeMagicGuessFromContent', - array( $this, &$head, &$tail, $file, &$mime ) + [ $this, &$head, &$tail, $file, &$mime ] ); return $mime; @@ -832,7 +832,7 @@ class MimeMagic { } $mime = 'application/zip'; - $opendocTypes = array( + $opendocTypes = [ 'chart-template', 'chart', 'formula-template', @@ -848,7 +848,7 @@ class MimeMagic { 'text-template', 'text-master', 'text-web', - 'text' ); + 'text' ]; // http://lists.oasis-open.org/archives/office/200505/msg00006.html $types = '(?:' . implode( '|', $opendocTypes ) . ')'; @@ -1110,7 +1110,7 @@ class MimeMagic { $extMime = $this->mMimeTypeAliases[$extMime]; } - $m = array( $extMime ); + $m = [ $extMime ]; } foreach ( $m as $mime ) { diff --git a/includes/MovePage.php b/includes/MovePage.php index fb0ca8c89a..6d69eaa60b 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -55,7 +55,7 @@ class MovePage { // Convert into a Status object if ( $errors ) { foreach ( $errors as $error ) { - call_user_func_array( array( $status, 'fatal' ), $error ); + call_user_func_array( [ $status, 'fatal' ], $error ); } } @@ -70,7 +70,7 @@ class MovePage { } Hooks::run( 'MovePageCheckPermissions', - array( $this->oldTitle, $this->newTitle, $user, $reason, $status ) + [ $this->oldTitle, $this->newTitle, $user, $reason, $status ] ); return $status; @@ -141,7 +141,7 @@ class MovePage { } // Hook for extensions to say a title can't be moved for technical reasons - Hooks::run( 'MovePageIsValidMove', array( $this->oldTitle, $this->newTitle, $status ) ); + Hooks::run( 'MovePageIsValidMove', [ $this->oldTitle, $this->newTitle, $status ] ); return $status; } @@ -228,7 +228,7 @@ class MovePage { public function move( User $user, $reason, $createRedirect ) { global $wgCategoryCollation; - Hooks::run( 'TitleMove', array( $this->oldTitle, $this->newTitle, $user ) ); + Hooks::run( 'TitleMove', [ $this->oldTitle, $this->newTitle, $user ] ); // If it is a file, move it first. // It is done before all other moving stuff is done because it's hard to revert. @@ -260,8 +260,8 @@ class MovePage { // from LinksUpdate::getCategoryInsertions() and friends. $prefixes = $dbw->select( 'categorylinks', - array( 'cl_sortkey_prefix', 'cl_to' ), - array( 'cl_from' => $pageid ), + [ 'cl_sortkey_prefix', 'cl_to' ], + [ 'cl_from' => $pageid ], __METHOD__ ); if ( $this->newTitle->getNamespace() == NS_CATEGORY ) { @@ -275,15 +275,15 @@ class MovePage { $prefix = $prefixRow->cl_sortkey_prefix; $catTo = $prefixRow->cl_to; $dbw->update( 'categorylinks', - array( + [ 'cl_sortkey' => Collation::singleton()->getSortKey( $this->newTitle->getCategorySortkey( $prefix ) ), 'cl_collation' => $wgCategoryCollation, 'cl_type' => $type, - 'cl_timestamp=cl_timestamp' ), - array( + 'cl_timestamp=cl_timestamp' ], + [ 'cl_from' => $pageid, - 'cl_to' => $catTo ), + 'cl_to' => $catTo ], __METHOD__ ); } @@ -293,17 +293,17 @@ class MovePage { if ( $protected ) { # Protect the redirect title as the title used to be... $dbw->insertSelect( 'page_restrictions', 'page_restrictions', - array( + [ 'pr_page' => $redirid, 'pr_type' => 'pr_type', 'pr_level' => 'pr_level', 'pr_cascade' => 'pr_cascade', 'pr_user' => 'pr_user', 'pr_expiry' => 'pr_expiry' - ), - array( 'pr_page' => $pageid ), + ], + [ 'pr_page' => $pageid ], __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); // Build comment for log @@ -320,10 +320,10 @@ class MovePage { $insertedPrIds = $dbw->select( 'page_restrictions', 'pr_id', - array( 'pr_page' => $redirid ), + [ 'pr_page' => $redirid ], __METHOD__ ); - $logRelationsValues = array(); + $logRelationsValues = []; foreach ( $insertedPrIds as $prid ) { $logRelationsValues[] = $prid->pr_id; } @@ -333,10 +333,10 @@ class MovePage { $logEntry->setTarget( $this->newTitle ); $logEntry->setComment( $comment ); $logEntry->setPerformer( $user ); - $logEntry->setParameters( array( + $logEntry->setParameters( [ '4::oldtitle' => $this->oldTitle->getPrefixedText(), - ) ); - $logEntry->setRelations( array( 'pr_id' => $logRelationsValues ) ); + ] ); + $logEntry->setRelations( [ 'pr_id' => $logRelationsValues ] ); $logId = $logEntry->insert(); $logEntry->publish( $logId ); } @@ -344,18 +344,18 @@ class MovePage { // Update *_from_namespace fields as needed if ( $this->oldTitle->getNamespace() != $this->newTitle->getNamespace() ) { $dbw->update( 'pagelinks', - array( 'pl_from_namespace' => $this->newTitle->getNamespace() ), - array( 'pl_from' => $pageid ), + [ 'pl_from_namespace' => $this->newTitle->getNamespace() ], + [ 'pl_from' => $pageid ], __METHOD__ ); $dbw->update( 'templatelinks', - array( 'tl_from_namespace' => $this->newTitle->getNamespace() ), - array( 'tl_from' => $pageid ), + [ 'tl_from_namespace' => $this->newTitle->getNamespace() ], + [ 'tl_from' => $pageid ], __METHOD__ ); $dbw->update( 'imagelinks', - array( 'il_from_namespace' => $this->newTitle->getNamespace() ), - array( 'il_from' => $pageid ), + [ 'il_from_namespace' => $this->newTitle->getNamespace() ], + [ 'il_from' => $pageid ], __METHOD__ ); } @@ -371,13 +371,13 @@ class MovePage { Hooks::run( 'TitleMoveCompleting', - array( $this->oldTitle, $this->newTitle, - $user, $pageid, $redirid, $reason, $nullRevision ) + [ $this->oldTitle, $this->newTitle, + $user, $pageid, $redirid, $reason, $nullRevision ] ); $dbw->endAtomic( __METHOD__ ); - $params = array( + $params = [ &$this->oldTitle, &$this->newTitle, &$user, @@ -385,7 +385,7 @@ class MovePage { $redirid, $reason, $nullRevision - ); + ]; $dbw->onTransactionIdle( function () use ( $params, $dbw ) { // Keep each single hook handler atomic $dbw->setFlag( DBO_TRX ); // flag is automatically reset by DB layer @@ -452,10 +452,10 @@ class MovePage { $logEntry->setPerformer( $user ); $logEntry->setTarget( $logTitle ); $logEntry->setComment( $reason ); - $logEntry->setParameters( array( + $logEntry->setParameters( [ '4::target' => $nt->getPrefixedText(), '5::noredir' => $redirectContent ? '0': '1', - ) ); + ] ); $formatter = LogFormatter::newFromEntry( $logEntry ); $formatter->setContext( RequestContext::newExtraneousContext( $this->oldTitle ) ); @@ -481,7 +481,7 @@ class MovePage { # by definition if we've got here it's rather uninteresting. # We have to remove it so that the next step doesn't trigger # a conflict on the unique namespace+title index... - $dbw->delete( 'page', array( 'page_id' => $newid ), __METHOD__ ); + $dbw->delete( 'page', [ 'page_id' => $newid ], __METHOD__ ); $newpage->doDeleteUpdates( $newid, $newcontent ); } @@ -496,11 +496,11 @@ class MovePage { # Change the name of the target page: $dbw->update( 'page', - /* SET */ array( + /* SET */ [ 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey(), - ), - /* WHERE */ array( 'page_id' => $oldid ), + ], + /* WHERE */ [ 'page_id' => $oldid ], __METHOD__ ); @@ -516,17 +516,17 @@ class MovePage { $newpage->updateRevisionOn( $dbw, $nullRevision ); Hooks::run( 'NewRevisionFromEditComplete', - array( $newpage, $nullRevision, $nullRevision->getParentId(), $user ) ); + [ $newpage, $nullRevision, $nullRevision->getParentId(), $user ] ); $newpage->doEditUpdates( $nullRevision, $user, - array( 'changed' => false, 'moved' => true, 'oldcountable' => $oldcountable ) ); + [ 'changed' => false, 'moved' => true, 'oldcountable' => $oldcountable ] ); // If the default content model changes, we need to populate rev_content_model if ( $defaultContentModelChanging ) { $dbw->update( 'revision', - array( 'rev_content_model' => $contentModel ), - array( 'rev_page' => $nt->getArticleID(), 'rev_content_model IS NULL' ), + [ 'rev_content_model' => $contentModel ], + [ 'rev_page' => $nt->getArticleID(), 'rev_content_model IS NULL' ], __METHOD__ ); } @@ -542,20 +542,20 @@ class MovePage { $newid = $redirectArticle->insertOn( $dbw ); if ( $newid ) { // sanity $this->oldTitle->resetArticleID( $newid ); - $redirectRevision = new Revision( array( + $redirectRevision = new Revision( [ 'title' => $this->oldTitle, // for determining the default content model 'page' => $newid, 'user_text' => $user->getName(), 'user' => $user->getId(), 'comment' => $comment, - 'content' => $redirectContent ) ); + 'content' => $redirectContent ] ); $redirectRevision->insertOn( $dbw ); $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); Hooks::run( 'NewRevisionFromEditComplete', - array( $redirectArticle, $redirectRevision, false, $user ) ); + [ $redirectArticle, $redirectRevision, false, $user ] ); - $redirectArticle->doEditUpdates( $redirectRevision, $user, array( 'created' => true ) ); + $redirectArticle->doEditUpdates( $redirectRevision, $user, [ 'created' => true ] ); } } diff --git a/includes/NoLocalSettings.php b/includes/NoLocalSettings.php index d299ab6ff5..b0a6b7bd04 100644 --- a/includes/NoLocalSettings.php +++ b/includes/NoLocalSettings.php @@ -21,7 +21,7 @@ */ # bug 30219 : can not use pathinfo() on URLs since slashes do not match -$matches = array(); +$matches = []; $ext = 'php'; $path = '/'; foreach ( array_filter( explode( '/', $_SERVER['PHP_SELF'] ) ) as $part ) { @@ -52,13 +52,13 @@ $templateParser = new TemplateParser(); try { echo $templateParser->processTemplate( 'NoLocalSettings', - array( + [ 'wgVersion' => ( isset( $wgVersion ) ? $wgVersion : 'VERSION' ), 'path' => $path, 'ext' => $ext, 'localSettingsExists' => file_exists( MW_CONFIG_FILE ), 'installerStarted' => $installerStarted - ) + ] ); } catch ( Exception $e ) { echo 'Error: ' . htmlspecialchars( $e->getMessage() ); diff --git a/includes/OutputHandler.php b/includes/OutputHandler.php index 30f193cdd8..c9c326b150 100644 --- a/includes/OutputHandler.php +++ b/includes/OutputHandler.php @@ -195,13 +195,13 @@ function wfHtmlValidationHandler( $s ) { $out .= Html::openElement( 'ul' ); $error = strtok( $errors, "\n" ); - $badLines = array(); + $badLines = []; while ( $error !== false ) { if ( preg_match( '/^line (\d+)/', $error, $m ) ) { $lineNum = intval( $m[1] ); $badLines[$lineNum] = true; $out .= Html::rawElement( 'li', null, - Html::element( 'a', array( 'href' => "#line-{$lineNum}" ), $error ) ) . "\n"; + Html::element( 'a', [ 'href' => "#line-{$lineNum}" ], $error ) ) . "\n"; } $error = strtok( "\n" ); } @@ -212,7 +212,7 @@ function wfHtmlValidationHandler( $s ) { $line = strtok( $s, "\n" ); $i = 1; while ( $line !== false ) { - $attrs = array(); + $attrs = []; if ( isset( $badLines[$i] ) ) { $attrs['class'] = 'highlight'; $attrs['id'] = "line-$i"; @@ -228,7 +228,7 @@ function wfHtmlValidationHandler( $s ) { li { white-space: pre } CSS; - $out = Html::htmlHeader( array( 'lang' => 'en', 'dir' => 'ltr' ) ) . + $out = Html::htmlHeader( [ 'lang' => 'en', 'dir' => 'ltr' ] ) . Html::rawElement( 'head', null, Html::element( 'title', null, 'HTML validation error' ) . Html::inlineStyle( $style ) ) . diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 459fb4d64e..2570cfbeaa 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -41,10 +41,10 @@ use WrappedString\WrappedString; */ class OutputPage extends ContextSource { /** @var array Should be private. Used with addMeta() which adds "" */ - protected $mMetatags = array(); + protected $mMetatags = []; /** @var array */ - protected $mLinktags = array(); + protected $mLinktags = []; /** @var bool */ protected $mCanonicalUrl = false; @@ -53,7 +53,7 @@ class OutputPage extends ContextSource { * @var array Additional stylesheets. Looks like this is for extensions. * Might be replaced by ResourceLoader. */ - protected $mExtStyles = array(); + protected $mExtStyles = []; /** * @var string Should be private - has getter and setter. Contains @@ -95,7 +95,7 @@ class OutputPage extends ContextSource { * @var array Contains the page subtitle. Special pages usually have some * links here. Don't confuse with site subtitle added by skins. */ - private $mSubtitle = array(); + private $mSubtitle = []; /** @var string */ public $mRedirect = ''; @@ -121,16 +121,16 @@ class OutputPage extends ContextSource { private $mETag = false; /** @var array */ - protected $mCategoryLinks = array(); + protected $mCategoryLinks = []; /** @var array */ - protected $mCategories = array(); + protected $mCategories = []; /** @var array */ - protected $mIndicators = array(); + protected $mIndicators = []; /** @var array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') */ - private $mLanguageLinks = array(); + private $mLanguageLinks = []; /** * Used for JavaScript (predates ResourceLoader) @@ -150,28 +150,28 @@ class OutputPage extends ContextSource { public $mPageLinkTitle = ''; /** @var array Array of elements in "". Parser might add its own headers! */ - protected $mHeadItems = array(); + protected $mHeadItems = []; /** @var array */ - protected $mModules = array(); + protected $mModules = []; /** @var array */ - protected $mModuleScripts = array(); + protected $mModuleScripts = []; /** @var array */ - protected $mModuleStyles = array(); + protected $mModuleStyles = []; /** @var ResourceLoader */ protected $mResourceLoader; /** @var array */ - protected $mJsConfigVars = array(); + protected $mJsConfigVars = []; /** @var array */ - protected $mTemplateIds = array(); + protected $mTemplateIds = []; /** @var array */ - protected $mImageTimeKeys = array(); + protected $mImageTimeKeys = []; /** @var string */ public $mRedirectCode = ''; @@ -183,9 +183,9 @@ class OutputPage extends ContextSource { * @see ResourceLoaderModule::$origin * ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden; */ - protected $mAllowedModules = array( + protected $mAllowedModules = [ ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL, - ); + ]; /** @var bool Whether output is disabled. If this is true, the 'output' method will do nothing. */ protected $mDoNothing = false; @@ -206,7 +206,7 @@ class OutputPage extends ContextSource { * We probably only support Atom in 2011. * @see $wgAdvertisedFeedTypes */ - private $mFeedLinks = array(); + private $mFeedLinks = []; // Gwicke work on squid caching? Roughly from 2003. protected $mEnableClientCache = true; @@ -259,7 +259,7 @@ class OutputPage extends ContextSource { * Style again! This seems like a code duplication since we already have * mStyles. This is what makes Open Source amazing. */ - protected $styles = array(); + protected $styles = []; /** * Whether jQuery is already handled. @@ -268,9 +268,9 @@ class OutputPage extends ContextSource { private $mIndexPolicy = 'index'; private $mFollowPolicy = 'follow'; - private $mVaryHeader = array( - 'Accept-Encoding' => array( 'match=gzip' ), - ); + private $mVaryHeader = [ + 'Accept-Encoding' => [ 'match=gzip' ], + ]; /** * If the current page was reached through a redirect, $mRedirectedFrom contains the Title @@ -283,7 +283,7 @@ class OutputPage extends ContextSource { /** * Additional key => value data */ - private $mProperties = array(); + private $mProperties = []; /** * @var string|null ResourceLoader target for load.php links. If null, will be omitted @@ -370,7 +370,7 @@ class OutputPage extends ContextSource { * @param string $val Tag value */ function addMeta( $name, $val ) { - array_push( $this->mMetatags, array( $name, $val ) ); + array_push( $this->mMetatags, [ $name, $val ] ); } /** @@ -542,7 +542,7 @@ class OutputPage extends ContextSource { $type = ResourceLoaderModule::TYPE_COMBINED ) { $resourceLoader = $this->getResourceLoader(); - $filteredModules = array(); + $filteredModules = []; foreach ( $modules as $val ) { $module = $resourceLoader->getModule( $val ); if ( $module instanceof ResourceLoaderModule @@ -640,7 +640,7 @@ class OutputPage extends ContextSource { */ public function getModuleMessages( $filter = false, $position = null ) { wfDeprecated( __METHOD__, '1.26' ); - return array(); + return []; } /** @@ -798,16 +798,16 @@ class OutputPage extends ContextSource { } $timestamp = wfTimestamp( TS_MW, $timestamp ); - $modifiedTimes = array( + $modifiedTimes = [ 'page' => $timestamp, 'user' => $this->getUser()->getTouched(), 'epoch' => $config->get( 'CacheEpoch' ) - ); + ]; if ( $config->get( 'UseSquid' ) ) { // bug 44570: the core page itself may not change, but resources might $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - $config->get( 'SquidMaxage' ) ); } - Hooks::run( 'OutputPageCheckLastModified', array( &$modifiedTimes ) ); + Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes ] ); $maxModified = max( $modifiedTimes ); $this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified ); @@ -905,7 +905,7 @@ class OutputPage extends ContextSource { */ public function setIndexPolicy( $policy ) { $policy = trim( $policy ); - if ( in_array( $policy, array( 'index', 'noindex' ) ) ) { + if ( in_array( $policy, [ 'index', 'noindex' ] ) ) { $this->mIndexPolicy = $policy; } } @@ -919,7 +919,7 @@ class OutputPage extends ContextSource { */ public function setFollowPolicy( $policy ) { $policy = trim( $policy ); - if ( in_array( $policy, array( 'follow', 'nofollow' ) ) ) { + if ( in_array( $policy, [ 'follow', 'nofollow' ] ) ) { $this->mFollowPolicy = $policy; } } @@ -1051,12 +1051,12 @@ class OutputPage extends ContextSource { * @return Message * @since 1.25 */ - public static function buildBacklinkSubtitle( Title $title, $query = array() ) { + public static function buildBacklinkSubtitle( Title $title, $query = [] ) { if ( $title->isRedirect() ) { $query['redirect'] = 'no'; } return wfMessage( 'backlinksubtitle' ) - ->rawParams( Linker::link( $title, null, array(), $query ) ); + ->rawParams( Linker::link( $title, null, [], $query ) ); } /** @@ -1065,7 +1065,7 @@ class OutputPage extends ContextSource { * @param Title $title Title to link to * @param array $query Array of additional parameters to include in the link */ - public function addBacklinkSubtitle( Title $title, $query = array() ) { + public function addBacklinkSubtitle( Title $title, $query = [] ) { $this->addSubtitle( self::buildBacklinkSubtitle( $title, $query ) ); } @@ -1073,7 +1073,7 @@ class OutputPage extends ContextSource { * Clear the subtitles */ public function clearSubtitle() { - $this->mSubtitle = array(); + $this->mSubtitle = []; } /** @@ -1148,7 +1148,7 @@ class OutputPage extends ContextSource { if ( $show ) { $this->setFeedAppendQuery( false ); } else { - $this->mFeedLinks = array(); + $this->mFeedLinks = []; } } @@ -1162,7 +1162,7 @@ class OutputPage extends ContextSource { * default links */ public function setFeedAppendQuery( $val ) { - $this->mFeedLinks = array(); + $this->mFeedLinks = []; foreach ( $this->getConfig()->get( 'AdvertisedFeedTypes' ) as $type ) { $query = "feed=$type"; @@ -1298,14 +1298,14 @@ class OutputPage extends ContextSource { } # Add the links to a LinkBatch - $arr = array( NS_CATEGORY => $categories ); + $arr = [ NS_CATEGORY => $categories ]; $lb = new LinkBatch; $lb->setArray( $arr ); # Fetch existence plus the hiddencat property $dbr = wfGetDB( DB_SLAVE ); - $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_len', - 'page_is_redirect', 'page_latest', 'pp_value' ); + $fields = [ 'page_id', 'page_namespace', 'page_title', 'page_len', + 'page_is_redirect', 'page_latest', 'pp_value' ]; if ( $this->getConfig()->get( 'ContentHandlerUseDB' ) ) { $fields[] = 'page_content_model'; @@ -1314,15 +1314,15 @@ class OutputPage extends ContextSource { $fields[] = 'page_lang'; } - $res = $dbr->select( array( 'page', 'page_props' ), + $res = $dbr->select( [ 'page', 'page_props' ], $fields, $lb->constructSet( 'page', $dbr ), __METHOD__, - array(), - array( 'page_props' => array( 'LEFT JOIN', array( + [], + [ 'page_props' => [ 'LEFT JOIN', [ 'pp_propname' => 'hiddencat', 'pp_page = page_id' - ) ) ) + ] ] ] ); # Add the results to the link cache @@ -1341,7 +1341,7 @@ class OutputPage extends ContextSource { # Add the remaining categories to the skin if ( Hooks::run( 'OutputPageMakeCategoryLinks', - array( &$this, $categories, &$this->mCategoryLinks ) ) + [ &$this, $categories, &$this->mCategoryLinks ] ) ) { foreach ( $categories as $category => $type ) { // array keys will cast numeric category names to ints, so cast back to string @@ -1368,7 +1368,7 @@ class OutputPage extends ContextSource { * @param array $categories Mapping category name => sort key */ public function setCategoryLinks( array $categories ) { - $this->mCategoryLinks = array(); + $this->mCategoryLinks = []; $this->addCategoryLinks( $categories ); } @@ -1441,15 +1441,15 @@ class OutputPage extends ContextSource { $link = Html::rawElement( 'a', - array( + [ 'href' => $helpUrl, 'target' => '_blank', 'class' => 'mw-helplink', - ), + ], $text ); - $this->setIndicators( array( 'mw-helplink' => $link ) ); + $this->setIndicators( [ 'mw-helplink' => $link ] ); } /** @@ -1548,7 +1548,7 @@ class OutputPage extends ContextSource { * @param array $attribs * @param string $contents */ - public function addElement( $element, array $attribs = array(), $contents = '' ) { + public function addElement( $element, array $attribs = [], $contents = '' ) { $this->addHTML( Html::element( $element, $attribs, $contents ) ); } @@ -1665,7 +1665,7 @@ class OutputPage extends ContextSource { public function setFileVersion( $file ) { $val = null; if ( $file instanceof File && $file->exists() ) { - $val = array( 'time' => $file->getTimestamp(), 'sha1' => $file->getSha1() ); + $val = [ 'time' => $file->getTimestamp(), 'sha1' => $file->getSha1() ]; } return wfSetVar( $this->mFileVersion, $val, true ); } @@ -1846,9 +1846,9 @@ class OutputPage extends ContextSource { // Link flags are ignored for now, but may in the future be // used to mark individual language links. - $linkFlags = array(); - Hooks::run( 'LanguageLinks', array( $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ) ); - Hooks::run( 'OutputPageParserOutput', array( &$this, $parserOutput ) ); + $linkFlags = []; + Hooks::run( 'LanguageLinks', [ $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ] ); + Hooks::run( 'OutputPageParserOutput', [ &$this, $parserOutput ] ); } /** @@ -1876,7 +1876,7 @@ class OutputPage extends ContextSource { */ public function addParserOutputText( $parserOutput ) { $text = $parserOutput->getText(); - Hooks::run( 'OutputPageBeforeHTML', array( &$this, &$text ) ); + Hooks::run( 'OutputPageBeforeHTML', [ &$this, &$text ] ); $this->addHTML( $text ); } @@ -2013,12 +2013,12 @@ class OutputPage extends ContextSource { $config = $this->getConfig(); $cookies = array_merge( SessionManager::singleton()->getVaryCookies(), - array( + [ 'forceHTTPS', - ), + ], $config->get( 'CacheVaryCookies' ) ); - Hooks::run( 'GetCacheVaryCookies', array( $this, &$cookies ) ); + Hooks::run( 'GetCacheVaryCookies', [ $this, &$cookies ] ); } return $cookies; } @@ -2051,10 +2051,10 @@ class OutputPage extends ContextSource { */ public function addVaryHeader( $header, array $option = null ) { if ( !array_key_exists( $header, $this->mVaryHeader ) ) { - $this->mVaryHeader[$header] = array(); + $this->mVaryHeader[$header] = []; } if ( !is_array( $option ) ) { - $option = array(); + $option = []; } $this->mVaryHeader[$header] = array_unique( array_merge( $this->mVaryHeader[$header], $option ) ); } @@ -2080,7 +2080,7 @@ class OutputPage extends ContextSource { public function getKeyHeader() { $cvCookies = $this->getCacheVaryCookies(); - $cookiesOption = array(); + $cookiesOption = []; foreach ( $cvCookies as $cookieName ) { $cookiesOption[] = 'param=' . $cookieName; } @@ -2090,7 +2090,7 @@ class OutputPage extends ContextSource { $this->addVaryHeader( $header, $options ); } - $headers = array(); + $headers = []; foreach ( $this->mVaryHeader as $header => $option ) { $newheader = $header; if ( is_array( $option ) && count( $option ) > 0 ) { @@ -2120,7 +2120,7 @@ class OutputPage extends ContextSource { $lang = $title->getPageLanguage(); if ( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) { $variants = $lang->getVariants(); - $aloption = array(); + $aloption = []; foreach ( $variants as $variant ) { if ( $variant === $lang->getCode() ) { continue; @@ -2277,7 +2277,7 @@ class OutputPage extends ContextSource { $redirect = $this->mRedirect; $code = $this->mRedirectCode; - if ( Hooks::run( "BeforePageRedirect", array( $this, &$redirect, &$code ) ) ) { + if ( Hooks::run( "BeforePageRedirect", [ $this, &$redirect, &$code ] ) ) { if ( $code == '301' || $code == '303' ) { if ( !$config->get( 'DebugRedirects' ) ) { $response->statusHeader( $code ); @@ -2329,12 +2329,12 @@ class OutputPage extends ContextSource { $modules = $sk->getDefaultModules(); // Enforce various default modules for all skins - $coreModules = array( + $coreModules = [ // Keep this list as small as possible 'site', 'mediawiki.page.startup', 'mediawiki.user', - ); + ]; // Support for high-density display images if enabled if ( $config->get( 'ResponsiveImages' ) ) { @@ -2349,13 +2349,13 @@ class OutputPage extends ContextSource { // Hook that allows last minute changes to the output page, e.g. // adding of CSS or Javascript by extensions. - Hooks::run( 'BeforePageDisplay', array( &$this, &$sk ) ); + Hooks::run( 'BeforePageDisplay', [ &$this, &$sk ] ); $sk->outputPage(); } // This hook allows last minute changes to final overall output by modifying output buffer - Hooks::run( 'AfterFinalPageOutput', array( $this ) ); + Hooks::run( 'AfterFinalPageOutput', [ $this ] ); $this->sendCacheControl(); @@ -2409,7 +2409,7 @@ class OutputPage extends ContextSource { * @param string|Message $msg Message key (string) for page text, or a Message object * @param array $params Message parameters; ignored if $msg is a Message object */ - public function showErrorPage( $title, $msg, $params = array() ) { + public function showErrorPage( $title, $msg, $params = [] ) { if ( !$title instanceof Message ) { $title = $this->msg( $title ); } @@ -2417,7 +2417,7 @@ class OutputPage extends ContextSource { $this->prepareErrorPage( $title ); if ( $msg instanceof Message ) { - if ( $params !== array() ) { + if ( $params !== [] ) { trigger_error( 'Argument ignored: $params. The message parameters argument ' . 'is discarded when the $msg argument is a Message object instead of ' . 'a string.', E_USER_NOTICE ); @@ -2442,7 +2442,7 @@ class OutputPage extends ContextSource { // 1. the user is not logged in // 2. the only error is insufficient permissions (i.e. no block or something else) // 3. the error can be avoided simply by logging in - if ( in_array( $action, array( 'read', 'edit', 'createpage', 'createtalk', 'upload' ) ) + if ( in_array( $action, [ 'read', 'edit', 'createpage', 'createtalk', 'upload' ] ) && $this->getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] ) && ( $errors[0][0] == 'badaccess-groups' || $errors[0][0] == 'badaccess-group0' ) && ( User::groupHasPermission( 'user', $action ) @@ -2468,7 +2468,7 @@ class OutputPage extends ContextSource { $displayReturnto = Title::newMainPage(); } - $query = array(); + $query = []; if ( $returnto ) { $query['returnto'] = $returnto->getPrefixedText(); @@ -2484,7 +2484,7 @@ class OutputPage extends ContextSource { $loginLink = Linker::linkKnown( SpecialPage::getTitleFor( 'Userlogin' ), $this->msg( 'loginreqlink' )->escaped(), - array(), + [], $query ); @@ -2539,13 +2539,13 @@ class OutputPage extends ContextSource { foreach ( $errors as $error ) { $text .= '
  • '; - $text .= call_user_func_array( array( $this, 'msg' ), $error )->plain(); + $text .= call_user_func_array( [ $this, 'msg' ], $error )->plain(); $text .= "
  • \n"; } $text .= ''; } else { $text .= "
    \n" . - call_user_func_array( array( $this, 'msg' ), reset( $errors ) )->plain() . + call_user_func_array( [ $this, 'msg' ], reset( $errors ) )->plain() . "\n
    "; } @@ -2597,8 +2597,8 @@ class OutputPage extends ContextSource { $message = $lag < $config->get( 'SlaveLagCritical' ) ? 'lag-warn-normal' : 'lag-warn-high'; - $wrap = Html::rawElement( 'div', array( 'class' => "mw-{$message}" ), "\n$1\n" ); - $this->wrapWikiMsg( "$wrap\n", array( $message, $this->getLanguage()->formatNum( $lag ) ) ); + $wrap = Html::rawElement( 'div', [ 'class' => "mw-{$message}" ], "\n$1\n" ); + $this->wrapWikiMsg( "$wrap\n", [ $message, $this->getLanguage()->formatNum( $lag ) ] ); } } @@ -2636,9 +2636,9 @@ class OutputPage extends ContextSource { * @param string $text Text of the link (input is not escaped) * @param array $options Options array to pass to Linker */ - public function addReturnTo( $title, array $query = array(), $text = null, $options = array() ) { + public function addReturnTo( $title, array $query = [], $text = null, $options = [] ) { $link = $this->msg( 'returnto' )->rawParams( - Linker::link( $title, $text, array(), $query, $options ) )->escaped(); + Linker::link( $title, $text, [], $query, $options ) )->escaped(); $this->addHTML( "

    {$link}

    \n" ); } @@ -2707,7 +2707,7 @@ class OutputPage extends ContextSource { // Our XML declaration is output by Html::htmlHeader. // http://www.whatwg.org/html/semantics.html#attr-meta-http-equiv-content-type // http://www.whatwg.org/html/semantics.html#charset - $ret .= Html::element( 'meta', array( 'charset' => 'UTF-8' ) ) . "\n"; + $ret .= Html::element( 'meta', [ 'charset' => 'UTF-8' ] ) . "\n"; } $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n"; @@ -2728,7 +2728,7 @@ class OutputPage extends ContextSource { $ret .= "$closeHead\n"; } - $bodyClasses = array(); + $bodyClasses = []; $bodyClasses[] = 'mediawiki'; # Classes for LTR/RTL directionality support @@ -2745,14 +2745,14 @@ class OutputPage extends ContextSource { $bodyClasses[] = 'action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) ); - $bodyAttrs = array(); + $bodyAttrs = []; // While the implode() is not strictly needed, it's used for backwards compatibility // (this used to be built as a string and hooks likely still expect that). $bodyAttrs['class'] = implode( ' ', $bodyClasses ); // Allow skins and extensions to add body attributes they need $sk->addToBodyAttributes( $this, $bodyAttrs ); - Hooks::run( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) ); + Hooks::run( 'OutputPageBodyAttributes', [ $this, $sk, &$bodyAttrs ] ); $ret .= Html::openElement( 'body', $bodyAttrs ) . "\n"; @@ -2784,15 +2784,15 @@ class OutputPage extends ContextSource { * @param array $extraQuery [optional] Array with extra query parameters for the request * @return array A list of HTML strings and array of client loader preset states */ - public function makeResourceLoaderLink( $modules, $only, array $extraQuery = array() ) { + public function makeResourceLoaderLink( $modules, $only, array $extraQuery = [] ) { $modules = (array)$modules; - $links = array( + $links = [ // List of html strings - 'html' => array(), + 'html' => [], // Associative array of module names and their states - 'states' => array(), - ); + 'states' => [], + ]; if ( !count( $modules ) ) { return $links; @@ -2820,7 +2820,7 @@ class OutputPage extends ContextSource { } // Create keyed-by-source and then keyed-by-group list of module objects from modules list - $sortedModules = array(); + $sortedModules = []; $resourceLoader = $this->getResourceLoader(); foreach ( $modules as $name ) { $module = $resourceLoader->getModule( $name ); @@ -2851,7 +2851,7 @@ class OutputPage extends ContextSource { // Create a fake request based on the one we are about to make so modules return // correct timestamp and emptiness data $query = ResourceLoader::makeLoaderQuery( - array(), // modules; not determined yet + [], // modules; not determined yet $this->getLanguage()->getCode(), $this->getSkin()->getSkinName(), $user, @@ -2922,14 +2922,14 @@ class OutputPage extends ContextSource { } else { if ( $context->getRaw() || $isRaw ) { // Startup module can't load itself, needs to use ', diff --git a/includes/libs/ArrayUtils.php b/includes/libs/ArrayUtils.php index f93402108a..fb35801130 100644 --- a/includes/libs/ArrayUtils.php +++ b/includes/libs/ArrayUtils.php @@ -47,7 +47,7 @@ class ArrayUtils { * function was introduced. */ public static function consistentHashSort( &$array, $key, $separator = "\000" ) { - $hashes = array(); + $hashes = []; foreach ( $array as $elt ) { $hashes[$elt] = md5( $elt . $separator . $key ); } @@ -158,11 +158,11 @@ class ArrayUtils { public static function arrayDiffAssocRecursive( $array1 ) { $arrays = func_get_args(); array_shift( $arrays ); - $ret = array(); + $ret = []; foreach ( $array1 as $key => $value ) { if ( is_array( $value ) ) { - $args = array( $value ); + $args = [ $value ]; foreach ( $arrays as $array ) { if ( isset( $array[$key] ) ) { $args[] = $array[$key]; diff --git a/includes/libs/BufferingStatsdDataFactory.php b/includes/libs/BufferingStatsdDataFactory.php index a0020dabb3..9c18b10f10 100644 --- a/includes/libs/BufferingStatsdDataFactory.php +++ b/includes/libs/BufferingStatsdDataFactory.php @@ -33,7 +33,7 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactory; * @since 1.25 */ class BufferingStatsdDataFactory extends StatsdDataFactory { - protected $buffer = array(); + protected $buffer = []; public function __construct( $prefix ) { parent::__construct(); @@ -54,7 +54,7 @@ class BufferingStatsdDataFactory extends StatsdDataFactory { $key = preg_replace( '/[:.]+/', '.', $key ); $key = preg_replace( '/[^a-z0-9.]+/i', '_', $key ); $key = trim( $key, '_.' ); - return str_replace( array( '._', '_.' ), '.', $key ); + return str_replace( [ '._', '_.' ], '.', $key ); } public function produceStatsdData( diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 246de75c99..5f4dda9703 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -45,7 +45,7 @@ class CSSMin { /* Protected Static Members */ /** @var array List of common image files extensions and MIME-types */ - protected static $mimeTypes = array( + protected static $mimeTypes = [ 'gif' => 'image/gif', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', @@ -55,7 +55,7 @@ class CSSMin { 'tiff' => 'image/tiff', 'xbm' => 'image/x-xbitmap', 'svg' => 'image/svg+xml', - ); + ]; /* Static Methods */ @@ -73,7 +73,7 @@ class CSSMin { */ public static function getLocalFileReferences( $source, $path = null ) { if ( $path === null ) { - return array(); + return []; } $files = self::getAllLocalFileReferences( $source, $path ); @@ -97,7 +97,7 @@ class CSSMin { public static function getAllLocalFileReferences( $source, $path ) { $stripped = preg_replace( '/' . self::COMMENT_REGEX . '/s', '', $source ); $path = rtrim( $path, '/' ) . '/'; - $files = array(); + $files = []; $rFlags = PREG_OFFSET_CAPTURE | PREG_SET_ORDER; if ( preg_match_all( '/' . self::URL_REGEX . '/', $stripped, $matches, $rFlags ) ) { @@ -192,7 +192,7 @@ class CSSMin { if ( strstr( $value, "\0" ) ) { throw new Exception( "Invalid character in CSS string" ); } - $value = strtr( $value, array( '\\' => '\\\\', '"' => '\\"' ) ); + $value = strtr( $value, [ '\\' => '\\\\', '"' => '\\"' ] ); $value = preg_replace_callback( '/[\x01-\x1f\x7f-\x9f]/', function ( $match ) { return '\\' . base_convert( ord( $match[0] ), 10, 16 ) . ' '; }, $value ); @@ -239,7 +239,7 @@ class CSSMin { if ( preg_match( '!^[\w\d:@/~.%+;,?&=-]+$!', $url ) ) { return "url($url)"; } else { - return 'url("' . strtr( $url, array( '\\' => '\\\\', '"' => '\\"' ) ) . '")'; + return 'url("' . strtr( $url, [ '\\' => '\\\\', '"' => '\\"' ] ) . '")'; } } @@ -277,7 +277,7 @@ class CSSMin { // Replace all comments by a placeholder so they will not interfere with the remapping. // Warning: This will also catch on anything looking like the start of a comment between // quotation marks (e.g. "foo /* bar"). - $comments = array(); + $comments = []; $pattern = '/(?!' . CSSMin::EMBED_REGEX . ')(' . CSSMin::COMMENT_REGEX . ')/s'; @@ -332,7 +332,7 @@ class CSSMin { if ( $embedData ) { // Remember the occurring MIME types to avoid fallbacks when embedding some files. - $mimeTypes = array(); + $mimeTypes = []; $ruleWithEmbedded = preg_replace_callback( $pattern, @@ -361,7 +361,7 @@ class CSSMin { ); // Are all referenced images SVGs? - $needsEmbedFallback = $mimeTypes !== array( 'image/svg+xml' => true ); + $needsEmbedFallback = $mimeTypes !== [ 'image/svg+xml' => true ]; } if ( !$embedData || $ruleWithEmbedded === $ruleWithRemapped ) { @@ -483,9 +483,9 @@ class CSSMin { public static function minify( $css ) { return trim( str_replace( - array( '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ), - array( ';', ':', '{', '{', ',', '}', '}' ), - preg_replace( array( '/\s+/', '/\/\*.*?\*\//s' ), array( ' ', '' ), $css ) + [ '; ', ': ', ' {', '{ ', ', ', '} ', ';}' ], + [ ';', ':', '{', '{', ',', '}', '}' ], + preg_replace( [ '/\s+/', '/\/\*.*?\*\//s' ], [ ' ', '' ], $css ) ) ); } diff --git a/includes/libs/Cookie.php b/includes/libs/Cookie.php index 0fe944443f..cc236e289c 100644 --- a/includes/libs/Cookie.php +++ b/includes/libs/Cookie.php @@ -208,7 +208,7 @@ class Cookie { } class CookieJar { - private $cookie = array(); + private $cookie = []; /** * Set a cookie in the cookie jar. Make sure only one cookie per-name exists. @@ -237,7 +237,7 @@ class CookieJar { * @return string */ public function serializeToHttpRequest( $path, $domain ) { - $cookies = array(); + $cookies = []; foreach ( $this->cookie as $c ) { $serialized = $c->serializeToHttpRequest( $path, $domain ); @@ -268,7 +268,7 @@ class CookieJar { if ( count( $bit ) >= 1 ) { list( $name, $value ) = explode( '=', array_shift( $bit ), 2 ); - $attr = array(); + $attr = []; foreach ( $bit as $piece ) { $parts = explode( '=', $piece ); diff --git a/includes/libs/GenericArrayObject.php b/includes/libs/GenericArrayObject.php index 93ae83b272..dec55c9540 100644 --- a/includes/libs/GenericArrayObject.php +++ b/includes/libs/GenericArrayObject.php @@ -77,7 +77,7 @@ abstract class GenericArrayObject extends ArrayObject { * @param string $iterator_class */ public function __construct( $input = null, $flags = 0, $iterator_class = 'ArrayIterator' ) { - parent::__construct( array(), $flags, $iterator_class ); + parent::__construct( [], $flags, $iterator_class ); if ( !is_null( $input ) ) { foreach ( $input as $offset => $value ) { @@ -198,10 +198,10 @@ abstract class GenericArrayObject extends ArrayObject { * @return array */ protected function getSerializationData() { - return array( + return [ 'data' => $this->getArrayCopy(), 'index' => $this->indexOffset, - ); + ]; } /** diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php index e7a10997cc..70ce31d713 100644 --- a/includes/libs/HashRing.php +++ b/includes/libs/HashRing.php @@ -28,14 +28,14 @@ */ class HashRing { /** @var Array (location => weight) */ - protected $sourceMap = array(); + protected $sourceMap = []; /** @var Array (location => (start, end)) */ - protected $ring = array(); + protected $ring = []; /** @var Array (location => (start, end)) */ protected $liveRing; /** @var Array (location => UNIX timestamp) */ - protected $ejectionExpiries = array(); + protected $ejectionExpiries = []; /** @var integer UNIX timestamp */ protected $ejectionNextExpiry = INF; @@ -53,7 +53,7 @@ class HashRing { } $this->sourceMap = $map; // Sort the locations based on the hash of their names - $hashes = array(); + $hashes = []; foreach ( $map as $location => $weight ) { $hashes[$location] = sha1( $location ); } @@ -62,7 +62,7 @@ class HashRing { } ); // Fit the map to weight-proportionate one with a space of size RING_SIZE $sum = array_sum( $map ); - $standardMap = array(); + $standardMap = []; foreach ( $map as $location => $weight ) { $standardMap[$location] = (int)floor( $weight / $sum * self::RING_SIZE ); } @@ -70,7 +70,7 @@ class HashRing { $index = 0; foreach ( $standardMap as $location => $weight ) { // Location covers half-closed interval [$index,$index + $weight) - $this->ring[$location] = array( $index, $index + $weight ); + $this->ring[$location] = [ $index, $index + $weight ]; $index += $weight; } // Make sure the last location covers what is left @@ -98,7 +98,7 @@ class HashRing { * @return array List of locations */ public function getLocations( $item, $limit ) { - $locations = array(); + $locations = []; $primaryLocation = null; $spot = hexdec( substr( sha1( $item ), 0, 7 ) ); // first 28 bits foreach ( $this->ring as $location => $range ) { @@ -190,7 +190,7 @@ class HashRing { $this->ejectionNextExpiry = min( $this->ejectionExpiries ); } else { // common case; avoid recalculating ring $this->liveRing = clone $this; - $this->liveRing->ejectionExpiries = array(); + $this->liveRing->ejectionExpiries = []; $this->liveRing->ejectionNextExpiry = INF; $this->liveRing->liveRing = null; diff --git a/includes/libs/HttpStatus.php b/includes/libs/HttpStatus.php index 3d7dee7da1..72fc333869 100644 --- a/includes/libs/HttpStatus.php +++ b/includes/libs/HttpStatus.php @@ -32,7 +32,7 @@ class HttpStatus { * @return string|null Message, or null if $code is not known */ public static function getMessage( $code ) { - static $statusMessage = array( + static $statusMessage = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', @@ -83,7 +83,7 @@ class HttpStatus { 505 => 'HTTP Version Not Supported', 507 => 'Insufficient Storage', 511 => 'Network Authentication Required', - ); + ]; return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null; } diff --git a/includes/libs/IEContentAnalyzer.php b/includes/libs/IEContentAnalyzer.php index c31a35278a..0d1e527ba6 100644 --- a/includes/libs/IEContentAnalyzer.php +++ b/includes/libs/IEContentAnalyzer.php @@ -28,35 +28,35 @@ class IEContentAnalyzer { /** * Relevant data taken from the type table in IE 5 */ - protected $baseTypeTable = array( - 'ambiguous' /*1*/ => array( + protected $baseTypeTable = [ + 'ambiguous' /*1*/ => [ 'text/plain', 'application/octet-stream', 'application/x-netcdf', // [sic] - ), - 'text' /*3*/ => array( + ], + 'text' /*3*/ => [ 'text/richtext', 'image/x-bitmap', 'application/postscript', 'application/base64', 'application/macbinhex40', 'application/x-cdf', 'text/scriptlet' - ), - 'binary' /*4*/ => array( + ], + 'binary' /*4*/ => [ 'application/pdf', 'audio/x-aiff', 'audio/basic', 'audio/wav', 'image/gif', 'image/pjpeg', 'image/jpeg', 'image/tiff', 'image/x-png', 'image/png', 'image/bmp', 'image/x-jg', 'image/x-art', 'image/x-emf', 'image/x-wmf', 'video/avi', 'video/x-msvideo', 'video/mpeg', 'application/x-compressed', 'application/x-zip-compressed', 'application/x-gzip-compressed', 'application/java', 'application/x-msdownload' - ), - 'html' /*5*/ => array( 'text/html' ), - ); + ], + 'html' /*5*/ => [ 'text/html' ], + ]; /** * Changes to the type table in later versions of IE */ - protected $addedTypes = array( - 'ie07' => array( - 'text' => array( 'text/xml', 'application/xml' ) - ), - ); + protected $addedTypes = [ + 'ie07' => [ + 'text' => [ 'text/xml', 'application/xml' ] + ], + ]; /** * An approximation of the "Content Type" values in HKEY_CLASSES_ROOT in a @@ -64,7 +64,7 @@ class IEContentAnalyzer { * * Used for extension to MIME type mapping if detection fails. */ - protected $registry = array( + protected $registry = [ '.323' => 'text/h323', '.3g2' => 'video/3gpp2', '.3gp' => 'video/3gpp', @@ -297,19 +297,19 @@ class IEContentAnalyzer { '.xml' => 'text/xml', '.xps' => 'application/vnd.ms-xpsdocument', '.xsl' => 'text/xml', - ); + ]; /** * IE versions which have been analysed to bring you this class, and for * which some substantive difference exists. These will appear as keys * in the return value of getRealMimesFromData(). The names are chosen to sort correctly. */ - protected $versions = array( 'ie05', 'ie06', 'ie07', 'ie07.strict', 'ie07.nohtml' ); + protected $versions = [ 'ie05', 'ie06', 'ie07', 'ie07.strict', 'ie07.nohtml' ]; /** * Type table with versions expanded */ - protected $typeTable = array(); + protected $typeTable = []; /** constructor */ function __construct() { @@ -337,7 +337,7 @@ class IEContentAnalyzer { */ public function getRealMimesFromData( $fileName, $chunk, $proposed ) { $types = $this->getMimesFromData( $fileName, $chunk, $proposed ); - $types = array_map( array( $this, 'translateMimeType' ), $types ); + $types = array_map( [ $this, 'translateMimeType' ], $types ); return $types; } @@ -348,7 +348,7 @@ class IEContentAnalyzer { * @return string */ public function translateMimeType( $type ) { - static $table = array( + static $table = [ 'image/pjpeg' => 'image/jpeg', 'image/x-png' => 'image/png', 'image/x-wmf' => 'application/x-msmetafile', @@ -357,7 +357,7 @@ class IEContentAnalyzer { 'application/x-compressed' => 'application/x-compress', 'application/x-gzip-compressed' => 'application/x-gzip', 'audio/mid' => 'audio/midi', - ); + ]; if ( isset( $table[$type] ) ) { $type = $table[$type]; } @@ -374,7 +374,7 @@ class IEContentAnalyzer { * @return Array: map of IE version to detected MIME type */ public function getMimesFromData( $fileName, $chunk, $proposed ) { - $types = array(); + $types = []; foreach ( $this->versions as $version ) { $types[$version] = $this->getMimeTypeForVersion( $version, $fileName, $chunk, $proposed ); } @@ -685,16 +685,16 @@ class IEContentAnalyzer { * @return array */ protected function sampleData( $version, $chunk ) { - $found = array(); - $counters = array( + $found = []; + $counters = [ 'ctrl' => 0, 'high' => 0, 'low' => 0, 'lf' => 0, 'cr' => 0, 'ff' => 0 - ); - $htmlTags = array( + ]; + $htmlTags = [ 'html', 'head', 'title', @@ -705,7 +705,7 @@ class IEContentAnalyzer { 'img', 'plaintext', 'table' - ); + ]; $rdfUrl = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; $rdfPurl = 'http://purl.org/rss/1.0/'; $xbmMagic1 = '#define'; @@ -828,7 +828,7 @@ class IEContentAnalyzer { $found['binhex'] = true; } } - return array( 'found' => $found, 'counters' => $counters ); + return [ 'found' => $found, 'counters' => $counters ]; } /** diff --git a/includes/libs/IEUrlExtension.php b/includes/libs/IEUrlExtension.php index 216d9b7860..16163fb304 100644 --- a/includes/libs/IEUrlExtension.php +++ b/includes/libs/IEUrlExtension.php @@ -59,7 +59,7 @@ class IEUrlExtension { * @param array $extWhitelist Extensions which are allowed, assumed harmless. * @return bool */ - public static function areServerVarsBad( $vars, $extWhitelist = array() ) { + public static function areServerVarsBad( $vars, $extWhitelist = [] ) { // Check QUERY_STRING or REQUEST_URI if ( isset( $vars['SERVER_SOFTWARE'] ) && isset( $vars['REQUEST_URI'] ) @@ -97,7 +97,7 @@ class IEUrlExtension { * URL, and which should be allowed. * @return bool */ - public static function isUrlExtensionBad( $urlPart, $extWhitelist = array() ) { + public static function isUrlExtensionBad( $urlPart, $extWhitelist = [] ) { if ( strval( $urlPart ) === '' ) { return false; } @@ -108,7 +108,7 @@ class IEUrlExtension { return false; } - if ( in_array( $extension, array( 'php', 'php5' ) ) ) { + if ( in_array( $extension, [ 'php', 'php5' ] ) ) { // Script extension, OK return false; } @@ -137,7 +137,7 @@ class IEUrlExtension { * @param $extWhitelist array * @return bool|string */ - public static function fixUrlForIE6( $url, $extWhitelist = array() ) { + public static function fixUrlForIE6( $url, $extWhitelist = [] ) { $questionPos = strpos( $url, '?' ); if ( $questionPos === false ) { $beforeQuery = $url . '?'; @@ -256,10 +256,10 @@ class IEUrlExtension { * */ public static function haveUndecodedRequestUri( $serverSoftware ) { - static $whitelist = array( + static $whitelist = [ 'Apache', 'Zeus', - 'LiteSpeed' ); + 'LiteSpeed' ]; if ( preg_match( '/^(.*?)($|\/| )/', $serverSoftware, $m ) ) { return in_array( $m[1], $whitelist ); } else { diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index a49eb0106c..2370ed3a8a 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -33,7 +33,7 @@ use Wikimedia\Assert\Assert; */ class MapCacheLRU { /** @var array */ - protected $cache = array(); // (key => value) + protected $cache = []; // (key => value) protected $maxCacheKeys; // integer; max entries @@ -110,7 +110,7 @@ class MapCacheLRU { */ public function clear( $keys = null ) { if ( $keys === null ) { - $this->cache = array(); + $this->cache = []; } else { foreach ( (array)$keys as $key ) { unset( $this->cache[$key] ); diff --git a/includes/libs/MappedIterator.php b/includes/libs/MappedIterator.php index 7fdde8a81a..73ffb14747 100644 --- a/includes/libs/MappedIterator.php +++ b/includes/libs/MappedIterator.php @@ -32,7 +32,7 @@ class MappedIterator extends FilterIterator { /** @var callable */ protected $aCallback; /** @var array */ - protected $cache = array(); + protected $cache = []; protected $rewound = false; // boolean; whether rewind() has been called @@ -51,7 +51,7 @@ class MappedIterator extends FilterIterator { * @param array $options Options map (includes "accept") (since 1.22) * @throws UnexpectedValueException */ - public function __construct( $iter, $vCallback, array $options = array() ) { + public function __construct( $iter, $vCallback, array $options = [] ) { if ( is_array( $iter ) ) { $baseIterator = new ArrayIterator( $iter ); } elseif ( $iter instanceof Iterator ) { @@ -65,13 +65,13 @@ class MappedIterator extends FilterIterator { } public function next() { - $this->cache = array(); + $this->cache = []; parent::next(); } public function rewind() { $this->rewound = true; - $this->cache = array(); + $this->cache = []; parent::rewind(); } diff --git a/includes/libs/MemoizedCallable.php b/includes/libs/MemoizedCallable.php index 14de6b9034..39faf3d08f 100644 --- a/includes/libs/MemoizedCallable.php +++ b/includes/libs/MemoizedCallable.php @@ -102,7 +102,7 @@ class MemoizedCallable { * @param array $args Parameters for memoized function or method. * @return mixed The memoized callable's return value. */ - public function invokeArgs( Array $args = array() ) { + public function invokeArgs( Array $args = [] ) { foreach ( $args as $arg ) { if ( $arg !== null && !is_scalar( $arg ) ) { throw new InvalidArgumentException( @@ -144,7 +144,7 @@ class MemoizedCallable { * @param array $args * @param int $ttl */ - public static function call( $callable, Array $args = array(), $ttl = 3600 ) { + public static function call( $callable, Array $args = [], $ttl = 3600 ) { $instance = new self( $callable, $ttl ); return $instance->invokeArgs( $args ); } diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php index 6ad77411dc..4e19025bbc 100644 --- a/includes/libs/MultiHttpClient.php +++ b/includes/libs/MultiHttpClient.php @@ -75,9 +75,9 @@ class MultiHttpClient { throw new Exception( "Cannot find CA bundle: " . $this->caBundlePath ); } } - static $opts = array( + static $opts = [ 'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy', 'userAgent' - ); + ]; foreach ( $opts as $key ) { if ( isset( $options[$key] ) ) { $this->$key = $options[$key]; @@ -104,8 +104,8 @@ class MultiHttpClient { * - reqTimeout : post-connection timeout per request (seconds) * @return array Response array for request */ - final public function run( array $req, array $opts = array() ) { - $req = $this->runMulti( array( $req ), $opts ); + final public function run( array $req, array $opts = [] ) { + $req = $this->runMulti( [ $req ], $opts ); return $req[0]['response']; } @@ -135,19 +135,19 @@ class MultiHttpClient { * @return array $reqs With response array populated for each * @throws Exception */ - public function runMulti( array $reqs, array $opts = array() ) { + public function runMulti( array $reqs, array $opts = [] ) { $chm = $this->getCurlMulti(); // Normalize $reqs and add all of the required cURL handles... - $handles = array(); + $handles = []; foreach ( $reqs as $index => &$req ) { - $req['response'] = array( + $req['response'] = [ 'code' => 0, 'reason' => '', - 'headers' => array(), + 'headers' => [], 'body' => '', 'error' => '' - ); + ]; if ( isset( $req[0] ) ) { $req['method'] = $req[0]; // short-form unset( $req[0] ); @@ -161,8 +161,8 @@ class MultiHttpClient { } elseif ( !isset( $req['url'] ) ) { throw new Exception( "Request has no 'url' field set." ); } - $req['query'] = isset( $req['query'] ) ? $req['query'] : array(); - $headers = array(); // normalized headers + $req['query'] = isset( $req['query'] ) ? $req['query'] : []; + $headers = []; // normalized headers if ( isset( $req['headers'] ) ) { foreach ( $req['headers'] as $name => $value ) { $headers[strtolower( $name )] = $value; @@ -194,7 +194,7 @@ class MultiHttpClient { // @TODO: use a per-host rolling handle window (e.g. CURLMOPT_MAX_HOST_CONNECTIONS) $batches = array_chunk( $indexes, $this->maxConnsPerHost ); - $infos = array(); + $infos = []; foreach ( $batches as $batch ) { // Attach all cURL handles for this batch @@ -272,7 +272,7 @@ class MultiHttpClient { * @return resource * @throws Exception */ - protected function getCurlHandle( array &$req, array $opts = array() ) { + protected function getCurlHandle( array &$req, array $opts = [] ) { $ch = curl_init(); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, @@ -292,8 +292,8 @@ class MultiHttpClient { $url = $req['url']; // PHP_QUERY_RFC3986 is PHP 5.4+ only $query = str_replace( - array( '+', '%7E' ), - array( '%20', '~' ), + [ '+', '%7E' ], + [ '%20', '~' ], http_build_query( $req['query'], '', '&' ) ); if ( $query != '' ) { @@ -363,7 +363,7 @@ class MultiHttpClient { $req['headers']['user-agent'] = $this->userAgent; } - $headers = array(); + $headers = []; foreach ( $req['headers'] as $name => $value ) { if ( strpos( $name, ': ' ) ) { throw new Exception( "Headers cannot have ':' in the name." ); @@ -375,7 +375,7 @@ class MultiHttpClient { curl_setopt( $ch, CURLOPT_HEADERFUNCTION, function ( $ch, $header ) use ( &$req ) { $length = strlen( $header ); - $matches = array(); + $matches = []; if ( preg_match( "/^(HTTP\/1\.[01]) (\d{3}) (.*)/", $header, $matches ) ) { $req['response']['code'] = (int)$matches[2]; $req['response']['reason'] = trim( $matches[3] ); diff --git a/includes/libs/ObjectFactory.php b/includes/libs/ObjectFactory.php index 2ffc1d3be8..c96a8a1643 100644 --- a/includes/libs/ObjectFactory.php +++ b/includes/libs/ObjectFactory.php @@ -57,7 +57,7 @@ class ObjectFactory { * constructor is non-public or non-existent */ public static function getObjectFromSpec( $spec ) { - $args = isset( $spec['args'] ) ? $spec['args'] : array(); + $args = isset( $spec['args'] ) ? $spec['args'] : []; $expandArgs = !isset( $spec['closure_expansion'] ) || $spec['closure_expansion'] === true; @@ -86,7 +86,7 @@ class ObjectFactory { if ( $expandArgs ) { $margs = static::expandClosures( $margs ); } - call_user_func_array( array( $obj, $method ), $margs ); + call_user_func_array( [ $obj, $method ], $margs ); } } diff --git a/includes/libs/ProcessCacheLRU.php b/includes/libs/ProcessCacheLRU.php index eec31cee56..5a933914c6 100644 --- a/includes/libs/ProcessCacheLRU.php +++ b/includes/libs/ProcessCacheLRU.php @@ -28,10 +28,10 @@ use Wikimedia\Assert\Assert; */ class ProcessCacheLRU { /** @var Array */ - protected $cache = array(); // (key => prop => value) + protected $cache = []; // (key => prop => value) /** @var Array */ - protected $cacheTimes = array(); // (key => prop => UNIX timestamp) + protected $cacheTimes = []; // (key => prop => UNIX timestamp) protected $maxCacheKeys; // integer; max entries @@ -109,8 +109,8 @@ class ProcessCacheLRU { */ public function clear( $keys = null ) { if ( $keys === null ) { - $this->cache = array(); - $this->cacheTimes = array(); + $this->cache = []; + $this->cacheTimes = []; } else { foreach ( (array)$keys as $key ) { unset( $this->cache[$key] ); diff --git a/includes/libs/ReplacementArray.php b/includes/libs/ReplacementArray.php index 02762f36d1..4512a4b13d 100644 --- a/includes/libs/ReplacementArray.php +++ b/includes/libs/ReplacementArray.php @@ -37,7 +37,7 @@ class ReplacementArray { * @return array */ public function __sleep() { - return array( 'data' ); + return [ 'data' ]; } /** diff --git a/includes/libs/RiffExtractor.php b/includes/libs/RiffExtractor.php index f987c59d21..3a8b55e21c 100644 --- a/includes/libs/RiffExtractor.php +++ b/includes/libs/RiffExtractor.php @@ -49,11 +49,11 @@ class RiffExtractor { } // Create basic info structure - $info = array( + $info = [ 'fileSize' => self::extractUInt32( $fileSize ), 'fourCC' => $fourCC, - 'chunks' => array(), - ); + 'chunks' => [], + ]; $numberOfChunks = 0; // Find out the chunks @@ -72,11 +72,11 @@ class RiffExtractor { $intChunkSize = self::extractUInt32( $chunkSize ); // Add chunk info to the info structure - $info['chunks'][] = array( + $info['chunks'][] = [ 'fourCC' => $chunkFourCC, 'start' => $chunkStart, 'size' => $intChunkSize - ); + ]; // Uneven chunks have padding bytes $padding = $intChunkSize % 2; diff --git a/includes/libs/SamplingStatsdClient.php b/includes/libs/SamplingStatsdClient.php index f77b211637..2e780c9728 100644 --- a/includes/libs/SamplingStatsdClient.php +++ b/includes/libs/SamplingStatsdClient.php @@ -61,7 +61,7 @@ class SamplingStatsdClient extends StatsdClient { */ public function send( $data, $sampleRate = 1 ) { if ( !is_array( $data ) ) { - $data = array( $data ); + $data = [ $data ]; } if ( !$data ) { return; @@ -111,7 +111,7 @@ class SamplingStatsdClient extends StatsdClient { * @throws LogicException */ protected function sampleData( $data ) { - $newData = array(); + $newData = []; $mt_rand_max = mt_getrandmax(); foreach ( $data as $item ) { $samplingRate = $item->getSampleRate(); diff --git a/includes/libs/ScopedCallback.php b/includes/libs/ScopedCallback.php index 1ec9eaa627..96075aad66 100644 --- a/includes/libs/ScopedCallback.php +++ b/includes/libs/ScopedCallback.php @@ -36,7 +36,7 @@ class ScopedCallback { * @param array $params Callback arguments (since 1.25) * @throws Exception */ - public function __construct( $callback, array $params = array() ) { + public function __construct( $callback, array $params = [] ) { if ( $callback !== null && !is_callable( $callback ) ) { throw new InvalidArgumentException( "Provided callback is not valid." ); } diff --git a/includes/libs/StatusValue.php b/includes/libs/StatusValue.php index 35de084b5f..b4206a21fc 100644 --- a/includes/libs/StatusValue.php +++ b/includes/libs/StatusValue.php @@ -43,12 +43,12 @@ class StatusValue { /** @var bool */ protected $ok = true; /** @var array */ - protected $errors = array(); + protected $errors = []; /** @var mixed */ public $value; /** @var array Map of (key => bool) to indicate success of each part of batch operations */ - public $success = array(); + public $success = []; /** @var int Counter for batch operations */ public $successCount = 0; /** @var int Counter for batch operations */ @@ -63,7 +63,7 @@ class StatusValue { public static function newFatal( $message /*, parameters...*/ ) { $params = func_get_args(); $result = new static(); - call_user_func_array( array( &$result, 'fatal' ), $params ); + call_user_func_array( [ &$result, 'fatal' ], $params ); return $result; } @@ -142,11 +142,11 @@ class StatusValue { * @param string|MessageSpecifier $message Message key or object */ public function warning( $message /*, parameters... */ ) { - $this->errors[] = array( + $this->errors[] = [ 'type' => 'warning', 'message' => $message, 'params' => array_slice( func_get_args(), 1 ) - ); + ]; } /** @@ -156,11 +156,11 @@ class StatusValue { * @param string|MessageSpecifier $message Message key or object */ public function error( $message /*, parameters... */ ) { - $this->errors[] = array( + $this->errors[] = [ 'type' => 'error', 'message' => $message, 'params' => array_slice( func_get_args(), 1 ) - ); + ]; } /** @@ -170,11 +170,11 @@ class StatusValue { * @param string|MessageSpecifier $message Message key or object */ public function fatal( $message /*, parameters... */ ) { - $this->errors[] = array( + $this->errors[] = [ 'type' => 'error', 'message' => $message, 'params' => array_slice( func_get_args(), 1 ) - ); + ]; $this->ok = false; } @@ -203,7 +203,7 @@ class StatusValue { * @return array */ public function getErrorsByType( $type ) { - $result = array(); + $result = []; foreach ( $this->errors as $error ) { if ( $error['type'] === $type ) { $result[] = $error; @@ -298,7 +298,7 @@ class StatusValue { $params = $error['params']; } else { $key = $error['message']; - $params = array(); + $params = []; } $out .= sprintf( "| %4d | %-25.25s | %-40.40s |\n", diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php index c56ed07a88..d2226b6daa 100644 --- a/includes/libs/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -75,7 +75,7 @@ class StringUtils { if ( $regexes === null ) { $cont = "[\x80-\xbf]"; $after = "(?!$cont)"; // "(?:[^\x80-\xbf]|$)" would work here - $regexes = array( + $regexes = [ // Continuation byte at the start "/^$cont/", @@ -97,7 +97,7 @@ class StringUtils { "/\xf0(?![\x90-\xbf]$cont{2}$after)/", "/[\xf1-\xf3](?!$cont{3}$after)/S", "/\xf4(?![\x80-\x8f]$cont{2}$after)/", - ); + ]; } foreach ( $regexes as $regex ) { @@ -176,7 +176,7 @@ class StringUtils { $encEnd = preg_quote( $endDelim, '!' ); $strcmp = strpos( $flags, 'i' ) === false ? 'strcmp' : 'strcasecmp'; $endLength = strlen( $endDelim ); - $m = array(); + $m = []; while ( $inputPos < strlen( $subject ) && preg_match( "!($encStart)|($encEnd)!S$flags", $subject, $m, PREG_OFFSET_CAPTURE, $inputPos ) @@ -219,10 +219,10 @@ class StringUtils { } elseif ( $tokenType == 'end' ) { if ( $foundStart ) { # Found match - $output .= call_user_func( $callback, array( + $output .= call_user_func( $callback, [ substr( $subject, $outputPos, $tokenOffset + $tokenLength - $outputPos ), substr( $subject, $contentPos, $tokenOffset - $contentPos ) - ) ); + ] ); $foundStart = false; } else { # Non-matching end, write it out diff --git a/includes/libs/Timing.php b/includes/libs/Timing.php index 00ceda3e78..62baaf1e93 100644 --- a/includes/libs/Timing.php +++ b/includes/libs/Timing.php @@ -45,12 +45,12 @@ use Psr\Log\NullLogger; class Timing implements LoggerAwareInterface { /** @var array[] */ - private $entries = array(); + private $entries = []; /** @var LoggerInterface */ protected $logger; - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { $this->clearMarks(); $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() ); } @@ -73,12 +73,12 @@ class Timing implements LoggerAwareInterface { * @return array The mark that has been created. */ public function mark( $markName ) { - $this->entries[$markName] = array( + $this->entries[$markName] = [ 'name' => $markName, 'entryType' => 'mark', 'startTime' => microtime( true ), 'duration' => 0, - ); + ]; return $this->entries[$markName]; } @@ -90,16 +90,16 @@ class Timing implements LoggerAwareInterface { if ( $markName !== null ) { unset( $this->entries[$markName] ); } else { - $this->entries = array( - 'requestStart' => array( + $this->entries = [ + 'requestStart' => [ 'name' => 'requestStart', 'entryType' => 'mark', 'startTime' => isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ? $_SERVER['REQUEST_TIME_FLOAT'] : $_SERVER['REQUEST_TIME'], 'duration' => 0, - ), - ); + ], + ]; } } @@ -142,12 +142,12 @@ class Timing implements LoggerAwareInterface { $endTime = microtime( true ); } - $this->entries[$measureName] = array( + $this->entries[$measureName] = [ 'name' => $measureName, 'entryType' => 'measure', 'startTime' => $startTime, 'duration' => $endTime - $startTime, - ); + ]; return $this->entries[$measureName]; } @@ -176,7 +176,7 @@ class Timing implements LoggerAwareInterface { */ public function getEntriesByType( $entryType ) { $this->sortEntries(); - $entries = array(); + $entries = []; foreach ( $this->entries as $entry ) { if ( $entry['entryType'] === $entryType ) { $entries[] = $entry; diff --git a/includes/libs/Xhprof.php b/includes/libs/Xhprof.php index d2cd0e4ea8..d0f067f6e1 100644 --- a/includes/libs/Xhprof.php +++ b/includes/libs/Xhprof.php @@ -70,20 +70,20 @@ class Xhprof { * * @param array $config */ - public function __construct( array $config = array() ) { + public function __construct( array $config = [] ) { $this->config = array_merge( - array( + [ 'flags' => 0, - 'exclude' => array(), + 'exclude' => [], 'include' => null, 'sort' => 'wt', - ), + ], $config ); - xhprof_enable( $this->config['flags'], array( + xhprof_enable( $this->config['flags'], [ 'ignored_functions' => $this->config['exclude'] - ) ); + ] ); } /** @@ -182,7 +182,7 @@ class Xhprof { $want = array_fill_keys( $this->config['include'], true ); $want['main()'] = true; - $keep = array(); + $keep = []; foreach ( $data as $key => $stats ) { list( $parent, $child ) = self::splitKey( $key ); if ( isset( $want[$parent] ) || isset( $want[$child] ) ) { @@ -223,14 +223,14 @@ class Xhprof { $hasMu = isset( $main['mu'] ); $hasAlloc = isset( $main['alloc'] ); - $this->inclusive = array(); + $this->inclusive = []; foreach ( $this->hieraData as $key => $stats ) { list( $parent, $child ) = self::splitKey( $key ); if ( !isset( $this->inclusive[$child] ) ) { - $this->inclusive[$child] = array( + $this->inclusive[$child] = [ 'ct' => 0, 'wt' => new RunningStat(), - ); + ]; if ( $hasCpu ) { $this->inclusive[$child]['cpu'] = new RunningStat(); } @@ -272,14 +272,14 @@ class Xhprof { $percent = ( isset( $main[$name] ) && $main[$name] ) ? 100 * $total / $main[$name] : 0; - $this->inclusive[$func][$name] = array( + $this->inclusive[$func][$name] = [ 'total' => $total, 'min' => $value->min, 'mean' => $value->m1, 'max' => $value->max, 'variance' => $value->m2, 'percent' => $percent, - ); + ]; } } } @@ -319,8 +319,8 @@ class Xhprof { $this->complete[$func][$stat]['exclusive'] = $value['total']; } // Add sapce for call tree information to be filled in later - $this->complete[$func]['calls'] = array(); - $this->complete[$func]['subcalls'] = array(); + $this->complete[$func]['calls'] = []; + $this->complete[$func]['subcalls'] = []; } foreach ( $this->hieraData as $key => $stats ) { @@ -367,7 +367,7 @@ class Xhprof { if ( isset( $edges[$function]['calls'] ) ) { return array_keys( $edges[$function]['calls'] ); } else { - return array(); + return []; } } @@ -383,7 +383,7 @@ class Xhprof { if ( isset( $edges[$function]['subcalls'] ) ) { return array_keys( $edges[$function]['subcalls'] ); } else { - return array(); + return []; } } @@ -396,9 +396,9 @@ class Xhprof { public function getCriticalPath( $metric = 'wt' ) { $this->stop(); $func = 'main()'; - $path = array( + $path = [ $func => $this->hieraData[$func], - ); + ]; while ( $func ) { $callees = $this->getCallees( $func ); $maxCallee = null; diff --git a/includes/libs/XmlTypeCheck.php b/includes/libs/XmlTypeCheck.php index 34afb68914..b3ea08da9c 100644 --- a/includes/libs/XmlTypeCheck.php +++ b/includes/libs/XmlTypeCheck.php @@ -56,12 +56,12 @@ class XmlTypeCheck { * data to the top string of the stack, then pop off the string and process it when the * element is closed. */ - protected $elementData = array(); + protected $elementData = []; /** * A stack of element names and attributes, as we process them. */ - protected $elementDataContext = array(); + protected $elementDataContext = []; /** * Current depth of the data stack. @@ -71,9 +71,9 @@ class XmlTypeCheck { /** * Additional parsing options */ - private $parserOptions = array( + private $parserOptions = [ 'processing_instruction_handler' => '', - ); + ]; /** * @param string $input a filename or string containing the XML element @@ -87,7 +87,7 @@ class XmlTypeCheck { * @param array $options list of additional parsing options: * processing_instruction_handler: Callback for xml_set_processing_instruction_handler */ - function __construct( $input, $filterCallback = null, $isFile = true, $options = array() ) { + function __construct( $input, $filterCallback = null, $isFile = true, $options = [] ) { $this->filterCallback = $filterCallback; $this->parserOptions = array_merge( $this->parserOptions, $options ); $this->validateFromInput( $input, $isFile ); @@ -165,7 +165,7 @@ class XmlTypeCheck { } private function readNext( XMLReader $reader ) { - set_error_handler( array( $this, 'XmlErrorHandler' ) ); + set_error_handler( [ $this, 'XmlErrorHandler' ] ); $ret = $reader->read(); restore_error_handler(); return $ret; @@ -258,7 +258,7 @@ class XmlTypeCheck { * @return array of attributes */ private function getAttributesArray( XMLReader $r ) { - $attrs = array(); + $attrs = []; while ( $r->moveToNextAttribute() ) { if ( $r->namespaceURI === 'http://www.w3.org/2000/xmlns/' ) { // XMLReader treats xmlns attributes as normal @@ -290,7 +290,7 @@ class XmlTypeCheck { * @param $attribs */ private function elementOpen( $name, $attribs ) { - $this->elementDataContext[] = array( $name, $attribs ); + $this->elementDataContext[] = [ $name, $attribs ]; $this->elementData[] = ''; $this->stackDepth++; } diff --git a/includes/libs/composer/ComposerInstalled.php b/includes/libs/composer/ComposerInstalled.php index 5f87b54b1d..9f15078c64 100644 --- a/includes/libs/composer/ComposerInstalled.php +++ b/includes/libs/composer/ComposerInstalled.php @@ -21,15 +21,15 @@ class ComposerInstalled { * @return array */ public function getInstalledDependencies() { - $deps = array(); + $deps = []; foreach ( $this->contents as $installed ) { - $deps[$installed['name']] = array( + $deps[$installed['name']] = [ 'version' => ComposerJson::normalizeVersion( $installed['version'] ), 'type' => $installed['type'], - 'licenses' => isset( $installed['license'] ) ? $installed['license'] : array(), - 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : array(), + 'licenses' => isset( $installed['license'] ) ? $installed['license'] : [], + 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [], 'description' => isset( $installed['description'] ) ? $installed['description']: '', - ); + ]; } ksort( $deps ); diff --git a/includes/libs/composer/ComposerJson.php b/includes/libs/composer/ComposerJson.php index bb55ac6380..311508f7c0 100644 --- a/includes/libs/composer/ComposerJson.php +++ b/includes/libs/composer/ComposerJson.php @@ -26,7 +26,7 @@ class ComposerJson { * @return array */ public function getRequiredDependencies() { - $deps = array(); + $deps = []; if ( isset( $this->contents['require'] ) ) { foreach ( $this->contents['require'] as $package => $version ) { if ( $package !== "php" && strpos( $package, 'ext-' ) !== 0 ) { diff --git a/includes/libs/composer/ComposerLock.php b/includes/libs/composer/ComposerLock.php index 22c33191d7..e93127c167 100644 --- a/includes/libs/composer/ComposerLock.php +++ b/includes/libs/composer/ComposerLock.php @@ -25,15 +25,15 @@ class ComposerLock { * @return array */ public function getInstalledDependencies() { - $deps = array(); + $deps = []; foreach ( $this->contents['packages'] as $installed ) { - $deps[$installed['name']] = array( + $deps[$installed['name']] = [ 'version' => ComposerJson::normalizeVersion( $installed['version'] ), 'type' => $installed['type'], - 'licenses' => isset( $installed['license'] ) ? $installed['license'] : array(), - 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : array(), + 'licenses' => isset( $installed['license'] ) ? $installed['license'] : [], + 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [], 'description' => isset( $installed['description'] ) ? $installed['description']: '', - ); + ]; } return $deps; diff --git a/includes/libs/eventrelayer/EventRelayer.php b/includes/libs/eventrelayer/EventRelayer.php index f95ba3f0e9..c385c38dfb 100644 --- a/includes/libs/eventrelayer/EventRelayer.php +++ b/includes/libs/eventrelayer/EventRelayer.php @@ -35,7 +35,7 @@ abstract class EventRelayer { * @return bool Success */ final public function notify( $channel, $event ) { - return $this->doNotify( $channel, array( $event ) ); + return $this->doNotify( $channel, [ $event ] ); } /** diff --git a/includes/libs/eventrelayer/EventRelayerMCRD.php b/includes/libs/eventrelayer/EventRelayerMCRD.php index 1e8b2a4058..4bcdf123ab 100644 --- a/includes/libs/eventrelayer/EventRelayerMCRD.php +++ b/includes/libs/eventrelayer/EventRelayerMCRD.php @@ -38,7 +38,7 @@ class EventRelayerMCRD extends EventRelayer { $this->baseUrl = $params['mcrdConfig']['url']; - $httpConfig = isset( $params['httpConfig'] ) ? $params['httpConfig'] : array(); + $httpConfig = isset( $params['httpConfig'] ) ? $params['httpConfig'] : []; if ( !isset( $httpConfig['connTimeout'] ) ) { $httpConfig['connTimeout'] = 1; } @@ -54,12 +54,12 @@ class EventRelayerMCRD extends EventRelayer { return true; } - $response = $this->http->run( array( + $response = $this->http->run( [ 'url' => "{$this->baseUrl}/relayer/api/v1.0/" . rawurlencode( $channel ), 'method' => 'POST', - 'body' => json_encode( array( 'events' => $events ) ), - 'headers' => array( 'content-type' => 'application/json' ) - ) ); + 'body' => json_encode( [ 'events' => $events ] ), + 'headers' => [ 'content-type' => 'application/json' ] + ] ); return $response['code'] == 201; } diff --git a/includes/libs/objectcache/APCBagOStuff.php b/includes/libs/objectcache/APCBagOStuff.php index c7f9c574da..8f70fc7a77 100644 --- a/includes/libs/objectcache/APCBagOStuff.php +++ b/includes/libs/objectcache/APCBagOStuff.php @@ -51,7 +51,7 @@ class APCBagOStuff extends BagOStuff { * * @param array $params */ - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { parent::__construct( $params ); if ( isset( $params['nativeSerialize'] ) ) { diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index a7e8a4780b..1aed28036a 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -44,7 +44,7 @@ use Psr\Log\NullLogger; */ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { /** @var array[] Lock tracking */ - protected $locks = array(); + protected $locks = []; /** @var integer */ protected $lastError = self::ERR_NONE; @@ -71,7 +71,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { const WRITE_SYNC = 1; // synchronously write to all locations for replicated stores const WRITE_CACHE_ONLY = 2; // Only change state of the in-memory cache - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { if ( isset( $params['logger'] ) ) { $this->setLogger( $params['logger'] ); } else { @@ -351,7 +351,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { } if ( $locked ) { - $this->locks[$key] = array( 'class' => $rclass, 'depth' => 1 ); + $this->locks[$key] = [ 'class' => $rclass, 'depth' => 1 ]; } return $locked; @@ -430,7 +430,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { * @return array */ public function getMulti( array $keys, $flags = 0 ) { - $res = array(); + $res = []; foreach ( $keys as $key ) { $val = $this->get( $key ); if ( $val !== false ) { @@ -577,9 +577,9 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { */ protected function debug( $text ) { if ( $this->debugMode ) { - $this->logger->debug( "{class} debug: $text", array( + $this->logger->debug( "{class} debug: $text", [ 'class' => get_class( $this ), - ) ); + ] ); } } diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php index fc156187fe..c71b16e502 100644 --- a/includes/libs/objectcache/CachedBagOStuff.php +++ b/includes/libs/objectcache/CachedBagOStuff.php @@ -43,7 +43,7 @@ class CachedBagOStuff extends HashBagOStuff { * @param BagOStuff $backend Permanent backend to use * @param array $params Parameters for HashBagOStuff */ - function __construct( BagOStuff $backend, $params = array() ) { + function __construct( BagOStuff $backend, $params = [] ) { $this->backend = $backend; parent::__construct( $params ); } diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php index 7b85d92580..6e7fb0cae0 100644 --- a/includes/libs/objectcache/HashBagOStuff.php +++ b/includes/libs/objectcache/HashBagOStuff.php @@ -31,7 +31,7 @@ use Wikimedia\Assert\Assert; */ class HashBagOStuff extends BagOStuff { /** @var mixed[] */ - protected $bag = array(); + protected $bag = []; /** @var integer Max entries allowed */ protected $maxCacheKeys; @@ -42,7 +42,7 @@ class HashBagOStuff extends BagOStuff { * @param array $params Additional parameters include: * - maxKeys : only allow this many keys (using oldest-first eviction) */ - function __construct( $params = array() ) { + function __construct( $params = [] ) { parent::__construct( $params ); $this->maxCacheKeys = isset( $params['maxKeys'] ) ? $params['maxKeys'] : INF; @@ -80,10 +80,10 @@ class HashBagOStuff extends BagOStuff { public function set( $key, $value, $exptime = 0, $flags = 0 ) { // Refresh key position for maxCacheKeys eviction unset( $this->bag[$key] ); - $this->bag[$key] = array( + $this->bag[$key] = [ self::KEY_VAL => $value, self::KEY_EXP => $this->convertExpiry( $exptime ) - ); + ]; if ( count( $this->bag ) > $this->maxCacheKeys ) { reset( $this->bag ); @@ -101,6 +101,6 @@ class HashBagOStuff extends BagOStuff { } public function clear() { - $this->bag = array(); + $this->bag = []; } } diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php index 73bdabd1c2..ec588cee00 100644 --- a/includes/libs/objectcache/MultiWriteBagOStuff.php +++ b/includes/libs/objectcache/MultiWriteBagOStuff.php @@ -72,7 +72,7 @@ class MultiWriteBagOStuff extends BagOStuff { ); } - $this->caches = array(); + $this->caches = []; foreach ( $params['caches'] as $cacheInfo ) { if ( $cacheInfo instanceof BagOStuff ) { $this->caches[] = $cacheInfo; @@ -82,7 +82,7 @@ class MultiWriteBagOStuff extends BagOStuff { // Callers intenting this to be for ObjectFactory::getObjectFromSpec // should have set "args" per the docs above. Doings so avoids extra // (likely harmless) params (factory/class/calls) ending up in "args". - $cacheInfo['args'] = array( $cacheInfo ); + $cacheInfo['args'] = [ $cacheInfo ]; } $this->caches[] = ObjectFactory::getObjectFromSpec( $cacheInfo ); } @@ -194,7 +194,7 @@ class MultiWriteBagOStuff extends BagOStuff { if ( $i == 0 || !$asyncWrites ) { // First store or in sync mode: write now and get result - if ( !call_user_func_array( array( $cache, $method ), $args ) ) { + if ( !call_user_func_array( [ $cache, $method ], $args ) ) { $ret = false; } } else { @@ -203,7 +203,7 @@ class MultiWriteBagOStuff extends BagOStuff { call_user_func( $this->asyncHandler, function () use ( $cache, $method, $args, $logger ) { - if ( !call_user_func_array( array( $cache, $method ), $args ) ) { + if ( !call_user_func_array( [ $cache, $method ], $args ) ) { $logger->warning( "Async $method op failed" ); } } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 4aa868efce..e43d37b8ca 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -145,7 +145,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $this->cache = $params['cache']; $this->pool = $params['pool']; $this->relayer = $params['relayer']; - $this->procCache = new HashBagOStuff( array( 'maxKeys' => self::MAX_PC_KEYS ) ); + $this->procCache = new HashBagOStuff( [ 'maxKeys' => self::MAX_PC_KEYS ] ); $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() ); } @@ -159,11 +159,11 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return WANObjectCache */ public static function newEmpty() { - return new self( array( + return new self( [ 'cache' => new EmptyBagOStuff(), 'pool' => 'empty', - 'relayer' => new EventRelayerNull( array() ) - ) ); + 'relayer' => new EventRelayerNull( [] ) + ] ); } /** @@ -205,9 +205,9 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @param array $checkKeys List of "check" keys * @return mixed Value of cache key or false on failure */ - final public function get( $key, &$curTTL = null, array $checkKeys = array() ) { - $curTTLs = array(); - $values = $this->getMulti( array( $key ), $curTTLs, $checkKeys ); + final public function get( $key, &$curTTL = null, array $checkKeys = [] ) { + $curTTLs = []; + $values = $this->getMulti( [ $key ], $curTTLs, $checkKeys ); $curTTL = isset( $curTTLs[$key] ) ? $curTTLs[$key] : null; return isset( $values[$key] ) ? $values[$key] : false; @@ -225,17 +225,17 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return array Map of (key => value) for keys that exist */ final public function getMulti( - array $keys, &$curTTLs = array(), array $checkKeys = array() + array $keys, &$curTTLs = [], array $checkKeys = [] ) { - $result = array(); - $curTTLs = array(); + $result = []; + $curTTLs = []; $vPrefixLen = strlen( self::VALUE_KEY_PREFIX ); $valueKeys = self::prefixCacheKeys( $keys, self::VALUE_KEY_PREFIX ); - $checkKeysForAll = array(); - $checkKeysByKey = array(); - $checkKeysFlat = array(); + $checkKeysForAll = []; + $checkKeysByKey = []; + $checkKeysFlat = []; foreach ( $checkKeys as $i => $keys ) { $prefixed = self::prefixCacheKeys( (array)$keys, self::TIME_KEY_PREFIX ); $checkKeysFlat = array_merge( $checkKeysFlat, $prefixed ); @@ -256,7 +256,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { // Collect timestamps from all "check" keys $purgeValuesForAll = $this->processCheckKeys( $checkKeysForAll, $wrappedValues, $now ); - $purgeValuesByKey = array(); + $purgeValuesByKey = []; foreach ( $checkKeysByKey as $cacheKey => $checks ) { $purgeValuesByKey[$cacheKey] = $this->processCheckKeys( $checks, $wrappedValues, $now ); @@ -304,7 +304,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return array List of purge value arrays */ private function processCheckKeys( array $timeKeys, array $wrappedValues, $now ) { - $purgeValues = array(); + $purgeValues = []; foreach ( $timeKeys as $timeKey ) { $purge = isset( $wrappedValues[$timeKey] ) ? self::parsePurgeValue( $wrappedValues[$timeKey] ) @@ -370,7 +370,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * Default: WANObjectCache::TSE_NONE * @return bool Success */ - final public function set( $key, $value, $ttl = 0, array $opts = array() ) { + final public function set( $key, $value, $ttl = 0, array $opts = [] ) { $lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] : self::TSE_NONE; $age = isset( $opts['since'] ) ? max( 0, microtime( true ) - $opts['since'] ) : 0; $lag = isset( $opts['lag'] ) ? $opts['lag'] : 0; @@ -382,7 +382,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { return true; // no-op the write for being unsafe } - $wrapExtra = array(); // additional wrapped value fields + $wrapExtra = []; // additional wrapped value fields // Check if there's a risk of writing stale data after the purge tombstone expired if ( $lag === false || ( $lag + $age ) > self::MAX_READ_LAG ) { // Case A: read lag with "lockTSE"; save but record value as stale @@ -762,7 +762,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * Default: WANObjectCache::TTL_UNCACHEABLE. * @return mixed Value to use for the key */ - final public function getWithSetCallback( $key, $ttl, $callback, array $opts = array() ) { + final public function getWithSetCallback( $key, $ttl, $callback, array $opts = [] ) { $pcTTL = isset( $opts['pcTTL'] ) ? $opts['pcTTL'] : self::TTL_UNCACHEABLE; // Try the process cache if enabled @@ -794,7 +794,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { protected function doGetWithSetCallback( $key, $ttl, $callback, array $opts ) { $lowTTL = isset( $opts['lowTTL'] ) ? $opts['lowTTL'] : min( self::LOW_TTL, $ttl ); $lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] : self::TSE_NONE; - $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : array(); + $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : []; // Get the current key value $curTTL = null; @@ -841,8 +841,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { } // Generate the new value from the callback... - $setOpts = array(); - $value = call_user_func_array( $callback, array( $cValue, &$ttl, &$setOpts ) ); + $setOpts = []; + $value = call_user_func_array( $callback, [ $cValue, &$ttl, &$setOpts ] ); // When delete() is called, writes are write-holed by the tombstone, // so use a special stash key to pass the new value around threads. if ( $useMutex && $value !== false && $ttl >= 0 ) { @@ -870,7 +870,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @since 1.27 */ public function makeKey() { - return call_user_func_array( array( $this->cache, __FUNCTION__ ), func_get_args() ); + return call_user_func_array( [ $this->cache, __FUNCTION__ ], func_get_args() ); } /** @@ -880,7 +880,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @since 1.27 */ public function makeGlobalKey() { - return call_user_func_array( array( $this->cache, __FUNCTION__ ), func_get_args() ); + return call_user_func_array( [ $this->cache, __FUNCTION__ ], func_get_args() ); } /** @@ -929,13 +929,13 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return bool Success */ protected function relayPurge( $key, $ttl, $holdoff ) { - $event = $this->cache->modifySimpleRelayEvent( array( + $event = $this->cache->modifySimpleRelayEvent( [ 'cmd' => 'set', 'key' => $key, 'val' => 'PURGED:$UNIXTIME$:' . (int)$holdoff, 'ttl' => max( $ttl, 1 ), 'sbt' => true, // substitute $UNIXTIME$ with actual microtime - ) ); + ] ); $ok = $this->relayer->notify( "{$this->pool}:purge", $event ); if ( !$ok ) { @@ -952,10 +952,10 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return bool Success */ protected function relayDelete( $key ) { - $event = $this->cache->modifySimpleRelayEvent( array( + $event = $this->cache->modifySimpleRelayEvent( [ 'cmd' => 'delete', 'key' => $key, - ) ); + ] ); $ok = $this->relayer->notify( "{$this->pool}:purge", $event ); if ( !$ok ) { @@ -997,12 +997,12 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return array */ protected function wrap( $value, $ttl ) { - return array( + return [ self::FLD_VERSION => self::VERSION, self::FLD_VALUE => $value, self::FLD_TTL => $ttl, self::FLD_TIME => microtime( true ) - ); + ]; } /** @@ -1018,14 +1018,14 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { if ( $purge !== false ) { // Purged values should always have a negative current $ttl $curTTL = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE ); - return array( false, $curTTL ); + return [ false, $curTTL ]; } if ( !is_array( $wrapped ) // not found || !isset( $wrapped[self::FLD_VERSION] ) // wrong format || $wrapped[self::FLD_VERSION] !== self::VERSION // wrong version ) { - return array( false, null ); + return [ false, null ]; } $flags = isset( $wrapped[self::FLD_FLAGS] ) ? $wrapped[self::FLD_FLAGS] : 0; @@ -1042,7 +1042,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $curTTL = INF; } - return array( $wrapped[self::FLD_VALUE], $curTTL ); + return [ $wrapped[self::FLD_VALUE], $curTTL ]; } /** @@ -1051,7 +1051,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * @return string[] */ protected static function prefixCacheKeys( array $keys, $prefix ) { - $res = array(); + $res = []; foreach ( $keys as $key ) { $res[] = $prefix . $key; } @@ -1078,10 +1078,10 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { // Back-compat with old purge values without holdoff $segments[2] = self::HOLDOFF_TTL; } - return array( + return [ self::FLD_TIME => (float)$segments[1], self::FLD_HOLDOFF => (int)$segments[2], - ); + ]; } /** diff --git a/includes/libs/objectcache/WinCacheBagOStuff.php b/includes/libs/objectcache/WinCacheBagOStuff.php index 8b0161090c..3d72abe84f 100644 --- a/includes/libs/objectcache/WinCacheBagOStuff.php +++ b/includes/libs/objectcache/WinCacheBagOStuff.php @@ -51,7 +51,7 @@ class WinCacheBagOStuff extends BagOStuff { /* wincache_ucache_set returns an empty array on success if $value was an array, bool otherwise */ - return ( is_array( $result ) && $result === array() ) || $result; + return ( is_array( $result ) && $result === [] ) || $result; } protected function cas( $casToken, $key, $value, $exptime = 0 ) { diff --git a/includes/libs/replacers/RegexlikeReplacer.php b/includes/libs/replacers/RegexlikeReplacer.php index 2b1fa74023..9874f524c2 100644 --- a/includes/libs/replacers/RegexlikeReplacer.php +++ b/includes/libs/replacers/RegexlikeReplacer.php @@ -36,7 +36,7 @@ class RegexlikeReplacer extends Replacer { * @return string */ public function replace( array $matches ) { - $pairs = array(); + $pairs = []; foreach ( $matches as $i => $match ) { $pairs["\$$i"] = $match; } diff --git a/includes/libs/replacers/Replacer.php b/includes/libs/replacers/Replacer.php index f4850bf6ad..3b978357ed 100644 --- a/includes/libs/replacers/Replacer.php +++ b/includes/libs/replacers/Replacer.php @@ -27,7 +27,7 @@ abstract class Replacer { * @return array */ public function cb() { - return array( &$this, 'replace' ); + return [ &$this, 'replace' ]; } /** diff --git a/includes/libs/virtualrest/ParsoidVirtualRESTService.php b/includes/libs/virtualrest/ParsoidVirtualRESTService.php index 5be4aeab41..da47d35651 100644 --- a/includes/libs/virtualrest/ParsoidVirtualRESTService.php +++ b/includes/libs/virtualrest/ParsoidVirtualRESTService.php @@ -53,14 +53,14 @@ class ParsoidVirtualRESTService extends VirtualRESTService { unset( $params['URL'] ); } // set up defaults and merge them with the given params - $mparams = array_merge( array( + $mparams = array_merge( [ 'name' => 'parsoid', 'url' => 'http://localhost:8000/', 'prefix' => 'localhost', 'domain' => 'localhost', 'forwardCookies' => false, 'HTTPProxy' => null, - ), $params ); + ], $params ); // Ensure that the url parameter has a trailing slash. $mparams['url'] = preg_replace( '#/?$#', @@ -79,7 +79,7 @@ class ParsoidVirtualRESTService extends VirtualRESTService { } public function onRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { $parts = explode( '/', $req['url'] ); diff --git a/includes/libs/virtualrest/RestbaseVirtualRESTService.php b/includes/libs/virtualrest/RestbaseVirtualRESTService.php index 81442adc42..d2dd89f809 100644 --- a/includes/libs/virtualrest/RestbaseVirtualRESTService.php +++ b/includes/libs/virtualrest/RestbaseVirtualRESTService.php @@ -47,7 +47,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { */ public function __construct( array $params ) { // set up defaults and merge them with the given params - $mparams = array_merge( array( + $mparams = array_merge( [ 'name' => 'restbase', 'url' => 'http://localhost:7231/', 'domain' => 'localhost', @@ -55,7 +55,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { 'forwardCookies' => false, 'HTTPProxy' => null, 'parsoidCompat' => false - ), $params ); + ], $params ); // Ensure that the url parameter has a trailing slash. $mparams['url'] = preg_replace( '#/?$#', @@ -79,7 +79,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { return $this->onParsoidRequests( $reqs, $idGenFunc ); } - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { // replace /local/ with the current domain $req['url'] = preg_replace( '#^local/#', $this->params['domain'] . '/', $req['url'] ); @@ -107,7 +107,7 @@ class RestbaseVirtualRESTService extends VirtualRESTService { */ public function onParsoidRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { $parts = explode( '/', $req['url'] ); if ( $parts[1] === 'v3' ) { diff --git a/includes/libs/virtualrest/SwiftVirtualRESTService.php b/includes/libs/virtualrest/SwiftVirtualRESTService.php index 88b0e1f14a..679d51c5ac 100644 --- a/includes/libs/virtualrest/SwiftVirtualRESTService.php +++ b/includes/libs/virtualrest/SwiftVirtualRESTService.php @@ -46,9 +46,9 @@ class SwiftVirtualRESTService extends VirtualRESTService { */ public function __construct( array $params ) { // set up defaults and merge them with the given params - $mparams = array_merge( array( + $mparams = array_merge( [ 'name' => 'swift' - ), $params ); + ], $params ); parent::__construct( $mparams ); } @@ -74,10 +74,10 @@ class SwiftVirtualRESTService extends VirtualRESTService { $this->authSessionTimestamp = 0; list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $req['response']; if ( $rcode >= 200 && $rcode <= 299 ) { // OK - $this->authCreds = array( + $this->authCreds = [ 'auth_token' => $rhdrs['x-auth-token'], 'storage_url' => $rhdrs['x-storage-url'] - ); + ]; $this->authSessionTimestamp = time(); return true; } elseif ( $rcode === 403 ) { @@ -94,7 +94,7 @@ class SwiftVirtualRESTService extends VirtualRESTService { } public function onRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; $firstReq = reset( $reqs ); if ( $firstReq && count( $reqs ) == 1 && isset( $firstReq['isAuth'] ) ) { // This was an authentication request for work requests... @@ -105,29 +105,29 @@ class SwiftVirtualRESTService extends VirtualRESTService { if ( $needsAuth === true ) { // These are work requests and we don't have any token to use. // Replace the work requests with an authentication request. - $result = array( - $idGeneratorFunc() => array( + $result = [ + $idGeneratorFunc() => [ 'method' => 'GET', 'url' => $this->params['swiftAuthUrl'] . "/v1.0", - 'headers' => array( + 'headers' => [ 'x-auth-user' => $this->params['swiftUser'], - 'x-auth-key' => $this->params['swiftKey'] ), + 'x-auth-key' => $this->params['swiftKey'] ], 'isAuth' => true, 'chain' => $reqs - ) - ); + ] + ]; } elseif ( $needsAuth !== false ) { // These are work requests and authentication has previously failed. // It is most efficient to just give failed pseudo responses back for // the original work requests. foreach ( $reqs as $key => $req ) { - $req['response'] = array( + $req['response'] = [ 'code' => $this->authCachedStatus, 'reason' => $this->authCachedReason, - 'headers' => array(), + 'headers' => [], 'body' => '', 'error' => '' - ); + ]; $result[$key] = $req; } } else { @@ -151,7 +151,7 @@ class SwiftVirtualRESTService extends VirtualRESTService { public function onResponses( array $reqs, Closure $idGeneratorFunc ) { $firstReq = reset( $reqs ); if ( $firstReq && count( $reqs ) == 1 && isset( $firstReq['isAuth'] ) ) { - $result = array(); + $result = []; // This was an authentication request for work requests... if ( $this->applyAuthResponse( $firstReq ) ) { // If it succeeded, we can subsitute the work requests back. @@ -161,13 +161,13 @@ class SwiftVirtualRESTService extends VirtualRESTService { // If it failed, it is most efficient to just give failing // pseudo-responses back for the actual work requests. foreach ( $firstReq['chain'] as $key => $req ) { - $req['response'] = array( + $req['response'] = [ 'code' => $this->authCachedStatus, 'reason' => $this->authCachedReason, - 'headers' => array(), + 'headers' => [], 'body' => '', 'error' => '' - ); + ]; $result[$key] = $req; } } diff --git a/includes/libs/virtualrest/VirtualRESTService.php b/includes/libs/virtualrest/VirtualRESTService.php index 01a4ea6edf..ccb14db020 100644 --- a/includes/libs/virtualrest/VirtualRESTService.php +++ b/includes/libs/virtualrest/VirtualRESTService.php @@ -35,7 +35,7 @@ */ abstract class VirtualRESTService { /** @var array Key/value map */ - protected $params = array(); + protected $params = []; /** * @param array $params Key/value map @@ -78,7 +78,7 @@ abstract class VirtualRESTService { * @return array Modified HTTP request array map */ public function onRequests( array $reqs, Closure $idGeneratorFunc ) { - $result = array(); + $result = []; foreach ( $reqs as $key => $req ) { // The default encoding treats the URL as a REST style path that uses // forward slash as a hierarchical delimiter (and never otherwise). diff --git a/includes/libs/virtualrest/VirtualRESTServiceClient.php b/includes/libs/virtualrest/VirtualRESTServiceClient.php index 519da4313c..c64fe34af7 100644 --- a/includes/libs/virtualrest/VirtualRESTServiceClient.php +++ b/includes/libs/virtualrest/VirtualRESTServiceClient.php @@ -47,7 +47,7 @@ class VirtualRESTServiceClient { /** @var MultiHttpClient */ protected $http; /** @var Array Map of (prefix => VirtualRESTService) */ - protected $instances = array(); + protected $instances = []; const VALID_MOUNT_REGEX = '#^/[0-9a-z]+/([0-9a-z]+/)*$#'; @@ -103,7 +103,7 @@ class VirtualRESTServiceClient { return ( $al < $bl ) ? 1 : -1; // largest prefix first }; - $matches = array(); // matching prefixes (mount points) + $matches = []; // matching prefixes (mount points) foreach ( $this->instances as $prefix => $service ) { if ( strpos( $path, $prefix ) === 0 ) { $matches[] = $prefix; @@ -113,8 +113,8 @@ class VirtualRESTServiceClient { // Return the most specific prefix and corresponding service return isset( $matches[0] ) - ? array( $matches[0], $this->instances[$matches[0]] ) - : array( null, null ); + ? [ $matches[0], $this->instances[$matches[0]] ] + : [ null, null ]; } /** @@ -134,7 +134,7 @@ class VirtualRESTServiceClient { * @return array Response array for request */ public function run( array $req ) { - $responses = $this->runMulti( array( $req ) ); + $responses = $this->runMulti( [ $req ] ); return $responses[0]; } @@ -166,17 +166,17 @@ class VirtualRESTServiceClient { $req['url'] = $req[1]; // short-form unset( $req[1] ); } - $req['chain'] = array(); // chain or list of replaced requests + $req['chain'] = []; // chain or list of replaced requests } unset( $req ); // don't assign over this by accident $curUniqueId = 0; - $armoredIndexMap = array(); // (original index => new index) + $armoredIndexMap = []; // (original index => new index) - $doneReqs = array(); // (index => request) - $executeReqs = array(); // (index => request) - $replaceReqsByService = array(); // (prefix => index => request) - $origPending = array(); // (index => 1) for original requests + $doneReqs = []; // (index => request) + $executeReqs = []; // (index => request) + $replaceReqsByService = []; // (prefix => index => request) + $origPending = []; // (index => 1) for original requests foreach ( $reqs as $origIndex => $req ) { // Re-index keys to consecutive integers (they will be swapped back later) @@ -210,12 +210,12 @@ class VirtualRESTServiceClient { } // Track requests executed this round that have a prefix/service. // Note that this also includes requests where 'response' was forced. - $checkReqIndexesByPrefix = array(); + $checkReqIndexesByPrefix = []; // Resolve the virtual URLs valid and qualified HTTP(S) URLs // and add any required authentication headers for the backend. // Services can also replace requests with new ones, either to // defer the original or to set a proxy response to the original. - $newReplaceReqsByService = array(); + $newReplaceReqsByService = []; foreach ( $replaceReqsByService as $prefix => $servReqs ) { $service = $this->instances[$prefix]; foreach ( $service->onRequests( $servReqs, $idFunc ) as $index => $req ) { @@ -245,13 +245,13 @@ class VirtualRESTServiceClient { $doneReqs[$index] = $ranReq; unset( $origPending[$index] ); } - $executeReqs = array(); + $executeReqs = []; // Services can also replace requests with new ones, either to // defer the original or to set a proxy response to the original. // Any replacement requests executed above will need to be replaced // with new requests (eventually the original). The responses can be // forced by setting 'response' rather than actually be sent over the wire. - $newReplaceReqsByService = array(); + $newReplaceReqsByService = []; foreach ( $checkReqIndexesByPrefix as $prefix => $servReqIndexes ) { $service = $this->instances[$prefix]; // $doneReqs actually has the requests (with 'response' set) @@ -278,7 +278,7 @@ class VirtualRESTServiceClient { $replaceReqsByService = $newReplaceReqsByService; } while ( count( $origPending ) ); - $responses = array(); + $responses = []; // Update $reqs to include 'response' and normalized request 'headers'. // This maintains the original order of $reqs. foreach ( $reqs as $origIndex => $req ) { diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index 72fcc3a5df..aa90d1d369 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -83,9 +83,9 @@ class BlockLogFormatter extends LogFormatter { $title = $this->entry->getTarget(); // Preload user page for non-autoblocks if ( substr( $title->getText(), 0, 1 ) !== '#' ) { - return array( $title->getTalkPage() ); + return [ $title->getTalkPage() ]; } - return array(); + return []; } public function getActionLinks() { @@ -99,7 +99,7 @@ class BlockLogFormatter extends LogFormatter { // Show unblock/change block link $title = $this->entry->getTarget(); - $links = array( + $links = [ Linker::linkKnown( SpecialPage::getTitleFor( 'Unblock', $title->getDBkey() ), $this->msg( 'unblocklink' )->escaped() @@ -108,7 +108,7 @@ class BlockLogFormatter extends LogFormatter { SpecialPage::getTitleFor( 'Block', $title->getDBkey() ), $this->msg( 'change-blocklink' )->escaped() ) - ); + ]; return $this->msg( 'parentheses' )->rawParams( $this->context->getLanguage()->pipeList( $links ) )->escaped(); @@ -146,7 +146,7 @@ class BlockLogFormatter extends LogFormatter { * @return string */ public static function formatBlockFlag( $flag, $lang ) { - static $messages = array(); + static $messages = []; if ( !isset( $messages[$flag] ) ) { $messages[$flag] = htmlspecialchars( $flag ); // Fallback @@ -173,13 +173,13 @@ class BlockLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ // While this looks wrong to be starting at 5 rather than 4, it's // because getMessageParameters uses $4 for its own purposes. '5::duration', '6:array:flags', '6::flags' => '6:array:flags', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; @@ -190,14 +190,14 @@ class BlockLogFormatter extends LogFormatter { $subtype = $entry->getSubtype(); if ( $subtype === 'block' || $subtype === 'reblock' ) { // Defaults for old log entries missing some fields - $params += array( + $params += [ '5::duration' => 'infinite', - '6:array:flags' => array(), - ); + '6:array:flags' => [], + ]; if ( !is_array( $params['6:array:flags'] ) ) { $params['6:array:flags'] = $params['6:array:flags'] === '' - ? array() + ? [] : explode( ',', $params['6:array:flags'] ); } diff --git a/includes/logging/ContentModelLogFormatter.php b/includes/logging/ContentModelLogFormatter.php index 982fcc308c..f130740a8d 100644 --- a/includes/logging/ContentModelLogFormatter.php +++ b/includes/logging/ContentModelLogFormatter.php @@ -21,12 +21,12 @@ class ContentModelLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'ChangeContentModel' ), $this->msg( 'logentry-contentmodel-change-revertlink' )->escaped(), - array(), - array( + [], + [ 'pagetitle' => $this->entry->getTarget()->getPrefixedText(), 'model' => $params[3], 'reason' => $this->msg( 'logentry-contentmodel-change-revert' )->inContentLanguage()->text(), - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); diff --git a/includes/logging/DeleteLogFormatter.php b/includes/logging/DeleteLogFormatter.php index f0598aa749..3b470ecd8f 100644 --- a/includes/logging/DeleteLogFormatter.php +++ b/includes/logging/DeleteLogFormatter.php @@ -31,7 +31,7 @@ class DeleteLogFormatter extends LogFormatter { protected function getMessageKey() { $key = parent::getMessageKey(); - if ( in_array( $this->entry->getSubtype(), array( 'event', 'revision' ) ) ) { + if ( in_array( $this->entry->getSubtype(), [ 'event', 'revision' ] ) ) { if ( count( $this->getMessageParameters() ) < 5 ) { return "$key-legacy"; } @@ -47,7 +47,7 @@ class DeleteLogFormatter extends LogFormatter { $params = parent::getMessageParameters(); $subtype = $this->entry->getSubtype(); - if ( in_array( $subtype, array( 'event', 'revision' ) ) ) { + if ( in_array( $subtype, [ 'event', 'revision' ] ) ) { // $params[3] here is 'revision' or 'archive' for page revisions, 'oldimage' or // 'filearchive' for file versions, or a comma-separated list of log_ids for log // entries. $subtype here is 'revision' for page revisions and file @@ -63,7 +63,7 @@ class DeleteLogFormatter extends LogFormatter { $old = $this->parseBitField( $params[$paramStart + 1] ); $new = $this->parseBitField( $params[$paramStart + 2] ); list( $hid, $unhid, $extra ) = RevisionDeleter::getChanges( $new, $old ); - $changes = array(); + $changes = []; // messages used: revdelete-content-hid, revdelete-summary-hid, revdelete-uname-hid foreach ( $hid as $v ) { $changes[] = $this->msg( "$v-hid" )->plain(); @@ -125,8 +125,8 @@ class DeleteLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Undelete' ), $this->msg( $message )->escaped(), - array(), - array( 'target' => $this->entry->getTarget()->getPrefixedDBkey() ) + [], + [ 'target' => $this->entry->getTarget()->getPrefixedDBkey() ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -144,7 +144,7 @@ class DeleteLogFormatter extends LogFormatter { ? $params[4] : explode( ',', $params[4] ); - $links = array(); + $links = []; // If there's only one item, we can show a diff link if ( count( $ids ) == 1 ) { @@ -153,23 +153,23 @@ class DeleteLogFormatter extends LogFormatter { $links[] = Linker::linkKnown( $this->entry->getTarget(), $this->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'diff' => intval( $ids[0] ), 'unhide' => 1 - ) + ] ); // Deleted revision diffs... } elseif ( $key == 'artimestamp' || $key == 'archive' ) { $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Undelete' ), $this->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'target' => $this->entry->getTarget()->getPrefixedDBkey(), 'diff' => 'prev', 'timestamp' => $ids[0] - ) + ] ); } } @@ -178,12 +178,12 @@ class DeleteLogFormatter extends LogFormatter { $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Revisiondelete' ), $this->msg( 'revdel-restore' )->escaped(), - array(), - array( + [], + [ 'target' => $this->entry->getTarget()->getPrefixedText(), 'type' => $key, 'ids' => implode( ',', $ids ), - ) + ] ); return $this->msg( 'parentheses' )->rawParams( @@ -203,12 +203,12 @@ class DeleteLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Revisiondelete' ), $this->msg( 'revdel-restore' )->escaped(), - array(), - array( + [], + [ 'target' => $this->entry->getTarget()->getPrefixedText(), 'type' => 'logging', 'ids' => $query - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -219,16 +219,16 @@ class DeleteLogFormatter extends LogFormatter { protected function getParametersForApi() { $entry = $this->entry; - $params = array(); + $params = []; $subtype = $this->entry->getSubtype(); - if ( in_array( $subtype, array( 'event', 'revision' ) ) ) { + if ( in_array( $subtype, [ 'event', 'revision' ] ) ) { $rawParams = $entry->getParameters(); if ( $subtype === 'event' ) { array_unshift( $rawParams, 'logging' ); } - static $map = array( + static $map = [ '4::type', '5::ids', '6::ofield', @@ -236,7 +236,7 @@ class DeleteLogFormatter extends LogFormatter { '4::ids' => '5::ids', '5::ofield' => '6::ofield', '6::nfield' => '7::nfield', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $rawParams[$index] ) ) { $rawParams[$key] = $rawParams[$index]; @@ -250,19 +250,19 @@ class DeleteLogFormatter extends LogFormatter { $rawParams['5::ids'] = explode( ',', $rawParams['5::ids'] ); } - $params = array( + $params = [ '::type' => $rawParams['4::type'], ':array:ids' => $rawParams['5::ids'], - ':assoc:old' => array( 'bitmask' => $old ), - ':assoc:new' => array( 'bitmask' => $new ), - ); + ':assoc:old' => [ 'bitmask' => $old ], + ':assoc:new' => [ 'bitmask' => $new ], + ]; - static $fields = array( + static $fields = [ Revision::DELETED_TEXT => 'content', Revision::DELETED_COMMENT => 'comment', Revision::DELETED_USER => 'user', Revision::DELETED_RESTRICTED => 'restricted', - ); + ]; foreach ( $fields as $bit => $key ) { $params[':assoc:old'][$key] = (bool)( $old & $bit ); $params[':assoc:new'][$key] = (bool)( $new & $bit ); diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index ddcb6365ec..e76aa29476 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -168,27 +168,27 @@ class DatabaseLogEntry extends LogEntryBase { * @return array */ public static function getSelectQueryData() { - $tables = array( 'logging', 'user' ); - $fields = array( + $tables = [ 'logging', 'user' ]; + $fields = [ 'log_id', 'log_type', 'log_action', 'log_timestamp', 'log_user', 'log_user_text', 'log_namespace', 'log_title', // unused log_page 'log_comment', 'log_params', 'log_deleted', 'user_id', 'user_name', 'user_editcount', - ); + ]; - $joins = array( + $joins = [ // IPs don't have an entry in user table - 'user' => array( 'LEFT JOIN', 'log_user=user_id' ), - ); + 'user' => [ 'LEFT JOIN', 'log_user=user_id' ], + ]; - return array( + return [ 'tables' => $tables, 'fields' => $fields, - 'conds' => array(), - 'options' => array(), + 'conds' => [], + 'options' => [], 'join_conds' => $joins, - ); + ]; } /** @@ -399,10 +399,10 @@ class ManualLogEntry extends LogEntryBase { protected $subtype; /** @var array Parameters for log entry */ - protected $parameters = array(); + protected $parameters = []; /** @var array */ - protected $relations = array(); + protected $relations = []; /** @var User Performer of the action for the log entry */ protected $performer; @@ -582,7 +582,7 @@ class ManualLogEntry extends LogEntryBase { $relations['associated_rev_id'] = $revId; } - $data = array( + $data = [ 'log_id' => $id, 'log_type' => $this->getType(), 'log_action' => $this->getSubtype(), @@ -594,7 +594,7 @@ class ManualLogEntry extends LogEntryBase { 'log_page' => $this->getTarget()->getArticleID(), 'log_comment' => $comment, 'log_params' => LogEntryBase::makeParamBlob( $params ), - ); + ]; if ( isset( $this->deleted ) ) { $data['log_deleted'] = $this->deleted; } @@ -602,22 +602,22 @@ class ManualLogEntry extends LogEntryBase { $dbw->insert( 'logging', $data, __METHOD__ ); $this->id = !is_null( $id ) ? $id : $dbw->insertId(); - $rows = array(); + $rows = []; foreach ( $relations as $tag => $values ) { if ( !strlen( $tag ) ) { throw new MWException( "Got empty log search tag." ); } if ( !is_array( $values ) ) { - $values = array( $values ); + $values = [ $values ]; } foreach ( $values as $value ) { - $rows[] = array( + $rows[] = [ 'ls_field' => $tag, 'ls_value' => $value, 'ls_log_id' => $this->id - ); + ]; } } if ( count( $rows ) ) { diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index e93030f07b..c96c0dbf0c 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -75,7 +75,7 @@ class LogEventsList extends ContextSource { * @param array $filter * @param string $tagFilter Tag to select by default */ - public function showOptions( $types = array(), $user = '', $page = '', $pattern = '', $year = 0, + public function showOptions( $types = [], $user = '', $page = '', $pattern = '', $year = 0, $month = 0, $filter = null, $tagFilter = '' ) { global $wgScript, $wgMiserMode; @@ -83,7 +83,7 @@ class LogEventsList extends ContextSource { $title = SpecialPage::getTitleFor( 'Log' ); // For B/C, we take strings, but make sure they are converted... - $types = ( $types === '' ) ? array() : (array)$types; + $types = ( $types === '' ) ? [] : (array)$types; $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); @@ -120,7 +120,7 @@ class LogEventsList extends ContextSource { $html = Xml::fieldset( $this->msg( 'log' )->text(), $html ); // Form wrapping - $html = Xml::tags( 'form', array( 'action' => $wgScript, 'method' => 'get' ), $html ); + $html = Xml::tags( 'form', [ 'action' => $wgScript, 'method' => 'get' ], $html ); $this->getOutput()->addHTML( $html ); } @@ -131,9 +131,9 @@ class LogEventsList extends ContextSource { */ private function getFilterLinks( $filter ) { // show/hide links - $messages = array( $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() ); + $messages = [ $this->msg( 'show' )->escaped(), $this->msg( 'hide' )->escaped() ]; // Option value -> message mapping - $links = array(); + $links = []; $hiddens = ''; // keep track for "go" button foreach ( $filter as $type => $val ) { // Should the below assignment be outside the foreach? @@ -147,7 +147,7 @@ class LogEventsList extends ContextSource { $link = Linker::linkKnown( $this->getTitle(), $messages[$hideVal], - array(), + [], $query ); @@ -193,7 +193,7 @@ class LogEventsList extends ContextSource { * @since 1.19 */ public function getTypeSelector() { - $typesByName = array(); // Temporary array + $typesByName = []; // Temporary array // First pass to load the log names foreach ( LogPage::validTypes() as $type ) { $page = new LogPage( $type ); @@ -209,7 +209,7 @@ class LogEventsList extends ContextSource { // Always put "All public logs" on top $public = $typesByName['']; unset( $typesByName[''] ); - $typesByName = array( '' => $public ) + $typesByName; + $typesByName = [ '' => $public ] + $typesByName; $select = new XmlSelect( 'type' ); foreach ( $typesByName as $type => $name ) { @@ -230,7 +230,7 @@ class LogEventsList extends ContextSource { 'mw-log-user', 15, $user, - array( 'class' => 'mw-autocomplete-user' ) + [ 'class' => 'mw-autocomplete-user' ] ); return '' . $label . ''; @@ -279,7 +279,7 @@ class LogEventsList extends ContextSource { } else { // Allow extensions to add their own extra inputs $input = ''; - Hooks::run( 'LogEventsListGetExtraInputs', array( $types[0], $this, &$input ) ); + Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input ] ); return $input; } } @@ -337,11 +337,11 @@ class LogEventsList extends ContextSource { $this->getContext() ); $classes = array_merge( - array( 'mw-logline-' . $entry->getType() ), + [ 'mw-logline-' . $entry->getType() ], $newClasses ); - return Html::rawElement( 'li', array( 'class' => $classes ), + return Html::rawElement( 'li', [ 'class' => $classes ], "$del $time $action $comment $revert $tagDisplay" ) . "\n"; } @@ -362,7 +362,7 @@ class LogEventsList extends ContextSource { return Xml::check( 'showhiderevisions', false, - array( 'name' => 'ids[' . $row->log_id . ']' ) + [ 'name' => 'ids[' . $row->log_id . ']' ] ); } @@ -384,12 +384,12 @@ class LogEventsList extends ContextSource { if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) { // If event was hidden from sysops if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { - $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); + $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] ); } else { $del = Xml::check( 'showhiderevisions', false, - array( 'name' => 'ids[' . $row->log_id . ']' ) + [ 'name' => 'ids[' . $row->log_id . ']' ] ); } } else { @@ -397,11 +397,11 @@ class LogEventsList extends ContextSource { if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { $del = Linker::revDeleteLinkDisabled( $canHide ); } else { - $query = array( + $query = [ 'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(), 'type' => 'logging', 'ids' => $row->log_id, - ); + ]; $del = Linker::revDeleteLink( $query, $entryIsSuppressed, @@ -466,13 +466,13 @@ class LogEventsList extends ContextSource { $user = $wgUser; } if ( $bitfield & LogPage::DELETED_RESTRICTED ) { - $permissions = array( 'suppressrevision', 'viewsuppressed' ); + $permissions = [ 'suppressrevision', 'viewsuppressed' ]; } else { - $permissions = array( 'deletedhistory' ); + $permissions = [ 'deletedhistory' ]; } $permissionlist = implode( ', ', $permissions ); wfDebug( "Checking for $permissionlist due to $field match on $bitfield\n" ); - return call_user_func_array( array( $user, 'isAllowedAny' ), $permissions ); + return call_user_func_array( [ $user, 'isAllowedAny' ], $permissions ); } return true; } @@ -510,18 +510,18 @@ class LogEventsList extends ContextSource { * @return int Number of total log items (not limited by $lim) */ public static function showLogExtract( - &$out, $types = array(), $page = '', $user = '', $param = array() + &$out, $types = [], $page = '', $user = '', $param = [] ) { - $defaultParameters = array( + $defaultParameters = [ 'lim' => 25, - 'conds' => array(), + 'conds' => [], 'showIfEmpty' => true, - 'msgKey' => array( '' ), + 'msgKey' => [ '' ], 'wrap' => "$1", 'flags' => 0, 'useRequestParams' => false, 'useMaster' => false, - ); + ]; # The + operator appends elements of remaining keys from the right # handed array to the left handed, whereas duplicated keys are NOT overwritten. $param += $defaultParameters; @@ -534,7 +534,7 @@ class LogEventsList extends ContextSource { $flags = $param['flags']; $useRequestParams = $param['useRequestParams']; if ( !is_array( $msgKey ) ) { - $msgKey = array( $msgKey ); + $msgKey = [ $msgKey ]; } if ( $out instanceof OutputPage ) { @@ -575,11 +575,11 @@ class LogEventsList extends ContextSource { $dir = $context->getLanguage()->getDir(); $lang = $context->getLanguage()->getHtmlCode(); - $s = Xml::openElement( 'div', array( + $s = Xml::openElement( 'div', [ 'class' => "mw-warning-with-logexcerpt mw-content-$dir", 'dir' => $dir, 'lang' => $lang, - ) ); + ] ); if ( count( $msgKey ) == 1 ) { $s .= $context->msg( $msgKey[0] )->parseAsBlock(); @@ -593,12 +593,12 @@ class LogEventsList extends ContextSource { $logBody . $loglist->endLogEventsList(); } elseif ( $showIfEmpty ) { - $s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ), + $s = Html::rawElement( 'div', [ 'class' => 'mw-warning-logempty' ], $context->msg( 'logempty' )->parse() ); } if ( $numRows > $pager->mLimit ) { # Show "Full log" link - $urlParam = array(); + $urlParam = []; if ( $page instanceof Title ) { $urlParam['page'] = $page->getPrefixedDBkey(); } elseif ( $page != '' ) { @@ -610,7 +610,7 @@ class LogEventsList extends ContextSource { } if ( !is_array( $types ) ) { # Make it an array, if it isn't - $types = array( $types ); + $types = [ $types ]; } # If there is exactly one log type, we can link to Special:Log?type=foo @@ -621,7 +621,7 @@ class LogEventsList extends ContextSource { $s .= Linker::link( SpecialPage::getTitleFor( 'Log' ), $context->msg( 'log-fulllog' )->escaped(), - array(), + [], $urlParam ); } @@ -635,7 +635,7 @@ class LogEventsList extends ContextSource { } /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */ - if ( Hooks::run( 'LogEventsListShowLogExtract', array( &$s, $types, $page, $user, $param ) ) ) { + if ( Hooks::run( 'LogEventsListShowLogExtract', [ &$s, $types, $page, $user, $param ] ) ) { // $out can be either an OutputPage object or a String-by-reference if ( $out instanceof OutputPage ) { $out->addHTML( $s ); @@ -664,7 +664,7 @@ class LogEventsList extends ContextSource { } // Reset the array, clears extra "where" clauses when $par is used - $hiddenLogs = array(); + $hiddenLogs = []; // Don't show private logs to unprivileged users foreach ( $wgLogRestrictions as $logType => $right ) { diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index b99cb410af..a64fee1e50 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -462,7 +462,7 @@ class LogFormatter { */ protected function extractParameters() { $entry = $this->entry; - $params = array(); + $params = []; if ( $entry->isLegacy() ) { foreach ( $entry->getParameters() as $index => $value ) { @@ -608,9 +608,9 @@ class LogFormatter { * @throws MWException * @return string */ - protected function makePageLink( Title $title = null, $parameters = array(), $html = null ) { + protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { if ( !$this->plaintext ) { - $link = Linker::link( $title, $html, array(), $parameters ); + $link = Linker::link( $title, $html, [], $parameters ); } else { if ( !$title instanceof Title ) { throw new MWException( "Expected title, got null" ); @@ -671,7 +671,7 @@ class LogFormatter { } $content = $this->msg( $message )->escaped(); - $attribs = array( 'class' => 'history-deleted' ); + $attribs = [ 'class' => 'history-deleted' ]; return Html::rawElement( 'span', $attribs, $content ); } @@ -685,7 +685,7 @@ class LogFormatter { if ( $this->plaintext ) { return $content; } - $attribs = array( 'class' => 'history-deleted' ); + $attribs = [ 'class' => 'history-deleted' ]; return Html::rawElement( 'span', $attribs, $content ); } @@ -726,7 +726,7 @@ class LogFormatter { * @return array Array of titles that should be preloaded with LinkBatch */ public function getPreloadTitles() { - return array(); + return []; } /** @@ -763,7 +763,7 @@ class LogFormatter { * @return array */ public function formatParametersForApi() { - $logParams = array(); + $logParams = []; foreach ( $this->getParametersForApi() as $key => $value ) { $vals = explode( ':', $key, 3 ); if ( count( $vals ) !== 3 ) { @@ -820,7 +820,7 @@ class LogFormatter { if ( $type === 'msg-content' ) { $msg->inContentLanguage(); } - $value = array(); + $value = []; $value["{$name}_key"] = $msg->getKey(); if ( $msg->getParams() ) { $value["{$name}_params"] = $msg->getParams(); @@ -832,7 +832,7 @@ class LogFormatter { case 'title-link': $title = Title::newFromText( $value ); if ( $title ) { - $value = array(); + $value = []; ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" ); } return $value; @@ -850,7 +850,7 @@ class LogFormatter { break; } - return array( $name => $value ); + return [ $name => $value ]; } } @@ -946,8 +946,8 @@ class LegacyLogFormatter extends LogFormatter { $params = $this->entry->getParameters(); - Hooks::run( 'LogLine', array( $type, $subtype, $title, $params, - &$this->comment, &$this->revert, $this->entry->getTimestamp() ) ); + Hooks::run( 'LogLine', [ $type, $subtype, $title, $params, + &$this->comment, &$this->revert, $this->entry->getTimestamp() ] ); return $this->revert; } diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 6b70ceca4d..daaff07a1e 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -97,7 +97,7 @@ class LogPage { // @todo FIXME private/protected/public property? $this->timestamp = $now = wfTimestampNow(); - $data = array( + $data = [ 'log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, @@ -109,7 +109,7 @@ class LogPage { 'log_page' => $this->target->getArticleID(), 'log_comment' => $this->comment, 'log_params' => $this->params - ); + ]; $dbw->insert( 'logging', $data, __METHOD__ ); $newId = !is_null( $log_id ) ? $log_id : $dbw->insertId(); @@ -225,7 +225,7 @@ class LogPage { * @return string HTML */ public static function actionText( $type, $action, $title = null, $skin = null, - $params = array(), $filterWikilinks = false + $params = [], $filterWikilinks = false ) { global $wgLang, $wgContLang, $wgLogActions; @@ -331,11 +331,11 @@ class LogPage { * * @return int The log_id of the inserted log entry */ - public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) { + public function addEntry( $action, $target, $comment, $params = [], $doer = null ) { global $wgContLang; if ( !is_array( $params ) ) { - $params = array( $params ); + $params = [ $params ]; } if ( $comment === null ) { @@ -394,14 +394,14 @@ class LogPage { return false; // nothing } - $data = array(); + $data = []; foreach ( $values as $value ) { - $data[] = array( + $data[] = [ 'ls_field' => $field, 'ls_value' => $value, 'ls_log_id' => $logid - ); + ]; } $dbw = wfGetDB( DB_MASTER ); @@ -428,7 +428,7 @@ class LogPage { */ public static function extractParams( $blob ) { if ( $blob === '' ) { - return array(); + return []; } else { return explode( "\n", $blob ); } diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 3583599bd0..11ae5d636a 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -28,7 +28,7 @@ */ class LogPager extends ReverseChronologicalPager { /** @var array Log types */ - private $types = array(); + private $types = []; /** @var string Events limited to those by performer when set */ private $performer = ''; @@ -58,8 +58,8 @@ class LogPager extends ReverseChronologicalPager { * @param int|bool $month The month to start from. Default: false * @param string $tagFilter Tag */ - public function __construct( $list, $types = array(), $performer = '', $title = '', $pattern = '', - $conds = array(), $year = false, $month = false, $tagFilter = '' ) { + public function __construct( $list, $types = [], $performer = '', $title = '', $pattern = '', + $conds = [], $year = false, $month = false, $tagFilter = '' ) { parent::__construct( $list->getContext() ); $this->mConds = $conds; @@ -87,7 +87,7 @@ class LogPager extends ReverseChronologicalPager { // Call ONLY after calling $this->limitType() already! public function getFilterParams() { global $wgFilterLogTypes; - $filters = array(); + $filters = []; if ( count( $this->types ) ) { return $filters; } @@ -117,7 +117,7 @@ class LogPager extends ReverseChronologicalPager { $user = $this->getUser(); // If $types is not an array, make it an array - $types = ( $types === '' ) ? array() : (array)$types; + $types = ( $types === '' ) ? [] : (array)$types; // Don't even show header for private logs; don't recognize it... $needReindex = false; foreach ( $types as $type ) { @@ -125,7 +125,7 @@ class LogPager extends ReverseChronologicalPager { && !$user->isAllowed( $wgLogRestrictions[$type] ) ) { $needReindex = true; - $types = array_diff( $types, array( $type ) ); + $types = array_diff( $types, [ $type ] ); } } if ( $needReindex ) { @@ -208,7 +208,7 @@ class LogPager extends ReverseChronologicalPager { $db = $this->mDb; $doUserRightsLogLike = false; - if ( $this->types == array( 'rights' ) ) { + if ( $this->types == [ 'rights' ] ) { $parts = explode( $wgUserrightsInterwikiDelimiter, $title->getDBKey() ); if ( count( $parts ) == 2 ) { list( $name, $database ) = array_map( 'trim', $parts ); @@ -233,7 +233,7 @@ class LogPager extends ReverseChronologicalPager { */ $this->mConds['log_namespace'] = $ns; if ( $doUserRightsLogLike ) { - $params = array( $name . $wgUserrightsInterwikiDelimiter ); + $params = [ $name . $wgUserrightsInterwikiDelimiter ]; foreach ( explode( '*', $database ) as $databasepart ) { $params[] = $databasepart; $params[] = $db->anyString(); @@ -270,7 +270,7 @@ class LogPager extends ReverseChronologicalPager { $options = $basic['options']; $joins = $basic['join_conds']; - $index = array(); + $index = []; # Add log_search table if there are conditions on it. # This filters the results to only include log rows that have # log_search records with the specified ls_field and ls_value values. @@ -291,15 +291,15 @@ class LogPager extends ReverseChronologicalPager { $options['USE INDEX'] = $index; } # Don't show duplicate rows when using log_search - $joins['log_search'] = array( 'INNER JOIN', 'ls_log_id=log_id' ); + $joins['log_search'] = [ 'INNER JOIN', 'ls_log_id=log_id' ]; - $info = array( + $info = [ 'tables' => $tables, 'fields' => $fields, 'conds' => array_merge( $conds, $this->mConds ), 'options' => $options, 'join_conds' => $joins, - ); + ]; # Add ChangeTags filter query ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $info['options'], $this->mTagFilter ); diff --git a/includes/logging/MergeLogFormatter.php b/includes/logging/MergeLogFormatter.php index 36e383b069..b0edd4c07f 100644 --- a/includes/logging/MergeLogFormatter.php +++ b/includes/logging/MergeLogFormatter.php @@ -31,12 +31,12 @@ class MergeLogFormatter extends LogFormatter { public function getPreloadTitles() { $params = $this->extractParameters(); - return array( Title::newFromText( $params[3] ) ); + return [ Title::newFromText( $params[3] ) ]; } protected function getMessageParameters() { $params = parent::getMessageParameters(); - $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) ); + $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] ); $newname = $this->makePageLink( Title::newFromText( $params[3] ) ); $params[2] = Message::rawParam( $oldname ); $params[3] = Message::rawParam( $newname ); @@ -57,13 +57,13 @@ class MergeLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'MergeHistory' ), $this->msg( 'revertmerge' )->escaped(), - array(), - array( + [], + [ 'target' => $params[3], 'dest' => $this->entry->getTarget()->getPrefixedDBkey(), 'mergepoint' => $params[4], 'submitted' => 1 // show the revisions immediately - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -73,12 +73,12 @@ class MergeLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:title:dest', '5:timestamp:mergepoint', '4::dest' => '4:title:dest', '5::mergepoint' => '5:timestamp:mergepoint', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/logging/MoveLogFormatter.php b/includes/logging/MoveLogFormatter.php index 7f5e9efab7..afbf8e95e6 100644 --- a/includes/logging/MoveLogFormatter.php +++ b/includes/logging/MoveLogFormatter.php @@ -32,7 +32,7 @@ class MoveLogFormatter extends LogFormatter { public function getPreloadTitles() { $params = $this->extractParameters(); - return array( Title::newFromText( $params[3] ) ); + return [ Title::newFromText( $params[3] ) ]; } protected function getMessageKey() { @@ -48,7 +48,7 @@ class MoveLogFormatter extends LogFormatter { protected function getMessageParameters() { $params = parent::getMessageParameters(); - $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) ); + $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] ); $newname = $this->makePageLink( Title::newFromText( $params[3] ) ); $params[2] = Message::rawParam( $oldname ); $params[3] = Message::rawParam( $newname ); @@ -74,13 +74,13 @@ class MoveLogFormatter extends LogFormatter { $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Movepage' ), $this->msg( 'revertmove' )->escaped(), - array(), - array( + [], + [ 'wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(), 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(), 'wpMovetalk' => 0 - ) + ] ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); @@ -90,12 +90,12 @@ class MoveLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:title:target', '5:bool:suppressredirect', '4::target' => '4:title:target', '5::noredir' => '5:bool:suppressredirect', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/logging/NewUsersLogFormatter.php b/includes/logging/NewUsersLogFormatter.php index b7068a08a0..382e4adb5c 100644 --- a/includes/logging/NewUsersLogFormatter.php +++ b/includes/logging/NewUsersLogFormatter.php @@ -60,9 +60,9 @@ class NewUsersLogFormatter extends LogFormatter { $subtype = $this->entry->getSubtype(); if ( $subtype === 'create2' || $subtype === 'byemail' ) { // add the user talk to LinkBatch for the userLink - return array( Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ); + return [ Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ]; } - return array(); + return []; } } diff --git a/includes/logging/PatrolLog.php b/includes/logging/PatrolLog.php index 4f2a565de3..510c71150d 100644 --- a/includes/logging/PatrolLog.php +++ b/includes/logging/PatrolLog.php @@ -76,10 +76,10 @@ class PatrolLog { * @return array */ private static function buildParams( $change, $auto ) { - return array( + return [ '4::curid' => $change->getAttribute( 'rc_this_oldid' ), '5::previd' => $change->getAttribute( 'rc_last_oldid' ), '6::auto' => (int)$auto - ); + ]; } } diff --git a/includes/logging/PatrolLogFormatter.php b/includes/logging/PatrolLogFormatter.php index 7fe0143ffb..0d007b3308 100644 --- a/includes/logging/PatrolLogFormatter.php +++ b/includes/logging/PatrolLogFormatter.php @@ -49,11 +49,11 @@ class PatrolLogFormatter extends LogFormatter { if ( $this->plaintext ) { $revlink = $revision; } elseif ( $target->exists() ) { - $query = array( + $query = [ 'oldid' => $oldid, 'diff' => 'prev' - ); - $revlink = Linker::link( $target, htmlspecialchars( $revision ), array(), $query ); + ]; + $revlink = Linker::link( $target, htmlspecialchars( $revision ), [], $query ); } else { $revlink = htmlspecialchars( $revision ); } @@ -67,14 +67,14 @@ class PatrolLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:number:curid', '5:number:previd', '6:bool:auto', '4::curid' => '4:number:curid', '5::previd' => '5:number:previd', '6::auto' => '6:bool:auto', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/logging/ProtectLogFormatter.php b/includes/logging/ProtectLogFormatter.php index bd04f15e60..0458297190 100644 --- a/includes/logging/ProtectLogFormatter.php +++ b/includes/logging/ProtectLogFormatter.php @@ -32,9 +32,9 @@ class ProtectLogFormatter extends LogFormatter { $subtype = $this->entry->getSubtype(); if ( $subtype === 'move_prot' ) { $params = $this->extractParameters(); - return array( Title::newFromText( $params[3] ) ); + return [ Title::newFromText( $params[3] ) ]; } - return array(); + return []; } protected function getMessageKey() { @@ -69,7 +69,7 @@ class ProtectLogFormatter extends LogFormatter { unset( $params[4] ); } } elseif ( $subtype === 'move_prot' ) { - $oldname = $this->makePageLink( Title::newFromText( $params[3] ), array( 'redirect' => 'no' ) ); + $oldname = $this->makePageLink( Title::newFromText( $params[3] ), [ 'redirect' => 'no' ] ); $params[3] = Message::rawParam( $oldname ); } @@ -86,24 +86,24 @@ class ProtectLogFormatter extends LogFormatter { // Show history link for all changes after the protection $title = $this->entry->getTarget(); - $links = array( + $links = [ Linker::link( $title, $this->msg( 'hist' )->escaped(), - array(), - array( + [], + [ 'action' => 'history', 'offset' => $this->entry->getTimestamp(), - ) + ] ) - ); + ]; // Show change protection link if ( $this->context->getUser()->isAllowed( 'protect' ) ) { $links[] = Linker::linkKnown( $title, $this->msg( 'protect_change' )->escaped(), - array(), - array( 'action' => 'protect' ) + [], + [ 'action' => 'protect' ] ); } @@ -116,18 +116,18 @@ class ProtectLogFormatter extends LogFormatter { $subtype = $this->entry->getSubtype(); $params = $entry->getParameters(); - $map = array(); + $map = []; if ( $subtype === 'protect' || $subtype === 'modify' ) { - $map = array( + $map = [ '4::description', '5:bool:cascade', 'details' => ':array:details', - ); + ]; } elseif ( $subtype === 'move_prot' ) { - $map = array( + $map = [ '4:title:oldtitle', '4::oldtitle' => '4:title:oldtitle', - ); + ]; } foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php index 79ffe867a4..eebccddbcd 100644 --- a/includes/logging/RightsLogFormatter.php +++ b/includes/logging/RightsLogFormatter.php @@ -29,7 +29,7 @@ * @since 1.21 */ class RightsLogFormatter extends LogFormatter { - protected function makePageLink( Title $title = null, $parameters = array(), $html = null ) { + protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { global $wgContLang, $wgUserrightsInterwikiDelimiter; if ( !$this->plaintext ) { @@ -103,12 +103,12 @@ class RightsLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ '4:array:oldgroups', '5:array:newgroups', '4::oldgroups' => '4:array:oldgroups', '5::newgroups' => '5:array:newgroups', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; @@ -141,7 +141,7 @@ class RightsLogFormatter extends LogFormatter { private function makeGroupArray( $group ) { // Migrate old group params from string to array if ( $group === '' ) { - $group = array(); + $group = []; } elseif ( is_string( $group ) ) { $group = array_map( 'trim', explode( ',', $group ) ); } diff --git a/includes/logging/UploadLogFormatter.php b/includes/logging/UploadLogFormatter.php index 52961dc4aa..6c5367172f 100644 --- a/includes/logging/UploadLogFormatter.php +++ b/includes/logging/UploadLogFormatter.php @@ -33,9 +33,9 @@ class UploadLogFormatter extends LogFormatter { $entry = $this->entry; $params = $entry->getParameters(); - static $map = array( + static $map = [ 'img_timestamp' => ':timestamp:img_timestamp', - ); + ]; foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 9bda12cb4d..30907e636c 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -59,7 +59,7 @@ class EmailNotification { protected $subject, $body, $replyto, $from; protected $timestamp, $summary, $minorEdit, $oldid, $composed_common, $pageStatus; - protected $mailTargets = array(); + protected $mailTargets = []; /** * @var Title @@ -86,21 +86,21 @@ class EmailNotification { global $wgEnotifWatchlist, $wgShowUpdatedMarker; if ( !$wgEnotifWatchlist && !$wgShowUpdatedMarker ) { - return array(); + return []; } $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->select( array( 'watchlist' ), - array( 'wl_user' ), - array( + $res = $dbw->select( [ 'watchlist' ], + [ 'wl_user' ], + [ 'wl_user != ' . intval( $editor->getID() ), 'wl_namespace' => $linkTarget->getNamespace(), 'wl_title' => $linkTarget->getDBkey(), 'wl_notificationtimestamp IS NULL', - ), __METHOD__ + ], __METHOD__ ); - $watchers = array(); + $watchers = []; foreach ( $res as $row ) { $watchers[] = intval( $row->wl_user ); } @@ -111,13 +111,13 @@ class EmailNotification { $dbw->onTransactionIdle( function () use ( $dbw, $timestamp, $watchers, $linkTarget, $fname ) { $dbw->update( 'watchlist', - array( /* SET */ + [ /* SET */ 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) - ), array( /* WHERE */ + ], [ /* WHERE */ 'wl_user' => $watchers, 'wl_namespace' => $linkTarget->getNamespace(), 'wl_title' => $linkTarget->getDBkey(), - ), $fname + ], $fname ); } ); @@ -173,7 +173,7 @@ class EmailNotification { if ( $sendEmail ) { JobQueueGroup::singleton()->lazyPush( new EnotifNotifyJob( $title, - array( + [ 'editor' => $editor->getName(), 'editorID' => $editor->getID(), 'timestamp' => $timestamp, @@ -182,7 +182,7 @@ class EmailNotification { 'oldid' => $oldid, 'watchers' => $watchers, 'pageStatus' => $pageStatus - ) + ] ) ); } } @@ -225,9 +225,9 @@ class EmailNotification { $this->composed_common = false; $this->pageStatus = $pageStatus; - $formattedPageStatus = array( 'deleted', 'created', 'moved', 'restored', 'changed' ); + $formattedPageStatus = [ 'deleted', 'created', 'moved', 'restored', 'changed' ]; - Hooks::run( 'UpdateUserMailerFormattedPageStatus', array( &$formattedPageStatus ) ); + Hooks::run( 'UpdateUserMailerFormattedPageStatus', [ &$formattedPageStatus ] ); if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) { throw new MWException( 'Not a valid page status!' ); } @@ -256,7 +256,7 @@ class EmailNotification { && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges ) && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() ) ) { - if ( Hooks::run( 'SendWatchlistEmailNotification', array( $watchingUser, $title, $this ) ) ) { + if ( Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) { $this->compose( $watchingUser, self::WATCHLIST ); } } @@ -300,7 +300,7 @@ class EmailNotification { ) { if ( !$targetUser->isEmailConfirmed() ) { wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" ); - } elseif ( !Hooks::run( 'AbortTalkPageEmailNotification', array( $targetUser, $title ) ) ) { + } elseif ( !Hooks::run( 'AbortTalkPageEmailNotification', [ $targetUser, $title ] ) ) { wfDebug( __METHOD__ . ": talk page update notification is aborted for this user\n" ); } else { wfDebug( __METHOD__ . ": sending talk page update notification\n" ); @@ -327,22 +327,22 @@ class EmailNotification { # named variables when composing your notification emails while # simply editing the Meta pages - $keys = array(); - $postTransformKeys = array(); + $keys = []; + $postTransformKeys = []; $pageTitleUrl = $this->title->getCanonicalURL(); $pageTitle = $this->title->getPrefixedText(); if ( $this->oldid ) { // Always show a link to the diff which triggered the mail. See bug 32210. $keys['$NEWPAGE'] = "\n\n" . wfMessage( 'enotif_lastdiff', - $this->title->getCanonicalURL( array( 'diff' => 'next', 'oldid' => $this->oldid ) ) ) + $this->title->getCanonicalURL( [ 'diff' => 'next', 'oldid' => $this->oldid ] ) ) ->inContentLanguage()->text(); if ( !$wgEnotifImpersonal ) { // For personal mail, also show a link to the diff of all changes // since last visited. $keys['$NEWPAGE'] .= "\n\n" . wfMessage( 'enotif_lastvisited', - $this->title->getCanonicalURL( array( 'diff' => '0', 'oldid' => $this->oldid ) ) ) + $this->title->getCanonicalURL( [ 'diff' => '0', 'oldid' => $this->oldid ] ) ) ->inContentLanguage()->text(); } $keys['$OLDID'] = $this->oldid; @@ -479,24 +479,24 @@ class EmailNotification { # expressed in terms of individual local time of the notification # recipient, i.e. watching user $body = str_replace( - array( '$WATCHINGUSERNAME', + [ '$WATCHINGUSERNAME', '$PAGEEDITDATE', - '$PAGEEDITTIME' ), - array( $wgEnotifUseRealName && $watchingUser->getRealName() !== '' + '$PAGEEDITTIME' ], + [ $wgEnotifUseRealName && $watchingUser->getRealName() !== '' ? $watchingUser->getRealName() : $watchingUser->getName(), $wgContLang->userDate( $this->timestamp, $watchingUser ), - $wgContLang->userTime( $this->timestamp, $watchingUser ) ), + $wgContLang->userTime( $this->timestamp, $watchingUser ) ], $this->body ); - $headers = array(); + $headers = []; if ( $source === self::WATCHLIST ) { $headers['List-Help'] = 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist'; } - return UserMailer::send( $to, $this->from, $this->subject, $body, array( + return UserMailer::send( $to, $this->from, $this->subject, $body, [ 'replyTo' => $this->replyto, 'headers' => $headers, - ) ); + ] ); } /** @@ -513,17 +513,17 @@ class EmailNotification { } $body = str_replace( - array( '$WATCHINGUSERNAME', + [ '$WATCHINGUSERNAME', '$PAGEEDITDATE', - '$PAGEEDITTIME' ), - array( wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(), + '$PAGEEDITTIME' ], + [ wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(), $wgContLang->date( $this->timestamp, false, false ), - $wgContLang->time( $this->timestamp, false, false ) ), + $wgContLang->time( $this->timestamp, false, false ) ], $this->body ); - return UserMailer::send( $addresses, $this->from, $this->subject, $body, array( + return UserMailer::send( $addresses, $this->from, $this->subject, $body, [ 'replyTo' => $this->replyto, - ) ); + ] ); } } diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index b5a09bde82..983f42c636 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -65,7 +65,7 @@ class UserMailer { * @return string */ static function arrayToHeaderString( $headers, $endl = PHP_EOL ) { - $strings = array(); + $strings = []; foreach ( $headers as $name => $value ) { // Prevent header injection by stripping newlines from value $value = self::sanitizeHeaderValue( $value ); @@ -114,20 +114,20 @@ class UserMailer { * @throws Exception * @return Status */ - public static function send( $to, $from, $subject, $body, $options = array() ) { + public static function send( $to, $from, $subject, $body, $options = [] ) { global $wgAllowHTMLEmail; $contentType = 'text/plain; charset=UTF-8'; if ( !is_array( $options ) ) { // Old calling style wfDeprecated( __METHOD__ . ' with $replyto as 5th parameter', '1.26' ); - $options = array( 'replyTo' => $options ); + $options = [ 'replyTo' => $options ]; if ( func_num_args() === 6 ) { $options['contentType'] = func_get_arg( 5 ); } } if ( !is_array( $to ) ) { - $to = array( $to ); + $to = [ $to ]; } // mail body must have some content @@ -176,7 +176,7 @@ class UserMailer { // target differently to split up the address list if ( count( $to ) > 1 ) { $oldTo = $to; - Hooks::run( 'UserMailerSplitTo', array( &$to ) ); + Hooks::run( 'UserMailerSplitTo', [ &$to ] ); if ( $oldTo != $to ) { $splitTo = array_diff( $oldTo, $to ); $to = array_diff( $oldTo, $splitTo ); // ignore new addresses added in the hook @@ -188,7 +188,7 @@ class UserMailer { } foreach ( $splitTo as $newTo ) { $status->merge( UserMailer::sendInternal( - array( $newTo ), $from, $subject, $body, $options ) ); + [ $newTo ], $from, $subject, $body, $options ) ); } return $status; } @@ -218,7 +218,7 @@ class UserMailer { MailAddress $from, $subject, $body, - $options = array() + $options = [] ) { global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams; $mime = null; @@ -226,11 +226,11 @@ class UserMailer { $replyto = isset( $options['replyTo'] ) ? $options['replyTo'] : null; $contentType = isset( $options['contentType'] ) ? $options['contentType'] : 'text/plain; charset=UTF-8'; - $headers = isset( $options['headers'] ) ? $options['headers'] : array(); + $headers = isset( $options['headers'] ) ? $options['headers'] : []; // Allow transformation of content, such as encrypting/signing $error = false; - if ( !Hooks::run( 'UserMailerTransformContent', array( $to, $from, &$body, &$error ) ) ) { + if ( !Hooks::run( 'UserMailerTransformContent', [ $to, $from, &$body, &$error ] ) ) { if ( $error ) { return Status::newFatal( 'php-mail-error', $error ); } else { @@ -272,7 +272,7 @@ class UserMailer { $extraParams = $wgAdditionalMailParams; // Hook to generate custom VERP address for 'Return-Path' - Hooks::run( 'UserMailerChangeReturnPath', array( $to, &$returnPath ) ); + Hooks::run( 'UserMailerChangeReturnPath', [ $to, &$returnPath ] ); // Add the envelope sender address using the -f command line option when PHP mail() is used. // Will default to the $from->address when the UserMailerChangeReturnPath hook fails and the // generated VERP address when the hook runs effectively. @@ -310,11 +310,11 @@ class UserMailer { $body['text'] = str_replace( "\n", "\r\n", $body['text'] ); $body['html'] = str_replace( "\n", "\r\n", $body['html'] ); } - $mime = new Mail_mime( array( + $mime = new Mail_mime( [ 'eol' => $endl, 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8' - ) ); + ] ); $mime->setTXTBody( $body['text'] ); $mime->setHTMLBody( $body['html'] ); $body = $mime->get(); // must call get() before headers() @@ -334,7 +334,7 @@ class UserMailer { // allow transformation of MIME-encoded message if ( !Hooks::run( 'UserMailerTransformMessage', - array( $to, $from, &$subject, &$headers, &$body, &$error ) ) + [ $to, $from, &$subject, &$headers, &$body, &$error ] ) ) { if ( $error ) { return Status::newFatal( 'php-mail-error', $error ); @@ -343,7 +343,7 @@ class UserMailer { } } - $ret = Hooks::run( 'AlternateUserMailer', array( $headers, $to, $from, $subject, $body ) ); + $ret = Hooks::run( 'AlternateUserMailer', [ $headers, $to, $from, $subject, $body ] ); if ( $ret === false ) { // the hook implementation will return false to skip regular mail sending return Status::newGood(); @@ -455,7 +455,7 @@ class UserMailer { * @return string */ public static function sanitizeHeaderValue( $val ) { - return strtr( $val, array( "\r" => '', "\n" => '' ) ); + return strtr( $val, [ "\r" => '', "\n" => '' ] ); } /** @@ -499,7 +499,7 @@ class UserMailer { } $out = "=?$charset?Q?"; $out .= preg_replace_callback( "/([$replace])/", - array( __CLASS__, 'quotedPrintableCallback' ), $string ); + [ __CLASS__, 'quotedPrintableCallback' ], $string ); $out .= '?='; return $out; } diff --git a/includes/media/BMP.php b/includes/media/BMP.php index 52f9518f79..64f12f71e4 100644 --- a/includes/media/BMP.php +++ b/includes/media/BMP.php @@ -45,7 +45,7 @@ class BmpHandler extends BitmapHandler { * @return array */ function getThumbType( $text, $mime, $params = null ) { - return array( 'png', 'image/png' ); + return [ 'png', 'image/png' ]; } /** @@ -75,6 +75,6 @@ class BmpHandler extends BitmapHandler { return false; } - return array( $w[1], $h[1] ); + return [ $w[1], $h[1] ]; } } diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index c2b82d8605..b470e064c8 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -117,37 +117,37 @@ class BitmapHandler extends TransformationalImageHandler { global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea, $wgImageMagickTempDir, $wgImageMagickConvertCommand, $wgMaxInterlacingAreas; - $quality = array(); - $sharpen = array(); + $quality = []; + $sharpen = []; $scene = false; - $animation_pre = array(); - $animation_post = array(); - $decoderHint = array(); + $animation_pre = []; + $animation_post = []; + $decoderHint = []; if ( $params['mimeType'] == 'image/jpeg' ) { $qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null; - $quality = array( '-quality', $qualityVal ?: '80' ); // 80% + $quality = [ '-quality', $qualityVal ?: '80' ]; // 80% if ( $params['interlace'] ) { - $animation_post = array( '-interlace', 'JPEG' ); + $animation_post = [ '-interlace', 'JPEG' ]; } # Sharpening, see bug 6193 if ( ( $params['physicalWidth'] + $params['physicalHeight'] ) / ( $params['srcWidth'] + $params['srcHeight'] ) < $wgSharpenReductionThreshold ) { - $sharpen = array( '-sharpen', $wgSharpenParameter ); + $sharpen = [ '-sharpen', $wgSharpenParameter ]; } if ( version_compare( $this->getMagickVersion(), "6.5.6" ) >= 0 ) { // JPEG decoder hint to reduce memory, available since IM 6.5.6-2 - $decoderHint = array( '-define', "jpeg:size={$params['physicalDimensions']}" ); + $decoderHint = [ '-define', "jpeg:size={$params['physicalDimensions']}" ]; } } elseif ( $params['mimeType'] == 'image/png' ) { - $quality = array( '-quality', '95' ); // zlib 9, adaptive filtering + $quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering if ( $params['interlace'] ) { - $animation_post = array( '-interlace', 'PNG' ); + $animation_post = [ '-interlace', 'PNG' ]; } } elseif ( $params['mimeType'] == 'image/webp' ) { - $quality = array( '-quality', '95' ); // zlib 9, adaptive filtering + $quality = [ '-quality', '95' ]; // zlib 9, adaptive filtering } elseif ( $params['mimeType'] == 'image/gif' ) { if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) { // Extract initial frame only; we're so big it'll @@ -155,11 +155,11 @@ class BitmapHandler extends TransformationalImageHandler { $scene = 0; } elseif ( $this->isAnimatedImage( $image ) ) { // Coalesce is needed to scale animated GIFs properly (bug 1017). - $animation_pre = array( '-coalesce' ); + $animation_pre = [ '-coalesce' ]; // We optimize the output, but -optimize is broken, // use optimizeTransparency instead (bug 11822) if ( version_compare( $this->getMagickVersion(), "6.3.5" ) >= 0 ) { - $animation_post = array( '-fuzz', '5%', '-layers', 'optimizeTransparency' ); + $animation_post = [ '-fuzz', '5%', '-layers', 'optimizeTransparency' ]; } } if ( $params['interlace'] && version_compare( $this->getMagickVersion(), "6.3.4" ) >= 0 @@ -174,11 +174,11 @@ class BitmapHandler extends TransformationalImageHandler { // background colour. After merging we reset the background // to be white for the default background colour setting // in the PNG image (which is used in old IE) - $animation_pre = array( + $animation_pre = [ '-background', 'transparent', '-layers', 'merge', '-background', 'white', - ); + ]; MediaWiki\suppressWarnings(); $xcfMeta = unserialize( $image->getMetadata() ); MediaWiki\restoreWarnings(); @@ -189,13 +189,13 @@ class BitmapHandler extends TransformationalImageHandler { ) { // bug 66323 - Greyscale images not rendered properly. // So only take the "red" channel. - $channelOnly = array( '-channel', 'R', '-separate' ); + $channelOnly = [ '-channel', 'R', '-separate' ]; $animation_pre = array_merge( $animation_pre, $channelOnly ); } } // Use one thread only, to avoid deadlock bugs on OOM - $env = array( 'OMP_NUM_THREADS' => 1 ); + $env = [ 'OMP_NUM_THREADS' => 1 ]; if ( strval( $wgImageMagickTempDir ) !== '' ) { $env['MAGICK_TMPDIR'] = $wgImageMagickTempDir; } @@ -204,29 +204,29 @@ class BitmapHandler extends TransformationalImageHandler { list( $width, $height ) = $this->extractPreRotationDimensions( $params, $rotation ); $cmd = call_user_func_array( 'wfEscapeShellArg', array_merge( - array( $wgImageMagickConvertCommand ), + [ $wgImageMagickConvertCommand ], $quality, // Specify white background color, will be used for transparent images // in Internet Explorer/Windows instead of default black. - array( '-background', 'white' ), + [ '-background', 'white' ], $decoderHint, - array( $this->escapeMagickInput( $params['srcPath'], $scene ) ), + [ $this->escapeMagickInput( $params['srcPath'], $scene ) ], $animation_pre, // For the -thumbnail option a "!" is needed to force exact size, // or ImageMagick may decide your ratio is wrong and slice off // a pixel. - array( '-thumbnail', "{$width}x{$height}!" ), + [ '-thumbnail', "{$width}x{$height}!" ], // Add the source url as a comment to the thumb, but don't add the flag if there's no comment ( $params['comment'] !== '' - ? array( '-set', 'comment', $this->escapeMagickProperty( $params['comment'] ) ) - : array() ), + ? [ '-set', 'comment', $this->escapeMagickProperty( $params['comment'] ) ] + : [] ), // T108616: Avoid exposure of local file path - array( '+set', 'Thumb::URI' ), - array( '-depth', 8 ), + [ '+set', 'Thumb::URI' ], + [ '-depth', 8 ], $sharpen, - array( '-rotate', "-$rotation" ), + [ '-rotate', "-$rotation" ], $animation_post, - array( $this->escapeMagickOutput( $params['dstPath'] ) ) ) ); + [ $this->escapeMagickOutput( $params['dstPath'] ) ] ) ); wfDebug( __METHOD__ . ": running ImageMagick: $cmd\n" ); $retval = 0; @@ -377,14 +377,14 @@ class BitmapHandler extends TransformationalImageHandler { # First find out what kind of file this is, and select the correct # input routine for this. - $typemap = array( - 'image/gif' => array( 'imagecreatefromgif', 'palette', false, 'imagegif' ), - 'image/jpeg' => array( 'imagecreatefromjpeg', 'truecolor', true, - array( __CLASS__, 'imageJpegWrapper' ) ), - 'image/png' => array( 'imagecreatefrompng', 'bits', false, 'imagepng' ), - 'image/vnd.wap.wbmp' => array( 'imagecreatefromwbmp', 'palette', false, 'imagewbmp' ), - 'image/xbm' => array( 'imagecreatefromxbm', 'palette', false, 'imagexbm' ), - ); + $typemap = [ + 'image/gif' => [ 'imagecreatefromgif', 'palette', false, 'imagegif' ], + 'image/jpeg' => [ 'imagecreatefromjpeg', 'truecolor', true, + [ __CLASS__, 'imageJpegWrapper' ] ], + 'image/png' => [ 'imagecreatefrompng', 'bits', false, 'imagepng' ], + 'image/vnd.wap.wbmp' => [ 'imagecreatefromwbmp', 'palette', false, 'imagewbmp' ], + 'image/xbm' => [ 'imagecreatefromxbm', 'palette', false, 'imagexbm' ], + ]; if ( !isset( $typemap[$params['mimeType']] ) ) { $err = 'Image type not supported'; @@ -447,7 +447,7 @@ class BitmapHandler extends TransformationalImageHandler { imagesavealpha( $dst_image, true ); - $funcParams = array( $dst_image, $params['dstPath'] ); + $funcParams = [ $dst_image, $params['dstPath'] ]; if ( $useQuality && isset( $params['quality'] ) ) { $funcParams[] = $params['quality']; } diff --git a/includes/media/BitmapMetadataHandler.php b/includes/media/BitmapMetadataHandler.php index a5cddac9d8..7999bbbf86 100644 --- a/includes/media/BitmapMetadataHandler.php +++ b/includes/media/BitmapMetadataHandler.php @@ -35,19 +35,19 @@ use MediaWiki\Logger\LoggerFactory; */ class BitmapMetadataHandler { /** @var array */ - private $metadata = array(); + private $metadata = []; /** @var array Metadata priority */ - private $metaPriority = array( - 20 => array( 'other' ), - 40 => array( 'native' ), - 60 => array( 'iptc-good-hash', 'iptc-no-hash' ), - 70 => array( 'xmp-deprecated' ), - 80 => array( 'xmp-general' ), - 90 => array( 'xmp-exif' ), - 100 => array( 'iptc-bad-hash' ), - 120 => array( 'exif' ), - ); + private $metaPriority = [ + 20 => [ 'other' ], + 40 => [ 'native' ], + 60 => [ 'iptc-good-hash', 'iptc-no-hash' ], + 70 => [ 'xmp-deprecated' ], + 80 => [ 'xmp-general' ], + 90 => [ 'xmp-exif' ], + 100 => [ 'iptc-bad-hash' ], + 120 => [ 'exif' ], + ]; /** @var string */ private $iptcType = 'iptc-no-hash'; @@ -123,7 +123,7 @@ class BitmapMetadataHandler { function getMetadataArray() { // this seems a bit ugly... This is all so its merged in right order // based on the MWG recomendation. - $temp = array(); + $temp = []; krsort( $this->metaPriority ); foreach ( $this->metaPriority as $pri ) { foreach ( $pri as $type ) { @@ -161,7 +161,7 @@ class BitmapMetadataHandler { $seg = JpegMetadataExtractor::segmentSplitter( $filename ); if ( isset( $seg['COM'] ) && isset( $seg['COM'][0] ) ) { - $meta->addMetadata( array( 'JPEGFileComment' => $seg['COM'] ), 'native' ); + $meta->addMetadata( [ 'JPEGFileComment' => $seg['COM'] ], 'native' ); } if ( isset( $seg['PSIR'] ) && count( $seg['PSIR'] ) > 0 ) { foreach ( $seg['PSIR'] as $curPSIRValue ) { @@ -235,7 +235,7 @@ class BitmapMetadataHandler { $baseArray = GIFMetadataExtractor::getMetadata( $filename ); if ( count( $baseArray['comment'] ) > 0 ) { - $meta->addMetadata( array( 'GIFFileComment' => $baseArray['comment'] ), 'native' ); + $meta->addMetadata( [ 'GIFFileComment' => $baseArray['comment'] ], 'native' ); } if ( $baseArray['xmp'] !== '' && XMPReader::isSupported() ) { diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php index 5cc05f2705..0d2ed29b00 100644 --- a/includes/media/DjVu.php +++ b/includes/media/DjVu.php @@ -72,10 +72,10 @@ class DjVuHandler extends ImageHandler { * @return array */ function getParamMap() { - return array( + return [ 'img_width' => 'width', 'img_page' => 'page', - ); + ]; } /** @@ -89,7 +89,7 @@ class DjVuHandler extends ImageHandler { // e.g. [[File:Foo.djvu|thumb|Page 3 of the document shows foo]] return false; } - if ( in_array( $name, array( 'width', 'height', 'page' ) ) ) { + if ( in_array( $name, [ 'width', 'height', 'page' ] ) ) { if ( $value <= 0 ) { return false; } else { @@ -120,7 +120,7 @@ class DjVuHandler extends ImageHandler { function parseParamString( $str ) { $m = false; if ( preg_match( '/^page(\d+)-(\d+)px$/', $str, $m ) ) { - return array( 'width' => $m[2], 'page' => $m[1] ); + return [ 'width' => $m[2], 'page' => $m[1] ]; } else { return false; } @@ -131,10 +131,10 @@ class DjVuHandler extends ImageHandler { * @return array */ function getScriptParams( $params ) { - return array( + return [ 'width' => $params['width'], 'page' => $params['page'], - ); + ]; } /** @@ -156,11 +156,11 @@ class DjVuHandler extends ImageHandler { $page = $params['page']; if ( $flags & self::TRANSFORM_LATER ) { - $params = array( + $params = [ 'width' => $width, 'height' => $height, 'page' => $page - ); + ]; return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } @@ -179,11 +179,11 @@ class DjVuHandler extends ImageHandler { // Provide a way to pool count limit the number of downloaders. if ( $image->getSize() >= 1e7 ) { // 10MB $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $image->getName() ), - array( + [ 'doWork' => function () use ( $image ) { return $image->getLocalRefPath(); } - ) + ] ); $srcPath = $work->execute(); } else { @@ -222,11 +222,11 @@ class DjVuHandler extends ImageHandler { $this->logErrorForExternalProcess( $retval, $err, $cmd ); return new MediaTransformError( 'thumbnail_error', $width, $height, $err ); } else { - $params = array( + $params = [ 'width' => $width, 'height' => $height, 'page' => $page - ); + ]; return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } @@ -352,7 +352,7 @@ class DjVuHandler extends ImageHandler { $mime = $magic->guessTypesForExtension( $wgDjvuOutputExtension ); } - return array( $wgDjvuOutputExtension, $mime ); + return [ $wgDjvuOutputExtension, $mime ]; } function getMetadata( $image, $path ) { @@ -361,9 +361,9 @@ class DjVuHandler extends ImageHandler { $xml = $this->getDjVuImage( $image, $path )->retrieveMetaData(); if ( $xml === false ) { // Special value so that we don't repetitively try and decode a broken file. - return serialize( array( 'error' => 'Error extracting metadata' ) ); + return serialize( [ 'error' => 'Error extracting metadata' ] ); } else { - return serialize( array( 'xml' => $xml ) ); + return serialize( [ 'xml' => $xml ] ); } } @@ -372,7 +372,7 @@ class DjVuHandler extends ImageHandler { } function isMetadataValid( $image, $metadata ) { - return !empty( $metadata ) && $metadata != serialize( array() ); + return !empty( $metadata ) && $metadata != serialize( [] ); } function pageCount( File $image ) { @@ -404,21 +404,21 @@ class DjVuHandler extends ImageHandler { return false; } - $dimsByPage = array(); + $dimsByPage = []; $count = count( $tree->xpath( '//OBJECT' ) ); for ( $i = 0; $i < $count; ++$i ) { $o = $tree->BODY[0]->OBJECT[$i]; if ( $o ) { - $dimsByPage[$i] = array( + $dimsByPage[$i] = [ 'width' => (int)$o['width'], 'height' => (int)$o['height'] - ); + ]; } else { $dimsByPage[$i] = false; } } - return array( 'pageCount' => $count, 'dimensionsByPage' => $dimsByPage ); + return [ 'pageCount' => $count, 'dimensionsByPage' => $dimsByPage ]; } ); } diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index 3b9b7c97b6..16740d840a 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -69,8 +69,8 @@ class DjVuImage { $width = $data['width']; $height = $data['height']; - return array( $width, $height, 'DjVu', - "width=\"$width\" height=\"$height\"" ); + return [ $width, $height, 'DjVu', + "width=\"$width\" height=\"$height\"" ]; } return false; @@ -166,7 +166,7 @@ class DjVuImage { private function readChunk( $file ) { $header = fread( $file, 8 ); if ( strlen( $header ) < 8 ) { - return array( false, 0 ); + return [ false, 0 ]; } else { // @todo FIXME: Would be good to replace this extract() call with // something that explicitly initializes local variables. @@ -174,7 +174,7 @@ class DjVuImage { /** @var string $chunk * @var string $length */ - return array( $chunk, $length ); + return [ $chunk, $length ]; } } @@ -255,12 +255,12 @@ class DjVuImage { * @var string $resolution * @var string $length * @var string $gamma */ - return array( + return [ 'width' => $width, 'height' => $height, 'version' => "$major.$minor", 'resolution' => $resolution, - 'gamma' => $gamma / 10.0 ); + 'gamma' => $gamma / 10.0 ]; } /** @@ -292,7 +292,7 @@ class DjVuImage { $cmd = wfEscapeShellArg( $wgDjvuTxt ) . ' --detail=page ' . wfEscapeShellArg( $this->mFilename ); wfDebug( __METHOD__ . ": $cmd\n" ); $retval = ''; - $txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) ); + $txt = wfShellExec( $cmd, $retval, [], [ 'memory' => self::DJVUTXT_MEMORY_LIMIT ] ); if ( $retval == 0 ) { # Strip some control characters $txt = preg_replace( "/[\013\035\037]/", "", $txt ); @@ -307,7 +307,7 @@ class DjVuImage { | # Or page can be empty ; in this case, djvutxt dumps () \(\s*()\)/sx EOR; - $txt = preg_replace_callback( $reg, array( $this, 'pageTextCallback' ), $txt ); + $txt = preg_replace_callback( $reg, [ $this, 'pageTextCallback' ], $txt ); $txt = "\n\n\n" . $txt . "\n\n"; $xml = preg_replace( "//", "", $xml, 1 ); $xml = $xml . $txt . ''; @@ -320,7 +320,7 @@ EOR; function pageTextCallback( $matches ) { # Get rid of invalid UTF-8, strip control characters $val = htmlspecialchars( UtfNormal\Validator::cleanUp( stripcslashes( $matches[1] ) ) ); - $val = str_replace( array( "\n", '�' ), array( ' ', '' ), $val ); + $val = str_replace( [ "\n", '�' ], [ ' ', '' ], $val ); return ''; } @@ -409,16 +409,16 @@ EOT; ) ) { $xml .= Xml::tags( 'OBJECT', - array( + [ # 'data' => '', # 'type' => 'image/x.djvu', 'height' => $m[2], 'width' => $m[1], # 'usemap' => '', - ), + ], "\n" . - Xml::element( 'PARAM', array( 'name' => 'DPI', 'value' => $m[3] ) ) . "\n" . - Xml::element( 'PARAM', array( 'name' => 'GAMMA', 'value' => $m[4] ) ) . "\n" + Xml::element( 'PARAM', [ 'name' => 'DPI', 'value' => $m[3] ] ) . "\n" . + Xml::element( 'PARAM', [ 'name' => 'GAMMA', 'value' => $m[4] ] ) . "\n" ) . "\n"; return true; diff --git a/includes/media/Exif.php b/includes/media/Exif.php index 052c39df56..11178f42cc 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -116,13 +116,13 @@ class Exif { * * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification */ - $this->mExifTags = array( + $this->mExifTags = [ # TIFF Rev. 6.0 Attribute Information (p22) - 'IFD0' => array( + 'IFD0' => [ # Tags relating to image structure 'ImageWidth' => Exif::SHORT_OR_LONG, # Image width 'ImageLength' => Exif::SHORT_OR_LONG, # Image height - 'BitsPerSample' => array( Exif::SHORT, 3 ), # Number of bits per component + 'BitsPerSample' => [ Exif::SHORT, 3 ], # Number of bits per component # "When a primary image is JPEG compressed, this designation is not" # "necessary and is omitted." (p23) 'Compression' => Exif::SHORT, # Compression scheme #p23 @@ -130,7 +130,7 @@ class Exif { 'Orientation' => Exif::SHORT, # Orientation of image #p24 'SamplesPerPixel' => Exif::SHORT, # Number of components 'PlanarConfiguration' => Exif::SHORT, # Image data arrangement #p24 - 'YCbCrSubSampling' => array( Exif::SHORT, 2 ), # Subsampling ratio of Y to C #p24 + 'YCbCrSubSampling' => [ Exif::SHORT, 2 ], # Subsampling ratio of Y to C #p24 'YCbCrPositioning' => Exif::SHORT, # Y and C positioning #p24-25 'XResolution' => Exif::RATIONAL, # Image resolution in width direction 'YResolution' => Exif::RATIONAL, # Image resolution in height direction @@ -145,11 +145,11 @@ class Exif { # Tags relating to image data characteristics 'TransferFunction' => Exif::IGNORE, # Transfer function - 'WhitePoint' => array( Exif::RATIONAL, 2 ), # White point chromaticity - 'PrimaryChromaticities' => array( Exif::RATIONAL, 6 ), # Chromaticities of primarities + 'WhitePoint' => [ Exif::RATIONAL, 2 ], # White point chromaticity + 'PrimaryChromaticities' => [ Exif::RATIONAL, 6 ], # Chromaticities of primarities # Color space transformation matrix coefficients #p27 - 'YCbCrCoefficients' => array( Exif::RATIONAL, 3 ), - 'ReferenceBlackWhite' => array( Exif::RATIONAL, 6 ), # Pair of black and white reference values + 'YCbCrCoefficients' => [ Exif::RATIONAL, 3 ], + 'ReferenceBlackWhite' => [ Exif::RATIONAL, 6 ], # Pair of black and white reference values # Other tags 'DateTime' => Exif::ASCII, # File change date and time @@ -159,10 +159,10 @@ class Exif { 'Software' => Exif::ASCII, # Software used 'Artist' => Exif::ASCII, # Person who created the image 'Copyright' => Exif::ASCII, # Copyright holder - ), + ], # Exif IFD Attribute Information (p30-31) - 'EXIF' => array( + 'EXIF' => [ # @todo NOTE: Nonexistence of this field is taken to mean nonconformance # to the Exif 2.1 AND 2.2 standards 'ExifVersion' => Exif::UNDEFINED, # Exif version @@ -209,13 +209,13 @@ class Exif { 'LightSource' => Exif::SHORT, # Light source #p40-41 'Flash' => Exif::SHORT, # Flash #p41-42 'FocalLength' => Exif::RATIONAL, # Lens focal length - 'SubjectArea' => array( Exif::SHORT, 4 ), # Subject area + 'SubjectArea' => [ Exif::SHORT, 4 ], # Subject area 'FlashEnergy' => Exif::RATIONAL, # Flash energy 'SpatialFrequencyResponse' => Exif::IGNORE, # Spatial frequency response. Not supported atm. 'FocalPlaneXResolution' => Exif::RATIONAL, # Focal plane X resolution 'FocalPlaneYResolution' => Exif::RATIONAL, # Focal plane Y resolution 'FocalPlaneResolutionUnit' => Exif::SHORT, # Focal plane resolution unit #p46 - 'SubjectLocation' => array( Exif::SHORT, 2 ), # Subject location + 'SubjectLocation' => [ Exif::SHORT, 2 ], # Subject location 'ExposureIndex' => Exif::RATIONAL, # Exposure index 'SensingMethod' => Exif::SHORT, # Sensing method #p46 'FileSource' => Exif::UNDEFINED, # File source #p47 @@ -237,22 +237,22 @@ class Exif { 'SubjectDistanceRange' => Exif::SHORT, # Subject distance range #p51 'ImageUniqueID' => Exif::ASCII, # Unique image ID - ), + ], # GPS Attribute Information (p52) - 'GPS' => array( + 'GPS' => [ 'GPSVersion' => Exif::UNDEFINED, # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix 'GPSLatitudeRef' => Exif::ASCII, # North or South Latitude #p52-53 - 'GPSLatitude' => array( Exif::RATIONAL, 3 ), # Latitude + 'GPSLatitude' => [ Exif::RATIONAL, 3 ], # Latitude 'GPSLongitudeRef' => Exif::ASCII, # East or West Longitude #p53 - 'GPSLongitude' => array( Exif::RATIONAL, 3 ), # Longitude + 'GPSLongitude' => [ Exif::RATIONAL, 3 ], # Longitude 'GPSAltitudeRef' => Exif::UNDEFINED, # Altitude reference. Note, the exif standard says this should be an EXIF::Byte, # but php seems to disagree. 'GPSAltitude' => Exif::RATIONAL, # Altitude - 'GPSTimeStamp' => array( Exif::RATIONAL, 3 ), # GPS time (atomic clock) + 'GPSTimeStamp' => [ Exif::RATIONAL, 3 ], # GPS time (atomic clock) 'GPSSatellites' => Exif::ASCII, # Satellites used for measurement 'GPSStatus' => Exif::ASCII, # Receiver status #p54 'GPSMeasureMode' => Exif::ASCII, # Measurement mode #p54-55 @@ -265,9 +265,9 @@ class Exif { 'GPSImgDirection' => Exif::RATIONAL, # Direction of image 'GPSMapDatum' => Exif::ASCII, # Geodetic survey data used 'GPSDestLatitudeRef' => Exif::ASCII, # Reference for latitude of destination #p56 - 'GPSDestLatitude' => array( Exif::RATIONAL, 3 ), # Latitude destination + 'GPSDestLatitude' => [ Exif::RATIONAL, 3 ], # Latitude destination 'GPSDestLongitudeRef' => Exif::ASCII, # Reference for longitude of destination #p57 - 'GPSDestLongitude' => array( Exif::RATIONAL, 3 ), # Longitude of destination + 'GPSDestLongitude' => [ Exif::RATIONAL, 3 ], # Longitude of destination 'GPSDestBearingRef' => Exif::ASCII, # Reference for bearing of destination #p57 'GPSDestBearing' => Exif::RATIONAL, # Bearing of destination 'GPSDestDistanceRef' => Exif::ASCII, # Reference for distance to destination #p57-58 @@ -276,8 +276,8 @@ class Exif { 'GPSAreaInformation' => Exif::UNDEFINED, # Name of GPS area 'GPSDateStamp' => Exif::ASCII, # GPS date 'GPSDifferential' => Exif::SHORT, # GPS differential correction - ), - ); + ], + ]; $this->file = $file; $this->basename = wfBaseName( $this->file ); @@ -306,7 +306,7 @@ class Exif { * when somebody uploads a file called something.jpeg * containing random gibberish. */ - $this->mRawExifData = $data ?: array(); + $this->mRawExifData = $data ?: []; $this->makeFilteredData(); $this->collapseData(); $this->debugFile( __FUNCTION__, false ); @@ -316,7 +316,7 @@ class Exif { * Make $this->mFilteredExifData */ function makeFilteredData() { - $this->mFilteredExifData = array(); + $this->mFilteredExifData = []; foreach ( array_keys( $this->mRawExifData ) as $section ) { if ( !array_key_exists( $section, $this->mExifTags ) ) { @@ -395,7 +395,7 @@ class Exif { if ( isset( $this->mFilteredExifData['ComponentsConfiguration'] ) ) { $val = $this->mFilteredExifData['ComponentsConfiguration']; - $ccVals = array(); + $ccVals = []; $strLen = strlen( $val ); for ( $i = 0; $i < $strLen; $i++ ) { @@ -666,7 +666,7 @@ class Exif { * @return bool */ private function isRational( $in ) { - $m = array(); + $m = []; # Avoid division by zero if ( !is_array( $in ) @@ -711,7 +711,7 @@ class Exif { * @return bool */ private function isSrational( $in ) { - $m = array(); + $m = []; # Avoid division by zero if ( !is_array( $in ) && diff --git a/includes/media/ExifBitmap.php b/includes/media/ExifBitmap.php index 3537cc665f..6a3809b481 100644 --- a/includes/media/ExifBitmap.php +++ b/includes/media/ExifBitmap.php @@ -146,12 +146,12 @@ class ExifBitmapHandler extends BitmapHandler { ) { // So we don't try and display metadata from PagedTiffHandler // for example when using InstantCommons. - return array(); + return []; } $exif = unserialize( $metadata ); if ( !$exif ) { - return array(); + return []; } unset( $exif['MEDIAWIKI_EXIF_VERSION'] ); diff --git a/includes/media/FormatMetadata.php b/includes/media/FormatMetadata.php index 73eeba667a..f392bd1c9e 100644 --- a/includes/media/FormatMetadata.php +++ b/includes/media/FormatMetadata.php @@ -106,7 +106,7 @@ class FormatMetadata extends ContextSource { // This seems ugly to wrap non-array's in an array just to unwrap again, // especially when most of the time it is not an array if ( !is_array( $tags[$tag] ) ) { - $vals = array( $vals ); + $vals = [ $vals ]; } // _type is a special value to say what array type @@ -417,15 +417,15 @@ class FormatMetadata extends ContextSource { break; case 'Flash': - $flashDecode = array( + $flashDecode = [ 'fired' => $val & bindec( '00000001' ), 'return' => ( $val & bindec( '00000110' ) ) >> 1, 'mode' => ( $val & bindec( '00011000' ) ) >> 3, 'function' => ( $val & bindec( '00100000' ) ) >> 5, 'redeye' => ( $val & bindec( '01000000' ) ) >> 6, // 'reserved' => ($val & bindec( '10000000' )) >> 7, - ); - $flashMsgs = array(); + ]; + $flashMsgs = []; # We do not need to handle unknown values since all are used. foreach ( $flashDecode as $subTag => $subValue ) { # We do not need any message for zeroed values. @@ -1092,7 +1092,7 @@ class FormatMetadata extends ContextSource { if ( $this->singleLang ) { return Html::rawElement( 'span', - array( 'lang' => $pLang ), $vals[$pLang] ); + [ 'lang' => $pLang ], $vals[$pLang] ); } } } @@ -1107,7 +1107,7 @@ class FormatMetadata extends ContextSource { $lang, false, $noHtml ); if ( $this->singleLang ) { return Html::rawElement( 'span', - array( 'lang' => $lang ), $item ); + [ 'lang' => $lang ], $item ); } } if ( $defaultItem !== false ) { @@ -1234,9 +1234,9 @@ class FormatMetadata extends ContextSource { * @return mixed A floating point number or whatever we were fed */ private function formatNum( $num, $round = false ) { - $m = array(); + $m = []; if ( is_array( $num ) ) { - $out = array(); + $out = []; foreach ( $num as $number ) { $out[] = $this->formatNum( $number ); } @@ -1270,7 +1270,7 @@ class FormatMetadata extends ContextSource { * @return mixed A floating point number or whatever we were fed */ private function formatFraction( $num ) { - $m = array(); + $m = []; if ( preg_match( '/^(-?\d+)\/(\d+)$/', $num, $m ) ) { $numerator = intval( $m[1] ); $denominator = intval( $m[2] ); @@ -1498,7 +1498,7 @@ class FormatMetadata extends ContextSource { . ''; } if ( isset( $vals['CiEmailWork'] ) ) { - $emails = array(); + $emails = []; // Have to split multiple emails at commas/new lines. $splitEmails = explode( "\n", $vals['CiEmailWork'] ); foreach ( $splitEmails as $e1 ) { @@ -1560,10 +1560,10 @@ class FormatMetadata extends ContextSource { * @since 1.23 */ public static function getVisibleFields() { - $fields = array(); + $fields = []; $lines = explode( "\n", wfMessage( 'metadata-fields' )->inContentLanguage()->text() ); foreach ( $lines as $line ) { - $matches = array(); + $matches = []; if ( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) { $fields[] = $matches[1]; } @@ -1585,7 +1585,7 @@ class FormatMetadata extends ContextSource { // If revision deleted, exit immediately if ( $file->isDeleted( File::DELETED_FILE ) ) { - return array(); + return []; } $cacheKey = wfMemcKey( @@ -1598,7 +1598,7 @@ class FormatMetadata extends ContextSource { $cachedValue = $cache->get( $cacheKey ); if ( $cachedValue - && Hooks::run( 'ValidateExtendedMetadataCache', array( $cachedValue['timestamp'], $file ) ) + && Hooks::run( 'ValidateExtendedMetadataCache', [ $cachedValue['timestamp'], $file ] ) ) { $extendedMetadata = $cachedValue['data']; } else { @@ -1614,7 +1614,7 @@ class FormatMetadata extends ContextSource { // outside fetchExtendedMetadata, but this way we don't need to redo the // computation on a cache hit. $this->sanitizeArrayForAPI( $extendedMetadata ); - $valueToCache = array( 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() ); + $valueToCache = [ 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() ]; $cache->set( $cacheKey, $valueToCache, $maxCacheTime ); } @@ -1636,18 +1636,18 @@ class FormatMetadata extends ContextSource { if ( $file instanceof ForeignAPIFile ) { // In case of error we pretend no metadata - this will get cached. // Might or might not be a good idea. - return $file->getExtendedMetadata() ?: array(); + return $file->getExtendedMetadata() ?: []; } $uploadDate = wfTimestamp( TS_ISO_8601, $file->getTimestamp() ); - $fileMetadata = array( + $fileMetadata = [ // This is modification time, which is close to "upload" time. - 'DateTime' => array( + 'DateTime' => [ 'value' => $uploadDate, 'source' => 'mediawiki-metadata', - ), - ); + ], + ]; $title = $file->getTitle(); if ( $title ) { @@ -1660,10 +1660,10 @@ class FormatMetadata extends ContextSource { $name = $text; } - $fileMetadata['ObjectName'] = array( + $fileMetadata['ObjectName'] = [ 'value' => $name, 'source' => 'mediawiki-metadata', - ); + ]; } return $fileMetadata; @@ -1683,13 +1683,13 @@ class FormatMetadata extends ContextSource { &$maxCacheTime ) { - Hooks::run( 'GetExtendedMetadata', array( + Hooks::run( 'GetExtendedMetadata', [ &$extendedMetadata, $file, $this->getContext(), $this->singleLang, &$maxCacheTime - ) ); + ] ); $visible = array_flip( self::getVisibleFields() ); foreach ( $extendedMetadata as $key => $value ) { @@ -1755,7 +1755,7 @@ class FormatMetadata extends ContextSource { return $value; } elseif ( isset( $value['_type'] ) && $value['_type'] === 'lang' ) { // if this is a multilang array, process fields separately - $newValue = array(); + $newValue = []; foreach ( $value as $k => $v ) { $newValue[$k] = $this->resolveMultivalueValue( $v ); } diff --git a/includes/media/GIF.php b/includes/media/GIF.php index b998d185f9..8ec7298036 100644 --- a/includes/media/GIF.php +++ b/includes/media/GIF.php @@ -65,11 +65,11 @@ class GIFHandler extends BitmapHandler { $meta = $image->getMetadata(); if ( !$meta ) { - return array(); + return []; } $meta = unserialize( $meta ); if ( !isset( $meta['metadata'] ) ) { - return array(); + return []; } unset( $meta['metadata']['_MW_GIF_VERSION'] ); @@ -170,7 +170,7 @@ class GIFHandler extends BitmapHandler { } /* Preserve original image info string, but strip the last char ')' so we can add even more */ - $info = array(); + $info = []; $info[] = $original; if ( $metadata['looped'] ) { diff --git a/includes/media/GIFMetadataExtractor.php b/includes/media/GIFMetadataExtractor.php index f5772de310..65a8fdc84a 100644 --- a/includes/media/GIFMetadataExtractor.php +++ b/includes/media/GIFMetadataExtractor.php @@ -62,7 +62,7 @@ class GIFMetadataExtractor { $duration = 0.0; $isLooped = false; $xmp = ""; - $comment = array(); + $comment = []; if ( !$filename ) { throw new Exception( "No file name specified" ); @@ -251,13 +251,13 @@ class GIFMetadataExtractor { } } - return array( + return [ 'frameCount' => $frameCount, 'looped' => $isLooped, 'duration' => $duration, 'xmp' => $xmp, 'comment' => $comment, - ); + ]; } /** diff --git a/includes/media/IPTC.php b/includes/media/IPTC.php index 9e51b7dd30..f93b1b59a5 100644 --- a/includes/media/IPTC.php +++ b/includes/media/IPTC.php @@ -39,7 +39,7 @@ class IPTC { */ static function parse( $rawData ) { $parsed = iptcparse( $rawData ); - $data = array(); + $data = []; if ( !is_array( $parsed ) ) { return $data; } @@ -52,7 +52,7 @@ class IPTC { // Unknown charset. refuse to parse. // note: There is a different between // unknown and no charset specified. - return array(); + return []; } unset( $parsed['1#090'] ); } @@ -81,7 +81,7 @@ class IPTC { if ( isset( $parsed['2#085'] ) ) { $titles = self::convIPTC( $parsed['2#085'], $c ); } else { - $titles = array(); + $titles = []; } $titleCount = count( $titles ); @@ -176,7 +176,7 @@ class IPTC { // if a version is set for the software. $softwareVersion = self::convIPTC( $parsed['2#070'], $c ); unset( $parsed['2#070'] ); - $data['Software'] = array( array( $software[0], $softwareVersion[0] ) ); + $data['Software'] = [ [ $software[0], $softwareVersion[0] ] ]; } else { $data['Software'] = $software; } @@ -225,7 +225,7 @@ class IPTC { if ( isset( $parsed['2#060'] ) ) { $time = $parsed['2#060']; } else { - $time = array(); + $time = []; } $timestamp = self::timeHelper( $val, $time, $c ); if ( $timestamp ) { @@ -239,7 +239,7 @@ class IPTC { if ( isset( $parsed['2#063'] ) ) { $time = $parsed['2#063']; } else { - $time = array(); + $time = []; } $timestamp = self::timeHelper( $val, $time, $c ); if ( $timestamp ) { @@ -252,7 +252,7 @@ class IPTC { if ( isset( $parsed['2#035'] ) ) { $time = $parsed['2#035']; } else { - $time = array(); + $time = []; } $timestamp = self::timeHelper( $val, $time, $c ); if ( $timestamp ) { @@ -265,7 +265,7 @@ class IPTC { if ( isset( $parsed['2#038'] ) ) { $time = $parsed['2#038']; } else { - $time = array(); + $time = []; } $timestamp = self::timeHelper( $val, $time, $c ); if ( $timestamp ) { diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php index c2870c25ea..a7847bbeec 100644 --- a/includes/media/ImageHandler.php +++ b/includes/media/ImageHandler.php @@ -36,11 +36,11 @@ abstract class ImageHandler extends MediaHandler { } function getParamMap() { - return array( 'img_width' => 'width' ); + return [ 'img_width' => 'width' ]; } function validateParam( $name, $value ) { - if ( in_array( $name, array( 'width', 'height' ) ) ) { + if ( in_array( $name, [ 'width', 'height' ] ) ) { if ( $value <= 0 ) { return false; } else { @@ -68,14 +68,14 @@ abstract class ImageHandler extends MediaHandler { function parseParamString( $str ) { $m = false; if ( preg_match( '/^(\d+)px$/', $str, $m ) ) { - return array( 'width' => $m[1] ); + return [ 'width' => $m[1] ]; } else { return false; } } function getScriptParams( $params ) { - return array( 'width' => $params['width'] ); + return [ 'width' => $params['width'] ]; } /** diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 5069f18045..81722c6d62 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -52,11 +52,11 @@ class JpegMetadataExtractor { $segmentCount = 0; - $segments = array( - 'XMP_ext' => array(), - 'COM' => array(), - 'PSIR' => array(), - ); + $segments = [ + 'XMP_ext' => [], + 'COM' => [], + 'PSIR' => [], + ]; if ( !$filename ) { throw new MWException( "No filename specified for " . __METHOD__ ); diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php index bad1468fe7..95498ba5bd 100644 --- a/includes/media/MediaHandler.php +++ b/includes/media/MediaHandler.php @@ -37,7 +37,7 @@ abstract class MediaHandler { const MAX_ERR_LOG_SIZE = 65535; /** @var MediaHandler[] Instance cache with array of MediaHandler */ - protected static $handlers = array(); + protected static $handlers = []; /** * Get a MediaHandler for a given MIME type from the instance cache @@ -68,7 +68,7 @@ abstract class MediaHandler { * Resets all static caches */ public static function resetCache() { - self::$handlers = array(); + self::$handlers = []; } /** @@ -161,8 +161,8 @@ abstract class MediaHandler { * @return string Version string */ static function getMetadataVersion() { - $version = array( '2' ); // core metadata version - Hooks::run( 'GetMetadataVersion', array( &$version ) ); + $version = [ '2' ]; // core metadata version + Hooks::run( 'GetMetadataVersion', [ &$version ] ); return implode( ';', $version ); } @@ -317,13 +317,13 @@ abstract class MediaHandler { // recognize the MIME type $extensions = $magic->getExtensionsForType( $mime ); if ( $extensions ) { - return array( strtok( $extensions, ' ' ), $mime ); + return [ strtok( $extensions, ' ' ), $mime ]; } } // The extension is correct (true) or the MIME type is unknown to // MediaWiki (null) - return array( $ext, $mime ); + return [ $ext, $mime ]; } /** @@ -333,7 +333,7 @@ abstract class MediaHandler { * @return array */ public function getStreamHeaders( $metadata ) { - return array(); + return []; } /** @@ -437,10 +437,10 @@ abstract class MediaHandler { function getPageDimensions( File $image, $page ) { $gis = $this->getImageSize( $image, $image->getLocalRefPath() ); if ( $gis ) { - return array( + return [ 'width' => $gis[0], 'height' => $gis[1] - ); + ]; } else { return false; } @@ -525,10 +525,10 @@ abstract class MediaHandler { * @return array Array for use displaying metadata. */ function formatMetadataHelper( $metadataArray, $context = false ) { - $result = array( - 'visible' => array(), - 'collapsed' => array() - ); + $result = [ + 'visible' => [], + 'collapsed' => [] + ]; $formatted = FormatMetadata::getFormattedData( $metadataArray, $context ); // Sort fields into visible and collapsed @@ -592,11 +592,11 @@ abstract class MediaHandler { wfDebug( __METHOD__ . ' Unknown metadata name: ' . $id . "\n" ); $name = wfEscapeWikiText( $id ); } - $array[$visibility][] = array( + $array[$visibility][] = [ 'id' => "$type-$id", 'name' => $name, 'value' => $value - ); + ]; } /** @@ -800,7 +800,7 @@ abstract class MediaHandler { * @since 1.23 */ public function getAvailableLanguages( File $file ) { - return array(); + return []; } /** diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index 0d51c47635..9a6547f2aa 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -30,7 +30,7 @@ abstract class MediaTransformOutput { /** @var array Associative array mapping optional supplementary image files * from pixel density (eg 1.5 or 2) to additional URLs. */ - public $responsiveUrls = array(); + public $responsiveUrls = []; /** @var File */ protected $file; @@ -131,7 +131,7 @@ abstract class MediaTransformOutput { * * @return string */ - abstract public function toHtml( $options = array() ); + abstract public function toHtml( $options = [] ); /** * This will be overridden to return true in error classes @@ -182,7 +182,7 @@ abstract class MediaTransformOutput { } elseif ( FileBackend::isStoragePath( $this->path ) ) { $be = $this->file->getRepo()->getBackend(); // The temp file will be process cached by FileBackend - $fsFile = $be->getLocalReference( array( 'src' => $this->path ) ); + $fsFile = $be->getLocalReference( [ 'src' => $this->path ] ); return $fsFile ? $fsFile->getPath() : false; } else { @@ -197,12 +197,12 @@ abstract class MediaTransformOutput { * @return Status * @since 1.27 */ - public function streamFileWithStatus( $headers = array() ) { + public function streamFileWithStatus( $headers = [] ) { if ( !$this->path ) { return Status::newFatal( 'backend-fail-stream', '' ); } elseif ( FileBackend::isStoragePath( $this->path ) ) { $be = $this->file->getRepo()->getBackend(); - return $be->streamFile( array( 'src' => $this->path, 'headers' => $headers ) ); + return $be->streamFile( [ 'src' => $this->path, 'headers' => $headers ] ); } else { // FS-file $success = StreamFile::stream( $this->getLocalCopyPath(), $headers ); return $success ? Status::newGood() : Status::newFatal( 'backend-fail-stream', $this->path ); @@ -216,7 +216,7 @@ abstract class MediaTransformOutput { * @param array $headers Additional HTTP headers to send on success * @return bool Success */ - public function streamFile( $headers = array() ) { + public function streamFile( $headers = [] ) { $this->streamFileWithStatus( $headers )->isOK(); } @@ -240,11 +240,11 @@ abstract class MediaTransformOutput { * @param string|array $params Query parameters to add * @return array */ - public function getDescLinkAttribs( $title = null, $params = array() ) { + public function getDescLinkAttribs( $title = null, $params = [] ) { if ( is_array( $params ) ) { $query = $params; } else { - $query = array(); + $query = []; } if ( $this->page && $this->page !== 1 ) { $query['page'] = $this->page; @@ -257,10 +257,10 @@ abstract class MediaTransformOutput { $query = $params . '&' . wfArrayToCgi( $query ); } - $attribs = array( + $attribs = [ 'href' => $this->file->getTitle()->getLocalURL( $query ), 'class' => 'image', - ); + ]; if ( $title ) { $attribs['title'] = $title; } @@ -287,25 +287,25 @@ class ThumbnailImage extends MediaTransformOutput { * @param string|bool $path Filesystem path to the thumb * @param array $parameters Associative array of parameters */ - function __construct( $file, $url, $path = false, $parameters = array() ) { + function __construct( $file, $url, $path = false, $parameters = [] ) { # Previous parameters: # $file, $url, $width, $height, $path = false, $page = false - $defaults = array( + $defaults = [ 'page' => false, 'lang' => false - ); + ]; if ( is_array( $parameters ) ) { $actualParams = $parameters + $defaults; } else { # Using old format, should convert. Later a warning could be added here. $numArgs = func_num_args(); - $actualParams = array( + $actualParams = [ 'width' => $path, 'height' => $parameters, 'page' => ( $numArgs > 5 ) ? func_get_arg( 5 ) : false - ) + $defaults; + ] + $defaults; $path = ( $numArgs > 4 ) ? func_get_arg( 4 ) : false; } @@ -355,7 +355,7 @@ class ThumbnailImage extends MediaTransformOutput { * @throws MWException * @return string */ - function toHtml( $options = array() ) { + function toHtml( $options = [] ) { if ( count( func_get_args() ) == 2 ) { throw new MWException( __METHOD__ . ' called in the old style' ); } @@ -364,13 +364,13 @@ class ThumbnailImage extends MediaTransformOutput { $query = isset( $options['desc-query'] ) ? $options['desc-query'] : ''; - $attribs = array( + $attribs = [ 'alt' => $alt, 'src' => $this->url, - ); + ]; if ( !empty( $options['custom-url-link'] ) ) { - $linkAttribs = array( 'href' => $options['custom-url-link'] ); + $linkAttribs = [ 'href' => $options['custom-url-link'] ]; if ( !empty( $options['title'] ) ) { $linkAttribs['title'] = $options['title']; } @@ -385,17 +385,17 @@ class ThumbnailImage extends MediaTransformOutput { } elseif ( !empty( $options['custom-title-link'] ) ) { /** @var Title $title */ $title = $options['custom-title-link']; - $linkAttribs = array( + $linkAttribs = [ 'href' => $title->getLinkURL(), 'title' => empty( $options['title'] ) ? $title->getFullText() : $options['title'] - ); + ]; } elseif ( !empty( $options['desc-link'] ) ) { $linkAttribs = $this->getDescLinkAttribs( empty( $options['title'] ) ? null : $options['title'], $query ); } elseif ( !empty( $options['file-link'] ) ) { - $linkAttribs = array( 'href' => $this->file->getURL() ); + $linkAttribs = [ 'href' => $this->file->getURL() ]; } else { $linkAttribs = false; if ( !empty( $options['title'] ) ) { @@ -425,7 +425,7 @@ class ThumbnailImage extends MediaTransformOutput { $attribs['srcset'] = Html::srcSet( $this->responsiveUrls ); } - Hooks::run( 'ThumbnailBeforeProduceHTML', array( $this, &$attribs, &$linkAttribs ) ); + Hooks::run( 'ThumbnailBeforeProduceHTML', [ $this, &$attribs, &$linkAttribs ] ); return $this->linkWrap( $linkAttribs, Xml::element( 'img', $attribs ) ); } @@ -456,7 +456,7 @@ class MediaTransformError extends MediaTransformOutput { $this->path = false; } - function toHtml( $options = array() ) { + function toHtml( $options = [] ) { return "
    width}px; height: {$this->height}px; display:inline-block;\">" . $this->htmlMsg . diff --git a/includes/media/PNG.php b/includes/media/PNG.php index e297fe1b45..f9af101af9 100644 --- a/includes/media/PNG.php +++ b/includes/media/PNG.php @@ -71,11 +71,11 @@ class PNGHandler extends BitmapHandler { $meta = $image->getMetadata(); if ( !$meta ) { - return array(); + return []; } $meta = unserialize( $meta ); if ( !isset( $meta['metadata'] ) ) { - return array(); + return []; } unset( $meta['metadata']['_MW_PNG_VERSION'] ); @@ -155,7 +155,7 @@ class PNGHandler extends BitmapHandler { return $original; } - $info = array(); + $info = []; $info[] = $original; if ( $metadata['loopCount'] == 0 ) { diff --git a/includes/media/PNGMetadataExtractor.php b/includes/media/PNGMetadataExtractor.php index ac92460ea6..7d59767731 100644 --- a/includes/media/PNGMetadataExtractor.php +++ b/includes/media/PNGMetadataExtractor.php @@ -49,7 +49,7 @@ class PNGMetadataExtractor { /* based on list at http://owl.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html#TextualData * and http://www.w3.org/TR/PNG/#11keywords */ - self::$textChunks = array( + self::$textChunks = [ 'xml:com.adobe.xmp' => 'xmp', # Artist is unofficial. Author is the recommended # keyword in the PNG spec. However some people output @@ -72,11 +72,11 @@ class PNGMetadataExtractor { 'label' => 'Label', 'creation time' => 'DateTimeDigitized', /* Other potentially useful things - Document */ - ); + ]; $frameCount = 0; $loopCount = 1; - $text = array(); + $text = []; $duration = 0.0; $bitDepth = 0; $colorType = 'unknown'; @@ -174,7 +174,7 @@ class PNGMetadataExtractor { } elseif ( $chunk_type == "iTXt" ) { // Extracts iTXt chunks, uncompressing if necessary. $buf = self::read( $fh, $chunk_size ); - $items = array(); + $items = []; if ( preg_match( '/^([^\x00]{1,79})\x00(\x00|\x01)\x00([^\x00]*)(.)[^\x00]*\x00(.*)$/Ds', $buf, $items ) @@ -398,14 +398,14 @@ class PNGMetadataExtractor { } } - return array( + return [ 'frameCount' => $frameCount, 'loopCount' => $loopCount, 'duration' => $duration, 'text' => $text, 'bitDepth' => $bitDepth, 'colorType' => $colorType, - ); + ]; } /** diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 1118598f88..d570f30ef2 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -33,12 +33,12 @@ class SvgHandler extends ImageHandler { * to the commonly used exif tags. This allows messages * to be reused, and consistent tag names for {{#formatmetadata:..}} */ - private static $metaConversion = array( + private static $metaConversion = [ 'originalwidth' => 'ImageWidth', 'originalheight' => 'ImageLength', 'description' => 'ImageDescription', 'title' => 'ObjectName', - ); + ]; function isEnabled() { global $wgSVGConverters, $wgSVGConverter; @@ -90,7 +90,7 @@ class SvgHandler extends ImageHandler { */ public function getAvailableLanguages( File $file ) { $metadata = $file->getMetadata(); - $langList = array(); + $langList = []; if ( $metadata ) { $metadata = $this->unpackMetadata( $metadata ); if ( isset( $metadata['translations'] ) ) { @@ -249,7 +249,7 @@ class SvgHandler extends ImageHandler { if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) { // This is a PHP callable $func = $wgSVGConverters[$wgSVGConverter][0]; - $args = array_merge( array( $srcPath, $dstPath, $width, $height, $lang ), + $args = array_merge( [ $srcPath, $dstPath, $width, $height, $lang ], array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) ); if ( !is_callable( $func ) ) { throw new MWException( "$func is not callable" ); @@ -259,16 +259,16 @@ class SvgHandler extends ImageHandler { } else { // External command $cmd = str_replace( - array( '$path/', '$width', '$height', '$input', '$output' ), - array( $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "", + [ '$path/', '$width', '$height', '$input', '$output' ], + [ $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "", intval( $width ), intval( $height ), wfEscapeShellArg( $srcPath ), - wfEscapeShellArg( $dstPath ) ), + wfEscapeShellArg( $dstPath ) ], $wgSVGConverters[$wgSVGConverter] ); - $env = array(); + $env = []; if ( $lang !== false ) { $env['LANG'] = $lang; } @@ -313,15 +313,15 @@ class SvgHandler extends ImageHandler { $metadata = $this->unpackMetadata( $metadata ); if ( isset( $metadata['width'] ) && isset( $metadata['height'] ) ) { - return array( $metadata['width'], $metadata['height'], 'SVG', - "width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" ); + return [ $metadata['width'], $metadata['height'], 'SVG', + "width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" ]; } else { // error - return array( 0, 0, 'SVG', "width=\"0\" height=\"0\"" ); + return [ 0, 0, 'SVG', "width=\"0\" height=\"0\"" ]; } } function getThumbType( $ext, $mime, $params = null ) { - return array( 'png', 'image/png' ); + return [ 'png', 'image/png' ]; } /** @@ -360,15 +360,15 @@ class SvgHandler extends ImageHandler { * @return string Serialised metadata */ function getMetadata( $file, $filename ) { - $metadata = array( 'version' => self::SVG_METADATA_VERSION ); + $metadata = [ 'version' => self::SVG_METADATA_VERSION ]; try { $metadata += SVGMetadataExtractor::getMetadata( $filename ); } catch ( Exception $e ) { // @todo SVG specific exceptions // File not found, broken, etc. - $metadata['error'] = array( + $metadata['error'] = [ 'message' => $e->getMessage(), 'code' => $e->getCode() - ); + ]; wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" ); } @@ -404,7 +404,7 @@ class SvgHandler extends ImageHandler { } protected function visibleMetadataFields() { - $fields = array( 'objectname', 'imagedescription' ); + $fields = [ 'objectname', 'imagedescription' ]; return $fields; } @@ -415,10 +415,10 @@ class SvgHandler extends ImageHandler { * @return array|bool */ function formatMetadata( $file, $context = false ) { - $result = array( - 'visible' => array(), - 'collapsed' => array() - ); + $result = [ + 'visible' => [], + 'collapsed' => [] + ]; $metadata = $file->getMetadata(); if ( !$metadata ) { return false; @@ -463,7 +463,7 @@ class SvgHandler extends ImageHandler { * @return bool Validity */ function validateParam( $name, $value ) { - if ( in_array( $name, array( 'width', 'height' ) ) ) { + if ( in_array( $name, [ 'width', 'height' ] ) ) { // Reject negative heights, widths return ( $value > 0 ); } elseif ( $name == 'lang' ) { @@ -501,16 +501,16 @@ class SvgHandler extends ImageHandler { function parseParamString( $str ) { $m = false; if ( preg_match( '/^lang([a-z]+(?:-[a-z]+)*)-(\d+)px$/', $str, $m ) ) { - return array( 'width' => array_pop( $m ), 'lang' => $m[1] ); + return [ 'width' => array_pop( $m ), 'lang' => $m[1] ]; } elseif ( preg_match( '/^(\d+)px$/', $str, $m ) ) { - return array( 'width' => $m[1], 'lang' => 'en' ); + return [ 'width' => $m[1], 'lang' => 'en' ]; } else { return false; } } function getParamMap() { - return array( 'img_lang' => 'lang', 'img_width' => 'width' ); + return [ 'img_lang' => 'lang', 'img_width' => 'width' ]; } /** @@ -518,7 +518,7 @@ class SvgHandler extends ImageHandler { * @return array */ function getScriptParams( $params ) { - $scriptParams = array( 'width' => $params['width'] ); + $scriptParams = [ 'width' => $params['width'] ]; if ( isset( $params['lang'] ) ) { $scriptParams['lang'] = $params['lang']; } @@ -529,13 +529,13 @@ class SvgHandler extends ImageHandler { public function getCommonMetaArray( File $file ) { $metadata = $file->getMetadata(); if ( !$metadata ) { - return array(); + return []; } $metadata = $this->unpackMetadata( $metadata ); if ( !$metadata || isset( $metadata['error'] ) ) { - return array(); + return []; } - $stdMetadata = array(); + $stdMetadata = []; foreach ( $metadata as $name => $value ) { $tag = strtolower( $name ); if ( $tag === 'originalwidth' || $tag === 'originalheight' ) { diff --git a/includes/media/SVGMetadataExtractor.php b/includes/media/SVGMetadataExtractor.php index 1ec2f814d6..f777230e39 100644 --- a/includes/media/SVGMetadataExtractor.php +++ b/includes/media/SVGMetadataExtractor.php @@ -53,9 +53,9 @@ class SVGReader { private $mDebug = false; /** @var array */ - private $metadata = array(); - private $languages = array(); - private $languagePrefixes = array(); + private $metadata = []; + private $languages = []; + private $languagePrefixes = []; /** * Constructor @@ -376,7 +376,7 @@ class SVGReader { * @return float Length in pixels */ static function scaleSVGUnit( $length, $viewportSize = 512 ) { - static $unitLength = array( + static $unitLength = [ 'px' => 1.0, 'pt' => 1.25, 'pc' => 15.0, @@ -386,8 +386,8 @@ class SVGReader { 'em' => 16.0, // fake it? 'ex' => 12.0, // fake it? '' => 1.0, // "User units" pixels by default - ); - $matches = array(); + ]; + $matches = []; if ( preg_match( '/^\s*(\d+(?:\.\d+)?)(em|ex|px|pt|pc|cm|mm|in|%|)\s*$/', $length, $matches ) ) { $length = floatval( $matches[1] ); $unit = $matches[2]; diff --git a/includes/media/TransformationalImageHandler.php b/includes/media/TransformationalImageHandler.php index 597ac26577..f6483a15fb 100644 --- a/includes/media/TransformationalImageHandler.php +++ b/includes/media/TransformationalImageHandler.php @@ -86,7 +86,7 @@ abstract class TransformationalImageHandler extends ImageHandler { $height = $params['physicalHeight']; } - return array( $width, $height ); + return [ $width, $height ]; } /** @@ -108,7 +108,7 @@ abstract class TransformationalImageHandler extends ImageHandler { } # Create a parameter array to pass to the scaler - $scalerParams = array( + $scalerParams = [ # The size to which the image will be resized 'physicalWidth' => $params['physicalWidth'], 'physicalHeight' => $params['physicalHeight'], @@ -127,7 +127,7 @@ abstract class TransformationalImageHandler extends ImageHandler { 'dstPath' => $dstPath, 'dstUrl' => $dstUrl, 'interlace' => isset( $params['interlace'] ) ? $params['interlace'] : false, - ); + ]; if ( isset( $params['quality'] ) && $params['quality'] === 'low' ) { $scalerParams['quality'] = 30; @@ -175,10 +175,10 @@ abstract class TransformationalImageHandler extends ImageHandler { if ( $flags & self::TRANSFORM_LATER ) { wfDebug( __METHOD__ . ": Transforming later per flags.\n" ); - $newParams = array( + $newParams = [ 'width' => $scalerParams['clientWidth'], 'height' => $scalerParams['clientHeight'] - ); + ]; if ( isset( $params['quality'] ) ) { $newParams['quality'] = $params['quality']; } @@ -223,7 +223,7 @@ abstract class TransformationalImageHandler extends ImageHandler { # Try a hook. Called "Bitmap" for historical reasons. /** @var $mto MediaTransformOutput */ $mto = null; - Hooks::run( 'BitmapHandlerTransform', array( $this, $image, &$scalerParams, &$mto ) ); + Hooks::run( 'BitmapHandlerTransform', [ $this, $image, &$scalerParams, &$mto ] ); if ( !is_null( $mto ) ) { wfDebug( __METHOD__ . ": Hook to BitmapHandlerTransform created an mto\n" ); $scaler = 'hookaborted'; @@ -271,10 +271,10 @@ abstract class TransformationalImageHandler extends ImageHandler { } elseif ( $mto ) { return $mto; } else { - $newParams = array( + $newParams = [ 'width' => $scalerParams['clientWidth'], 'height' => $scalerParams['clientHeight'] - ); + ]; if ( isset( $params['quality'] ) ) { $newParams['quality'] = $params['quality']; } @@ -330,10 +330,10 @@ abstract class TransformationalImageHandler extends ImageHandler { * @todo FIXME: No rotation support */ protected function getClientScalingThumbnailImage( $image, $scalerParams ) { - $params = array( + $params = [ 'width' => $scalerParams['clientWidth'], 'height' => $scalerParams['clientHeight'] - ); + ]; return new ThumbnailImage( $image, $image->getURL(), null, $params ); } @@ -598,7 +598,7 @@ abstract class TransformationalImageHandler extends ImageHandler { $checkImageAreaHookResult = null; Hooks::run( 'BitmapHandlerCheckImageArea', - array( $file, &$params, &$checkImageAreaHookResult ) + [ $file, &$params, &$checkImageAreaHookResult ] ); if ( !is_null( $checkImageAreaHookResult ) ) { diff --git a/includes/media/WebP.php b/includes/media/WebP.php index f894618a76..8fda7511b7 100644 --- a/includes/media/WebP.php +++ b/includes/media/WebP.php @@ -122,10 +122,10 @@ class WebPHandler extends BitmapHandler { * 'compression' can be 'lossy', 'lossless', 'animated' or 'unknown' */ public static function extractMetadataFromChunks( $chunks, $filename ) { - $vp8Info = array(); + $vp8Info = []; foreach ( $chunks as $chunk ) { - if ( !in_array( $chunk['fourCC'], array( 'VP8 ', 'VP8L', 'VP8X' ) ) ) { + if ( !in_array( $chunk['fourCC'], [ 'VP8 ', 'VP8L', 'VP8X' ] ) ) { // Not a chunk containing interesting metadata continue; } @@ -165,16 +165,16 @@ class WebPHandler extends BitmapHandler { if ( $syncCode != "\x9D\x01\x2A" ) { wfDebugLog( 'WebP', __METHOD__ . ': Invalid sync code: ' . bin2hex( $syncCode ) . "\n" ); - return array(); + return []; } // Bytes 14-17 are image size $imageSize = unpack( 'v2', substr( $header, 14, 4 ) ); // Image sizes are 14 bit, 2 MSB are scaling parameters which are ignored here - return array( + return [ 'compression' => 'lossy', 'width' => $imageSize[1] & 0x3FFF, 'height' => $imageSize[2] & 0x3FFF - ); + ]; } /** @@ -189,17 +189,17 @@ class WebPHandler extends BitmapHandler { if ( $header{8} != "\x2F" ) { wfDebugLog( 'WebP', __METHOD__ . ': Invalid signature: ' . bin2hex( $header{8} ) . "\n" ); - return array(); + return []; } // Bytes 9-12 contain the image size // Bits 0-13 are width-1; bits 15-27 are height-1 $imageSize = unpack( 'C4', substr( $header, 9, 4 ) ); - return array( + return [ 'compression' => 'lossless', 'width' => ( $imageSize[1] | ( ( $imageSize[2] & 0x3F ) << 8 ) ) + 1, 'height' => ( ( ( $imageSize[2] & 0xC0 ) >> 6 ) | ( $imageSize[3] << 2 ) | ( ( $imageSize[4] & 0x03 ) << 10 ) ) + 1 - ); + ]; } /** @@ -217,13 +217,13 @@ class WebPHandler extends BitmapHandler { $width = unpack( 'V', substr( $header, 12, 3 ) . "\x00" ); $height = unpack( 'V', substr( $header, 15, 3 ) . "\x00" ); - return array( + return [ 'compression' => 'unknown', 'animated' => ( $flags[1] & self::VP8X_ANIM ) == self::VP8X_ANIM, 'transparency' => ( $flags[1] & self::VP8X_ALPHA ) == self::VP8X_ALPHA, 'width' => ( $width[1] & 0xFFFFFF ) + 1, 'height' => ( $height[1] & 0xFFFFFF ) + 1 - ); + ]; } public function getImageSize( $file, $path, $metadata = false ) { @@ -241,7 +241,7 @@ class WebPHandler extends BitmapHandler { if ( $metadata == false ) { return false; } - return array( $metadata['width'], $metadata['height'] ); + return [ $metadata['width'], $metadata['height'] ]; } /** @@ -292,7 +292,7 @@ class WebPHandler extends BitmapHandler { * @return array */ public function getThumbType( $ext, $mime, $params = null ) { - return array( 'png', 'image/png' ); + return [ 'png', 'image/png' ]; } /** diff --git a/includes/media/XCF.php b/includes/media/XCF.php index 41e1d54b6b..05c38472c6 100644 --- a/includes/media/XCF.php +++ b/includes/media/XCF.php @@ -50,7 +50,7 @@ class XCFHandler extends BitmapHandler { * @return array */ function getThumbType( $ext, $mime, $params = null ) { - return array( 'png', 'image/png' ); + return [ 'png', 'image/png' ]; } /** @@ -68,7 +68,7 @@ class XCFHandler extends BitmapHandler { # Forge a return array containing metadata information just like getimagesize() # See PHP documentation at: http://www.php.net/getimagesize - $metadata = array(); + $metadata = []; $metadata[0] = $header['width']; $metadata[1] = $header['height']; $metadata[2] = null; # IMAGETYPE constant, none exist for XCF. @@ -162,7 +162,7 @@ class XCFHandler extends BitmapHandler { */ public function getMetadata( $file, $filename ) { $header = self::getXCFMetadata( $filename ); - $metadata = array(); + $metadata = []; if ( $header ) { // Try to be consistent with the names used by PNG files. // Unclear from base media type if it has an alpha layer, diff --git a/includes/media/XMP.php b/includes/media/XMP.php index 6d1970078c..70f67b7858 100644 --- a/includes/media/XMP.php +++ b/includes/media/XMP.php @@ -55,7 +55,7 @@ class XMPReader implements LoggerAwareInterface { protected $items; /** @var array Array to hold the current element (and previous element, and so on) */ - private $curItem = array(); + private $curItem = []; /** @var bool|string The structure name when processing nested structures. */ private $ancestorStruct = false; @@ -64,10 +64,10 @@ class XMPReader implements LoggerAwareInterface { private $charContent = false; /** @var array Stores the state the xmpreader is in (see MODE_FOO constants) */ - private $mode = array(); + private $mode = []; /** @var array Array to hold results */ - private $results = array(); + private $results = []; /** @var bool If we're doing a seq or bag. */ private $processingArray = false; @@ -182,10 +182,10 @@ class XMPReader implements LoggerAwareInterface { xml_parser_set_option( $this->xmlParser, XML_OPTION_SKIP_WHITE, 1 ); xml_set_element_handler( $this->xmlParser, - array( $this, 'startElement' ), - array( $this, 'endElement' ) ); + [ $this, 'startElement' ], + [ $this, 'endElement' ] ); - xml_set_character_data_handler( $this->xmlParser, array( $this, 'char' ) ); + xml_set_character_data_handler( $this->xmlParser, [ $this, 'char' ] ); $this->parsable = self::PARSABLE_UNKNOWN; $this->xmlParsableBuffer = ''; @@ -308,7 +308,7 @@ class XMPReader implements LoggerAwareInterface { // detect encoding by looking for BOM which is supposed to be in processing instruction. // see page 12 of http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart3.pdf if ( !$this->charset ) { - $bom = array(); + $bom = []; if ( preg_match( '/\xEF\xBB\xBF|\xFE\xFF|\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFF\xFE/', $content, $bom ) ) { @@ -376,7 +376,7 @@ class XMPReader implements LoggerAwareInterface { $this->logger->warning( '{method} : Error reading XMP content: {error} ' . '(line: {line} column: {column} byte offset: {offset})', - array( + [ 'method' => __METHOD__, 'error_code' => $code, 'error' => $error, @@ -384,21 +384,21 @@ class XMPReader implements LoggerAwareInterface { 'column' => $col, 'offset' => $offset, 'content' => $content, - ) ); - $this->results = array(); // blank if error. + ] ); + $this->results = []; // blank if error. $this->destroyXMLParser(); return false; } } catch ( Exception $e ) { $this->logger->warning( '{method} Exception caught while parsing: ' . $e->getMessage(), - array( + [ 'method' => __METHOD__, 'exception' => $e, 'content' => $content, - ) + ] ); - $this->results = array(); + $this->results = []; return false; } if ( $allOfIt ) { @@ -548,7 +548,7 @@ class XMPReader implements LoggerAwareInterface { /** @noinspection PhpUnusedLocalVariableInspection */ $reset = new ScopedCallback( 'libxml_disable_entity_loader', - array( $oldDisable ) + [ $oldDisable ] ); $reader->setParserProperty( XMLReader::SUBST_ENTITIES, false ); @@ -667,7 +667,7 @@ class XMPReader implements LoggerAwareInterface { $validate = $info['validate']; } else { $validator = new XMPValidate( $this->logger ); - $validate = array( $validator, $info['validate'] ); + $validate = [ $validator, $info['validate'] ]; } if ( !isset( $this->results['xmp-' . $info['map_group']][$finalName] ) ) { @@ -675,7 +675,7 @@ class XMPReader implements LoggerAwareInterface { $this->logger->debug( __METHOD__ . " <$ns:$tag> has no valid members." ); } elseif ( is_callable( $validate ) ) { $val =& $this->results['xmp-' . $info['map_group']][$finalName]; - call_user_func_array( $validate, array( $info, &$val, false ) ); + call_user_func_array( $validate, [ $info, &$val, false ] ); if ( is_null( $val ) ) { // the idea being the validation function will unset the variable if // its invalid. @@ -1345,11 +1345,11 @@ class XMPReader implements LoggerAwareInterface { $validate = $info['validate']; } else { $validator = new XMPValidate( $this->logger ); - $validate = array( $validator, $info['validate'] ); + $validate = [ $validator, $info['validate'] ]; } if ( is_callable( $validate ) ) { - call_user_func_array( $validate, array( $info, &$val, true ) ); + call_user_func_array( $validate, [ $info, &$val, true ] ); // the reasoning behind using &$val instead of using the return value // is to be consistent between here and validating structures. if ( is_null( $val ) ) { diff --git a/includes/media/XMPInfo.php b/includes/media/XMPInfo.php index 6fc2343869..052be33a4b 100644 --- a/includes/media/XMPInfo.php +++ b/includes/media/XMPInfo.php @@ -60,372 +60,372 @@ class XMPInfo { * * Currently this just has a bunch of EXIF values as this class is only half-done. */ - static private $items = array( - 'http://ns.adobe.com/exif/1.0/' => array( - 'ApertureValue' => array( + static private $items = [ + 'http://ns.adobe.com/exif/1.0/' => [ + 'ApertureValue' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'BrightnessValue' => array( + ], + 'BrightnessValue' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'CompressedBitsPerPixel' => array( + ], + 'CompressedBitsPerPixel' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'DigitalZoomRatio' => array( + ], + 'DigitalZoomRatio' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'ExposureBiasValue' => array( + ], + 'ExposureBiasValue' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'ExposureIndex' => array( + ], + 'ExposureIndex' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'ExposureTime' => array( + ], + 'ExposureTime' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'FlashEnergy' => array( + ], + 'FlashEnergy' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational', - ), - 'FNumber' => array( + ], + 'FNumber' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'FocalLength' => array( + ], + 'FocalLength' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'FocalPlaneXResolution' => array( + ], + 'FocalPlaneXResolution' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'FocalPlaneYResolution' => array( + ], + 'FocalPlaneYResolution' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'GPSAltitude' => array( + ], + 'GPSAltitude' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational', - ), - 'GPSDestBearing' => array( + ], + 'GPSDestBearing' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'GPSDestDistance' => array( + ], + 'GPSDestDistance' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'GPSDOP' => array( + ], + 'GPSDOP' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'GPSImgDirection' => array( + ], + 'GPSImgDirection' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'GPSSpeed' => array( + ], + 'GPSSpeed' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'GPSTrack' => array( + ], + 'GPSTrack' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'MaxApertureValue' => array( + ], + 'MaxApertureValue' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'ShutterSpeedValue' => array( + ], + 'ShutterSpeedValue' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), - 'SubjectDistance' => array( + ], + 'SubjectDistance' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational' - ), + ], /* Flash */ - 'Flash' => array( + 'Flash' => [ 'mode' => XMPReader::MODE_STRUCT, - 'children' => array( + 'children' => [ 'Fired' => true, 'Function' => true, 'Mode' => true, 'RedEyeMode' => true, 'Return' => true, - ), + ], 'validate' => 'validateFlash', 'map_group' => 'exif', - ), - 'Fired' => array( + ], + 'Fired' => [ 'map_group' => 'exif', 'validate' => 'validateBoolean', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'Function' => array( + ], + 'Function' => [ 'map_group' => 'exif', 'validate' => 'validateBoolean', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'Mode' => array( + ], + 'Mode' => [ 'map_group' => 'exif', 'validate' => 'validateClosed', 'mode' => XMPReader::MODE_SIMPLE, - 'choices' => array( '0' => true, '1' => true, - '2' => true, '3' => true ), + 'choices' => [ '0' => true, '1' => true, + '2' => true, '3' => true ], 'structPart' => true, - ), - 'Return' => array( + ], + 'Return' => [ 'map_group' => 'exif', 'validate' => 'validateClosed', 'mode' => XMPReader::MODE_SIMPLE, - 'choices' => array( '0' => true, - '2' => true, '3' => true ), + 'choices' => [ '0' => true, + '2' => true, '3' => true ], 'structPart' => true, - ), - 'RedEyeMode' => array( + ], + 'RedEyeMode' => [ 'map_group' => 'exif', 'validate' => 'validateBoolean', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), + ], /* End Flash */ - 'ISOSpeedRatings' => array( + 'ISOSpeedRatings' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateInteger' - ), + ], /* end rational things */ - 'ColorSpace' => array( + 'ColorSpace' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '1' => true, '65535' => true ), - ), - 'ComponentsConfiguration' => array( + 'choices' => [ '1' => true, '65535' => true ], + ], + 'ComponentsConfiguration' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateClosed', - 'choices' => array( '1' => true, '2' => true, '3' => true, '4' => true, - '5' => true, '6' => true ) - ), - 'Contrast' => array( + 'choices' => [ '1' => true, '2' => true, '3' => true, '4' => true, + '5' => true, '6' => true ] + ], + 'Contrast' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '0' => true, '1' => true, '2' => true ) - ), - 'CustomRendered' => array( + 'choices' => [ '0' => true, '1' => true, '2' => true ] + ], + 'CustomRendered' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '0' => true, '1' => true ) - ), - 'DateTimeOriginal' => array( + 'choices' => [ '0' => true, '1' => true ] + ], + 'DateTimeOriginal' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateDate', - ), - 'DateTimeDigitized' => array( /* xmp:CreateDate */ + ], + 'DateTimeDigitized' => [ /* xmp:CreateDate */ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateDate', - ), + ], /* todo: there might be interesting information in * exif:DeviceSettingDescription, but need to find an * example */ - 'ExifVersion' => array( + 'ExifVersion' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'ExposureMode' => array( + ], + 'ExposureMode' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 2, - ), - 'ExposureProgram' => array( + ], + 'ExposureProgram' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 8, - ), - 'FileSource' => array( + ], + 'FileSource' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '3' => true ) - ), - 'FlashpixVersion' => array( + 'choices' => [ '3' => true ] + ], + 'FlashpixVersion' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'FocalLengthIn35mmFilm' => array( + ], + 'FocalLengthIn35mmFilm' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', - ), - 'FocalPlaneResolutionUnit' => array( + ], + 'FocalPlaneResolutionUnit' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '2' => true, '3' => true ), - ), - 'GainControl' => array( + 'choices' => [ '2' => true, '3' => true ], + ], + 'GainControl' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 4, - ), + ], /* this value is post-processed out later */ - 'GPSAltitudeRef' => array( + 'GPSAltitudeRef' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '0' => true, '1' => true ), - ), - 'GPSAreaInformation' => array( + 'choices' => [ '0' => true, '1' => true ], + ], + 'GPSAreaInformation' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'GPSDestBearingRef' => array( + ], + 'GPSDestBearingRef' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( 'T' => true, 'M' => true ), - ), - 'GPSDestDistanceRef' => array( + 'choices' => [ 'T' => true, 'M' => true ], + ], + 'GPSDestDistanceRef' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( 'K' => true, 'M' => true, - 'N' => true ), - ), - 'GPSDestLatitude' => array( + 'choices' => [ 'K' => true, 'M' => true, + 'N' => true ], + ], + 'GPSDestLatitude' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateGPS', - ), - 'GPSDestLongitude' => array( + ], + 'GPSDestLongitude' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateGPS', - ), - 'GPSDifferential' => array( + ], + 'GPSDifferential' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '0' => true, '1' => true ), - ), - 'GPSImgDirectionRef' => array( + 'choices' => [ '0' => true, '1' => true ], + ], + 'GPSImgDirectionRef' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( 'T' => true, 'M' => true ), - ), - 'GPSLatitude' => array( + 'choices' => [ 'T' => true, 'M' => true ], + ], + 'GPSLatitude' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateGPS', - ), - 'GPSLongitude' => array( + ], + 'GPSLongitude' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateGPS', - ), - 'GPSMapDatum' => array( + ], + 'GPSMapDatum' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'GPSMeasureMode' => array( + ], + 'GPSMeasureMode' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '2' => true, '3' => true ) - ), - 'GPSProcessingMethod' => array( + 'choices' => [ '2' => true, '3' => true ] + ], + 'GPSProcessingMethod' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'GPSSatellites' => array( + ], + 'GPSSatellites' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'GPSSpeedRef' => array( + ], + 'GPSSpeedRef' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( 'K' => true, 'M' => true, - 'N' => true ), - ), - 'GPSStatus' => array( + 'choices' => [ 'K' => true, 'M' => true, + 'N' => true ], + ], + 'GPSStatus' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( 'A' => true, 'V' => true ) - ), - 'GPSTimeStamp' => array( + 'choices' => [ 'A' => true, 'V' => true ] + ], + 'GPSTimeStamp' => [ 'map_group' => 'exif', // Note: in exif, GPSDateStamp does not include // the time, where here it does. 'map_name' => 'GPSDateStamp', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateDate', - ), - 'GPSTrackRef' => array( + ], + 'GPSTrackRef' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( 'T' => true, 'M' => true ) - ), - 'GPSVersionID' => array( + 'choices' => [ 'T' => true, 'M' => true ] + ], + 'GPSVersionID' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'ImageUniqueID' => array( + ], + 'ImageUniqueID' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'LightSource' => array( + ], + 'LightSource' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', /* can't use a range, as it skips... */ - 'choices' => array( '0' => true, '1' => true, + 'choices' => [ '0' => true, '1' => true, '2' => true, '3' => true, '4' => true, '9' => true, '10' => true, '11' => true, '12' => true, '13' => true, @@ -435,146 +435,146 @@ class XMPInfo { '21' => true, '22' => true, '23' => true, '24' => true, '255' => true, - ), - ), - 'MeteringMode' => array( + ], + ], + 'MeteringMode' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 6, - 'choices' => array( '255' => true ), - ), + 'choices' => [ '255' => true ], + ], /* Pixel(X|Y)Dimension are rather useless, but for * completeness since we do it with exif. */ - 'PixelXDimension' => array( + 'PixelXDimension' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', - ), - 'PixelYDimension' => array( + ], + 'PixelYDimension' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', - ), - 'Saturation' => array( + ], + 'Saturation' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 2, - ), - 'SceneCaptureType' => array( + ], + 'SceneCaptureType' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 3, - ), - 'SceneType' => array( + ], + 'SceneType' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '1' => true ), - ), + 'choices' => [ '1' => true ], + ], // Note, 6 is not valid SensingMethod. - 'SensingMethod' => array( + 'SensingMethod' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 1, 'rangeHigh' => 5, - 'choices' => array( '7' => true, 8 => true ), - ), - 'Sharpness' => array( + 'choices' => [ '7' => true, 8 => true ], + ], + 'Sharpness' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 2, - ), - 'SpectralSensitivity' => array( + ], + 'SpectralSensitivity' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), + ], // This tag should perhaps be displayed to user better. - 'SubjectArea' => array( + 'SubjectArea' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateInteger', - ), - 'SubjectDistanceRange' => array( + ], + 'SubjectDistanceRange' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', 'rangeLow' => 0, 'rangeHigh' => 3, - ), - 'SubjectLocation' => array( + ], + 'SubjectLocation' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateInteger', - ), - 'UserComment' => array( + ], + 'UserComment' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_LANG, - ), - 'WhiteBalance' => array( + ], + 'WhiteBalance' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '0' => true, '1' => true ) - ), - ), - 'http://ns.adobe.com/tiff/1.0/' => array( - 'Artist' => array( + 'choices' => [ '0' => true, '1' => true ] + ], + ], + 'http://ns.adobe.com/tiff/1.0/' => [ + 'Artist' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'BitsPerSample' => array( + ], + 'BitsPerSample' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateInteger', - ), - 'Compression' => array( + ], + 'Compression' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '1' => true, '6' => true ), - ), + 'choices' => [ '1' => true, '6' => true ], + ], /* this prop should not be used in XMP. dc:rights is the correct prop */ - 'Copyright' => array( + 'Copyright' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_LANG, - ), - 'DateTime' => array( /* proper prop is xmp:ModifyDate */ + ], + 'DateTime' => [ /* proper prop is xmp:ModifyDate */ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateDate', - ), - 'ImageDescription' => array( /* proper one is dc:description */ + ], + 'ImageDescription' => [ /* proper one is dc:description */ 'map_group' => 'exif', 'mode' => XMPReader::MODE_LANG, - ), - 'ImageLength' => array( + ], + 'ImageLength' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', - ), - 'ImageWidth' => array( + ], + 'ImageWidth' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', - ), - 'Make' => array( + ], + 'Make' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'Model' => array( + ], + 'Model' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), + ], /**** Do not extract this property * It interferes with auto exif rotation. * 'Orientation' => array( @@ -585,70 +585,70 @@ class XMPInfo { * '6' => true, '7' => true, '8' => true ), *), ******/ - 'PhotometricInterpretation' => array( + 'PhotometricInterpretation' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '2' => true, '6' => true ), - ), - 'PlanerConfiguration' => array( + 'choices' => [ '2' => true, '6' => true ], + ], + 'PlanerConfiguration' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '1' => true, '2' => true ), - ), - 'PrimaryChromaticities' => array( + 'choices' => [ '1' => true, '2' => true ], + ], + 'PrimaryChromaticities' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateRational', - ), - 'ReferenceBlackWhite' => array( + ], + 'ReferenceBlackWhite' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateRational', - ), - 'ResolutionUnit' => array( + ], + 'ResolutionUnit' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '2' => true, '3' => true ), - ), - 'SamplesPerPixel' => array( + 'choices' => [ '2' => true, '3' => true ], + ], + 'SamplesPerPixel' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', - ), - 'Software' => array( /* see xmp:CreatorTool */ + ], + 'Software' => [ /* see xmp:CreatorTool */ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), + ], /* ignore TransferFunction */ - 'WhitePoint' => array( + 'WhitePoint' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateRational', - ), - 'XResolution' => array( + ], + 'XResolution' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational', - ), - 'YResolution' => array( + ], + 'YResolution' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRational', - ), - 'YCbCrCoefficients' => array( + ], + 'YCbCrCoefficients' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateRational', - ), - 'YCbCrPositioning' => array( + ], + 'YCbCrPositioning' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateClosed', - 'choices' => array( '1' => true, '2' => true ), - ), + 'choices' => [ '1' => true, '2' => true ], + ], /******** * Disable extracting this property (bug 31944) * Several files have a string instead of a Seq @@ -666,49 +666,49 @@ class XMPInfo { * 'choices' => array( '1' => true, '2' => true ), * ), */ - ), - 'http://ns.adobe.com/exif/1.0/aux/' => array( - 'Lens' => array( + ], + 'http://ns.adobe.com/exif/1.0/aux/' => [ + 'Lens' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'SerialNumber' => array( + ], + 'SerialNumber' => [ 'map_group' => 'exif', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'OwnerName' => array( + ], + 'OwnerName' => [ 'map_group' => 'exif', 'map_name' => 'CameraOwnerName', 'mode' => XMPReader::MODE_SIMPLE, - ), - ), - 'http://purl.org/dc/elements/1.1/' => array( - 'title' => array( + ], + ], + 'http://purl.org/dc/elements/1.1/' => [ + 'title' => [ 'map_group' => 'general', 'map_name' => 'ObjectName', 'mode' => XMPReader::MODE_LANG - ), - 'description' => array( + ], + 'description' => [ 'map_group' => 'general', 'map_name' => 'ImageDescription', 'mode' => XMPReader::MODE_LANG - ), - 'contributor' => array( + ], + 'contributor' => [ 'map_group' => 'general', 'map_name' => 'dc-contributor', 'mode' => XMPReader::MODE_BAG - ), - 'coverage' => array( + ], + 'coverage' => [ 'map_group' => 'general', 'map_name' => 'dc-coverage', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'creator' => array( + ], + 'creator' => [ 'map_group' => 'general', 'map_name' => 'Artist', // map with exif Artist, iptc byline (2:80) 'mode' => XMPReader::MODE_SEQ, - ), - 'date' => array( + ], + 'date' => [ 'map_group' => 'general', // Note, not mapped with other date properties, as this type of date is // non-specific: "A point or period of time associated with an event in @@ -716,287 +716,287 @@ class XMPInfo { 'map_name' => 'dc-date', 'mode' => XMPReader::MODE_SEQ, 'validate' => 'validateDate', - ), + ], /* Do not extract dc:format, as we've got better ways to determine MIME type */ - 'identifier' => array( + 'identifier' => [ 'map_group' => 'deprecated', 'map_name' => 'Identifier', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'language' => array( + ], + 'language' => [ 'map_group' => 'general', 'map_name' => 'LanguageCode', /* mapped with iptc 2:135 */ 'mode' => XMPReader::MODE_BAG, 'validate' => 'validateLangCode', - ), - 'publisher' => array( + ], + 'publisher' => [ 'map_group' => 'general', 'map_name' => 'dc-publisher', 'mode' => XMPReader::MODE_BAG, - ), + ], // for related images/resources - 'relation' => array( + 'relation' => [ 'map_group' => 'general', 'map_name' => 'dc-relation', 'mode' => XMPReader::MODE_BAG, - ), - 'rights' => array( + ], + 'rights' => [ 'map_group' => 'general', 'map_name' => 'Copyright', 'mode' => XMPReader::MODE_LANG, - ), + ], // Note: source is not mapped with iptc source, since iptc // source describes the source of the image in terms of a person // who provided the image, where this is to describe an image that the // current one is based on. - 'source' => array( + 'source' => [ 'map_group' => 'general', 'map_name' => 'dc-source', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'subject' => array( + ], + 'subject' => [ 'map_group' => 'general', 'map_name' => 'Keywords', /* maps to iptc 2:25 */ 'mode' => XMPReader::MODE_BAG, - ), - 'type' => array( + ], + 'type' => [ 'map_group' => 'general', 'map_name' => 'dc-type', 'mode' => XMPReader::MODE_BAG, - ), - ), - 'http://ns.adobe.com/xap/1.0/' => array( - 'CreateDate' => array( + ], + ], + 'http://ns.adobe.com/xap/1.0/' => [ + 'CreateDate' => [ 'map_group' => 'general', 'map_name' => 'DateTimeDigitized', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateDate', - ), - 'CreatorTool' => array( + ], + 'CreatorTool' => [ 'map_group' => 'general', 'map_name' => 'Software', 'mode' => XMPReader::MODE_SIMPLE - ), - 'Identifier' => array( + ], + 'Identifier' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_BAG, - ), - 'Label' => array( + ], + 'Label' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'ModifyDate' => array( + ], + 'ModifyDate' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'DateTime', 'validate' => 'validateDate', - ), - 'MetadataDate' => array( + ], + 'MetadataDate' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, // map_name to be consistent with other date names. 'map_name' => 'DateTimeMetadata', 'validate' => 'validateDate', - ), - 'Nickname' => array( + ], + 'Nickname' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'Rating' => array( + ], + 'Rating' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateRating', - ), - ), - 'http://ns.adobe.com/xap/1.0/rights/' => array( - 'Certificate' => array( + ], + ], + 'http://ns.adobe.com/xap/1.0/rights/' => [ + 'Certificate' => [ 'map_group' => 'general', 'map_name' => 'RightsCertificate', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'Marked' => array( + ], + 'Marked' => [ 'map_group' => 'general', 'map_name' => 'Copyrighted', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateBoolean', - ), - 'Owner' => array( + ], + 'Owner' => [ 'map_group' => 'general', 'map_name' => 'CopyrightOwner', 'mode' => XMPReader::MODE_BAG, - ), + ], // this seems similar to dc:rights. - 'UsageTerms' => array( + 'UsageTerms' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_LANG, - ), - 'WebStatement' => array( + ], + 'WebStatement' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - ), + ], + ], // XMP media management. - 'http://ns.adobe.com/xap/1.0/mm/' => array( + 'http://ns.adobe.com/xap/1.0/mm/' => [ // if we extract the exif UniqueImageID, might // as well do this too. - 'OriginalDocumentID' => array( + 'OriginalDocumentID' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), + ], // It might also be useful to do xmpMM:LastURL // and xmpMM:DerivedFrom as you can potentially, // get the url of this document/source for this // document. However whats more likely is you'd // get a file:// url for the path of the doc, // which is somewhat of a privacy issue. - ), - 'http://creativecommons.org/ns#' => array( - 'license' => array( + ], + 'http://creativecommons.org/ns#' => [ + 'license' => [ 'map_name' => 'LicenseUrl', 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'morePermissions' => array( + ], + 'morePermissions' => [ 'map_name' => 'MorePermissionsUrl', 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'attributionURL' => array( + ], + 'attributionURL' => [ 'map_group' => 'general', 'map_name' => 'AttributionUrl', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'attributionName' => array( + ], + 'attributionName' => [ 'map_group' => 'general', 'map_name' => 'PreferredAttributionName', 'mode' => XMPReader::MODE_SIMPLE, - ), - ), + ], + ], // Note, this property affects how jpeg metadata is extracted. - 'http://ns.adobe.com/xmp/note/' => array( - 'HasExtendedXMP' => array( + 'http://ns.adobe.com/xmp/note/' => [ + 'HasExtendedXMP' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, - ), - ), + ], + ], /* Note, in iptc schemas, the legacy properties are denoted * as deprecated, since other properties should used instead, * and properties marked as deprecated in the standard are * are marked as general here as they don't have replacements */ - 'http://ns.adobe.com/photoshop/1.0/' => array( - 'City' => array( + 'http://ns.adobe.com/photoshop/1.0/' => [ + 'City' => [ 'map_group' => 'deprecated', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'CityDest', - ), - 'Country' => array( + ], + 'Country' => [ 'map_group' => 'deprecated', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'CountryDest', - ), - 'State' => array( + ], + 'State' => [ 'map_group' => 'deprecated', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'ProvinceOrStateDest', - ), - 'DateCreated' => array( + ], + 'DateCreated' => [ 'map_group' => 'deprecated', // marking as deprecated as the xmp prop preferred 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'DateTimeOriginal', 'validate' => 'validateDate', // note this prop is an XMP, not IPTC date - ), - 'CaptionWriter' => array( + ], + 'CaptionWriter' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'Writer', - ), - 'Instructions' => array( + ], + 'Instructions' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'SpecialInstructions', - ), - 'TransmissionReference' => array( + ], + 'TransmissionReference' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'OriginalTransmissionRef', - ), - 'AuthorsPosition' => array( + ], + 'AuthorsPosition' => [ /* This corresponds with 2:85 * By-line Title, which needs to be * handled weirdly to correspond * with iptc/exif. */ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE - ), - 'Credit' => array( + ], + 'Credit' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'Source' => array( + ], + 'Source' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'Urgency' => array( + ], + 'Urgency' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'Category' => array( + ], + 'Category' => [ // Note, this prop is deprecated, but in general // group since it doesn't have a replacement. 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'iimCategory', - ), - 'SupplementalCategories' => array( + ], + 'SupplementalCategories' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_BAG, 'map_name' => 'iimSupplementalCategory', - ), - 'Headline' => array( + ], + 'Headline' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE - ), - ), - 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/' => array( - 'CountryCode' => array( + ], + ], + 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/' => [ + 'CountryCode' => [ 'map_group' => 'deprecated', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'CountryCodeDest', - ), - 'IntellectualGenre' => array( + ], + 'IntellectualGenre' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), + ], // Note, this is a six digit code. // See: http://cv.iptc.org/newscodes/scene/ // Since these aren't really all that common, // we just show the number. - 'Scene' => array( + 'Scene' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_BAG, 'validate' => 'validateInteger', 'map_name' => 'SceneCode', - ), + ], /* Note: SubjectCode should be an 8 ascii digits. * it is not really an integer (has leading 0's, * cannot have a +/- sign), but validateInteger * will let it through. */ - 'SubjectCode' => array( + 'SubjectCode' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_BAG, 'map_name' => 'SubjectNewsCode', 'validate' => 'validateInteger' - ), - 'Location' => array( + ], + 'Location' => [ 'map_group' => 'deprecated', 'mode' => XMPReader::MODE_SIMPLE, 'map_name' => 'SublocationDest', - ), - 'CreatorContactInfo' => array( + ], + 'CreatorContactInfo' => [ /* Note this maps to 2:118 in iim * (Contact) field. However those field * types are slightly different - 2:118 @@ -1006,7 +1006,7 @@ class XMPInfo { 'map_group' => 'general', 'mode' => XMPReader::MODE_STRUCT, 'map_name' => 'Contact', - 'children' => array( + 'children' => [ 'CiAdrExtadr' => true, 'CiAdrCity' => true, 'CiAdrCtry' => true, @@ -1015,135 +1015,135 @@ class XMPInfo { 'CiAdrPcode' => true, 'CiAdrRegion' => true, 'CiUrlWork' => true, - ), - ), - 'CiAdrExtadr' => array( /* address */ + ], + ], + 'CiAdrExtadr' => [ /* address */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiAdrCity' => array( /* city */ + ], + 'CiAdrCity' => [ /* city */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiAdrCtry' => array( /* country */ + ], + 'CiAdrCtry' => [ /* country */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiEmailWork' => array( /* email (possibly separated by ',') */ + ], + 'CiEmailWork' => [ /* email (possibly separated by ',') */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiTelWork' => array( /* telephone */ + ], + 'CiTelWork' => [ /* telephone */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiAdrPcode' => array( /* postal code */ + ], + 'CiAdrPcode' => [ /* postal code */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiAdrRegion' => array( /* province/state */ + ], + 'CiAdrRegion' => [ /* province/state */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CiUrlWork' => array( /* url. Multiple may be separated by comma. */ + ], + 'CiUrlWork' => [ /* url. Multiple may be separated by comma. */ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), + ], /* End contact info struct properties */ - ), - 'http://iptc.org/std/Iptc4xmpExt/2008-02-29/' => array( - 'Event' => array( + ], + 'http://iptc.org/std/Iptc4xmpExt/2008-02-29/' => [ + 'Event' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, - ), - 'OrganisationInImageName' => array( + ], + 'OrganisationInImageName' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_BAG, 'map_name' => 'OrganisationInImage' - ), - 'PersonInImage' => array( + ], + 'PersonInImage' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_BAG, - ), - 'MaxAvailHeight' => array( + ], + 'MaxAvailHeight' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', 'map_name' => 'OriginalImageHeight', - ), - 'MaxAvailWidth' => array( + ], + 'MaxAvailWidth' => [ 'map_group' => 'general', 'mode' => XMPReader::MODE_SIMPLE, 'validate' => 'validateInteger', 'map_name' => 'OriginalImageWidth', - ), + ], // LocationShown and LocationCreated are handled // specially because they are hierarchical, but we // also want to merge with the old non-hierarchical. - 'LocationShown' => array( + 'LocationShown' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_BAGSTRUCT, - 'children' => array( + 'children' => [ 'WorldRegion' => true, 'CountryCode' => true, /* iso code */ 'CountryName' => true, 'ProvinceState' => true, 'City' => true, 'Sublocation' => true, - ), - ), - 'LocationCreated' => array( + ], + ], + 'LocationCreated' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_BAGSTRUCT, - 'children' => array( + 'children' => [ 'WorldRegion' => true, 'CountryCode' => true, /* iso code */ 'CountryName' => true, 'ProvinceState' => true, 'City' => true, 'Sublocation' => true, - ), - ), - 'WorldRegion' => array( + ], + ], + 'WorldRegion' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CountryCode' => array( + ], + 'CountryCode' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'CountryName' => array( + ], + 'CountryName' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, 'map_name' => 'Country', - ), - 'ProvinceState' => array( + ], + 'ProvinceState' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, 'map_name' => 'ProvinceOrState', - ), - 'City' => array( + ], + 'City' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), - 'Sublocation' => array( + ], + 'Sublocation' => [ 'map_group' => 'special', 'mode' => XMPReader::MODE_SIMPLE, 'structPart' => true, - ), + ], /* Other props that might be interesting but * Not currently extracted: @@ -1151,7 +1151,7 @@ class XMPInfo { * DigitalSourceType * RegistryId */ - ), + ], /* Plus props we might want to consider: * (Note: some of these have unclear/incomplete definitions @@ -1164,5 +1164,5 @@ class XMPInfo { * Various model release fields * Property release fields. */ - ); + ]; } diff --git a/includes/media/XMPValidate.php b/includes/media/XMPValidate.php index e1f69db2fd..d69d3ec06e 100644 --- a/includes/media/XMPValidate.php +++ b/includes/media/XMPValidate.php @@ -259,7 +259,7 @@ class XMPValidate implements LoggerAwareInterface { // this only validates standalone properties, not arrays, etc return; } - $res = array(); + $res = []; // @codingStandardsIgnoreStart Long line that cannot be broken if ( !preg_match( /* ahh! scary regex... */ @@ -360,7 +360,7 @@ class XMPValidate implements LoggerAwareInterface { return; } - $m = array(); + $m = []; if ( preg_match( '/(\d{1,3}),(\d{1,2}),(\d{1,2})([NWSE])/D', $val, $m ) diff --git a/includes/objectcache/MemcachedPeclBagOStuff.php b/includes/objectcache/MemcachedPeclBagOStuff.php index aa21cbb74a..090ace8538 100644 --- a/includes/objectcache/MemcachedPeclBagOStuff.php +++ b/includes/objectcache/MemcachedPeclBagOStuff.php @@ -112,7 +112,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { __CLASS__ . ': invalid value for serializer parameter' ); } - $servers = array(); + $servers = []; foreach ( $params['servers'] as $host ) { $servers[] = IP::splitHostAndPort( $host ); // (ip, port) } @@ -189,7 +189,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { break; default: $msg = $this->client->getResultMessage(); - $logCtx = array(); + $logCtx = []; if ( $key !== false ) { $server = $this->client->getServerByKey( $key ); $logCtx['memcached-server'] = "{$server['host']}:{$server['port']}"; @@ -209,7 +209,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { foreach ( $keys as $key ) { $this->validateKeyEncoding( $key ); } - $result = $this->client->getMulti( $keys ) ?: array(); + $result = $this->client->getMulti( $keys ) ?: []; return $this->checkResult( false, $result ); } diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index 90a9f7c842..12a673a829 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -78,9 +78,9 @@ use MediaWiki\Logger\LoggerFactory; */ class ObjectCache { /** @var BagOStuff[] Map of (id => BagOStuff) */ - public static $instances = array(); + public static $instances = []; /** @var WANObjectCache[] Map of (id => WANObjectCache) */ - public static $wanInstances = array(); + public static $wanInstances = []; /** * Get a cached instance of the specified type of cache object. @@ -217,7 +217,7 @@ class ObjectCache { */ public static function newAnything( $params ) { global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType; - $candidates = array( $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType ); + $candidates = [ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType ]; foreach ( $candidates as $candidate ) { if ( $candidate !== CACHE_NONE && $candidate !== CACHE_ANYTHING ) { return self::getInstance( $candidate ); @@ -267,7 +267,7 @@ class ObjectCache { * @return BagOStuff * @deprecated 1.27 */ - public static function newAccelerator( $params = array(), $fallback = null ) { + public static function newAccelerator( $params = [], $fallback = null ) { if ( $fallback === null ) { // The is_array check here is needed because in PHP 5.3: // $a = 'hash'; isset( $params['fallback'] ); yields true @@ -363,7 +363,7 @@ class ObjectCache { * Clear all the cached instances. */ public static function clear() { - self::$instances = array(); - self::$wanInstances = array(); + self::$instances = []; + self::$wanInstances = []; } } diff --git a/includes/objectcache/RedisBagOStuff.php b/includes/objectcache/RedisBagOStuff.php index 2c12fdf099..61e6926c85 100644 --- a/includes/objectcache/RedisBagOStuff.php +++ b/includes/objectcache/RedisBagOStuff.php @@ -65,8 +65,8 @@ class RedisBagOStuff extends BagOStuff { */ function __construct( $params ) { parent::__construct( $params ); - $redisConf = array( 'serializer' => 'none' ); // manage that in this class - foreach ( array( 'connectTimeout', 'persistent', 'password' ) as $opt ) { + $redisConf = [ 'serializer' => 'none' ]; // manage that in this class + foreach ( [ 'connectTimeout', 'persistent', 'password' ] as $opt ) { if ( isset( $params[$opt] ) ) { $redisConf[$opt] = $params[$opt]; } @@ -143,8 +143,8 @@ class RedisBagOStuff extends BagOStuff { } public function getMulti( array $keys, $flags = 0 ) { - $batches = array(); - $conns = array(); + $batches = []; + $conns = []; foreach ( $keys as $key ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { @@ -153,7 +153,7 @@ class RedisBagOStuff extends BagOStuff { $conns[$server] = $conn; $batches[$server][] = $key; } - $result = array(); + $result = []; foreach ( $batches as $server => $batchKeys ) { $conn = $conns[$server]; try { @@ -187,8 +187,8 @@ class RedisBagOStuff extends BagOStuff { * @return bool */ public function setMulti( array $data, $expiry = 0 ) { - $batches = array(); - $conns = array(); + $batches = []; + $conns = []; foreach ( $data as $key => $value ) { list( $server, $conn ) = $this->getConnection( $key ); if ( !$conn ) { @@ -241,7 +241,7 @@ class RedisBagOStuff extends BagOStuff { $result = $conn->set( $key, $this->serialize( $value ), - array( 'nx', 'ex' => $expiry ) + [ 'nx', 'ex' => $expiry ] ); } else { $result = $conn->setnx( $key, $this->serialize( $value ) ); @@ -356,12 +356,12 @@ class RedisBagOStuff extends BagOStuff { } } - return array( $server, $conn ); + return [ $server, $conn ]; } $this->setLastError( BagOStuff::ERR_UNREACHABLE ); - return array( false, false ); + return [ false, false ]; } /** diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 0e3c9ebbf9..39450941e3 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -49,9 +49,9 @@ class SqlBagOStuff extends BagOStuff { /** @var array */ protected $conns; /** @var array UNIX timestamps */ - protected $connFailureTimes = array(); + protected $connFailureTimes = []; /** @var array Exceptions */ - protected $connFailureErrors = array(); + protected $connFailureErrors = []; /** * Constructor. Parameters are: @@ -91,12 +91,12 @@ class SqlBagOStuff extends BagOStuff { if ( isset( $params['servers'] ) ) { $this->serverInfos = $params['servers']; $this->numServers = count( $this->serverInfos ); - $this->serverNames = array(); + $this->serverNames = []; foreach ( $this->serverInfos as $i => $info ) { $this->serverNames[$i] = isset( $info['host'] ) ? $info['host'] : "#$i"; } } elseif ( isset( $params['server'] ) ) { - $this->serverInfos = array( $params['server'] ); + $this->serverInfos = [ $params['server'] ]; $this->numServers = count( $this->serverInfos ); } else { $this->serverInfos = false; @@ -187,7 +187,7 @@ class SqlBagOStuff extends BagOStuff { } else { $serverIndex = 0; } - return array( $serverIndex, $this->getTableNameByShard( $tableIndex ) ); + return [ $serverIndex, $this->getTableNameByShard( $tableIndex ) ]; } /** @@ -212,7 +212,7 @@ class SqlBagOStuff extends BagOStuff { } protected function getWithToken( $key, &$casToken, $flags = 0 ) { - $values = $this->getMulti( array( $key ) ); + $values = $this->getMulti( [ $key ] ); if ( array_key_exists( $key, $values ) ) { $casToken = $values[$key]; return $values[$key]; @@ -221,9 +221,9 @@ class SqlBagOStuff extends BagOStuff { } public function getMulti( array $keys, $flags = 0 ) { - $values = array(); // array of (key => value) + $values = []; // array of (key => value) - $keysByTable = array(); + $keysByTable = []; foreach ( $keys as $key ) { list( $serverIndex, $tableName ) = $this->getTableByKey( $key ); $keysByTable[$serverIndex][$tableName][] = $key; @@ -231,19 +231,19 @@ class SqlBagOStuff extends BagOStuff { $this->garbageCollect(); // expire old entries if any - $dataRows = array(); + $dataRows = []; foreach ( $keysByTable as $serverIndex => $serverKeys ) { try { $db = $this->getDB( $serverIndex ); foreach ( $serverKeys as $tableName => $tableKeys ) { $res = $db->select( $tableName, - array( 'keyname', 'value', 'exptime' ), - array( 'keyname' => $tableKeys ), + [ 'keyname', 'value', 'exptime' ], + [ 'keyname' => $tableKeys ], __METHOD__, // Approximate write-on-the-fly BagOStuff API via blocking. // This approximation fails if a ROLLBACK happens (which is rare). // We do not want to flush the TRX as that can break callers. - $db->trxLevel() ? array( 'LOCK IN SHARE MODE' ) : array() + $db->trxLevel() ? [ 'LOCK IN SHARE MODE' ] : [] ); if ( $res === false ) { continue; @@ -282,7 +282,7 @@ class SqlBagOStuff extends BagOStuff { } public function setMulti( array $data, $expiry = 0 ) { - $keysByTable = array(); + $keysByTable = []; foreach ( $data as $key => $value ) { list( $serverIndex, $tableName ) = $this->getTableByKey( $key ); $keysByTable[$serverIndex][$tableName][] = $key; @@ -312,19 +312,19 @@ class SqlBagOStuff extends BagOStuff { $encExpiry = $db->timestamp( $exptime ); } foreach ( $serverKeys as $tableName => $tableKeys ) { - $rows = array(); + $rows = []; foreach ( $tableKeys as $key ) { - $rows[] = array( + $rows[] = [ 'keyname' => $key, 'value' => $db->encodeBlob( $this->serialize( $data[$key] ) ), 'exptime' => $encExpiry, - ); + ]; } try { $db->replace( $tableName, - array( 'keyname' ), + [ 'keyname' ], $rows, __METHOD__ ); @@ -341,7 +341,7 @@ class SqlBagOStuff extends BagOStuff { } public function set( $key, $value, $exptime = 0, $flags = 0 ) { - $ok = $this->setMulti( array( $key => $value ), $exptime ); + $ok = $this->setMulti( [ $key => $value ], $exptime ); if ( ( $flags & self::WRITE_SYNC ) == self::WRITE_SYNC ) { $ok = $ok && $this->waitForSlaves(); } @@ -369,15 +369,15 @@ class SqlBagOStuff extends BagOStuff { // delete/insert to avoid clashes with conflicting keynames $db->update( $tableName, - array( + [ 'keyname' => $key, 'value' => $db->encodeBlob( $this->serialize( $value ) ), 'exptime' => $encExpiry - ), - array( + ], + [ 'keyname' => $key, 'value' => $db->encodeBlob( $this->serialize( $casToken ) ) - ), + ], __METHOD__ ); } catch ( DBQueryError $e ) { @@ -395,7 +395,7 @@ class SqlBagOStuff extends BagOStuff { $db = $this->getDB( $serverIndex ); $db->delete( $tableName, - array( 'keyname' => $key ), + [ 'keyname' => $key ], __METHOD__ ); } catch ( DBError $e ) { $this->handleWriteError( $e, $serverIndex ); @@ -412,16 +412,16 @@ class SqlBagOStuff extends BagOStuff { $step = intval( $step ); $row = $db->selectRow( $tableName, - array( 'value', 'exptime' ), - array( 'keyname' => $key ), + [ 'value', 'exptime' ], + [ 'keyname' => $key ], __METHOD__, - array( 'FOR UPDATE' ) ); + [ 'FOR UPDATE' ] ); if ( $row === false ) { // Missing return null; } - $db->delete( $tableName, array( 'keyname' => $key ), __METHOD__ ); + $db->delete( $tableName, [ 'keyname' => $key ], __METHOD__ ); if ( $this->isExpired( $db, $row->exptime ) ) { // Expired, do not reinsert @@ -431,11 +431,11 @@ class SqlBagOStuff extends BagOStuff { $oldValue = intval( $this->unserialize( $db->decodeBlob( $row->value ) ) ); $newValue = $oldValue + $step; $db->insert( $tableName, - array( + [ 'keyname' => $key, 'value' => $db->encodeBlob( $this->serialize( $newValue ) ), 'exptime' => $row->exptime - ), __METHOD__, 'IGNORE' ); + ], __METHOD__, 'IGNORE' ); if ( $db->affectedRows() == 0 ) { // Race condition. See bug 28611 @@ -516,7 +516,7 @@ class SqlBagOStuff extends BagOStuff { $db = $this->getDB( $serverIndex ); $dbTimestamp = $db->timestamp( $timestamp ); $totalSeconds = false; - $baseConds = array( 'exptime < ' . $db->addQuotes( $dbTimestamp ) ); + $baseConds = [ 'exptime < ' . $db->addQuotes( $dbTimestamp ) ]; for ( $i = 0; $i < $this->shards; $i++ ) { $maxExpTime = false; while ( true ) { @@ -526,14 +526,14 @@ class SqlBagOStuff extends BagOStuff { } $rows = $db->select( $this->getTableNameByShard( $i ), - array( 'keyname', 'exptime' ), + [ 'keyname', 'exptime' ], $conds, __METHOD__, - array( 'LIMIT' => 100, 'ORDER BY' => 'exptime' ) ); + [ 'LIMIT' => 100, 'ORDER BY' => 'exptime' ] ); if ( $rows === false || !$rows->numRows() ) { break; } - $keys = array(); + $keys = []; $row = $rows->current(); $minExpTime = $row->exptime; if ( $totalSeconds === false ) { @@ -547,11 +547,11 @@ class SqlBagOStuff extends BagOStuff { $db->delete( $this->getTableNameByShard( $i ), - array( + [ 'exptime >= ' . $db->addQuotes( $minExpTime ), 'exptime < ' . $db->addQuotes( $dbTimestamp ), 'keyname' => $keys - ), + ], __METHOD__ ); if ( $progressCallback ) { @@ -736,7 +736,7 @@ class SqlBagOStuff extends BagOStuff { if ( !$this->serverInfos ) { // Main LB is used; wait for any slaves to catch up try { - wfGetLBFactory()->waitForReplication( array( 'wiki' => wfWikiID() ) ); + wfGetLBFactory()->waitForReplication( [ 'wiki' => wfWikiID() ] ); return true; } catch ( DBReplicationWaitError $e ) { return false; diff --git a/includes/page/Article.php b/includes/page/Article.php index e81fd96658..4e4b2d7e65 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -118,7 +118,7 @@ class Article implements Page { } $page = null; - Hooks::run( 'ArticleFromTitle', array( &$title, &$page, $context ) ); + Hooks::run( 'ArticleFromTitle', [ &$title, &$page, $context ] ); if ( !$page ) { switch ( $title->getNamespace() ) { case NS_FILE: @@ -283,7 +283,7 @@ class Article implements Page { if ( $this->mRevision !== null ) { // Revision title doesn't match the page title given? if ( $this->mPage->getID() != $this->mRevision->getPage() ) { - $function = array( get_class( $this->mPage ), 'newFromID' ); + $function = [ get_class( $this->mPage ), 'newFromID' ]; $this->mPage = call_user_func( $function, $this->mRevision->getPage() ); } } @@ -340,7 +340,7 @@ class Article implements Page { // @todo Get rid of mContent everywhere! $this->mContent = ContentHandler::getContentText( $content ); - ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) ); + ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', [ &$this, &$this->mContent ] ); return $this->mContent; } @@ -370,7 +370,7 @@ class Article implements Page { # Pre-fill content with error message so that if something # fails we'll have something telling us what we intended. // XXX: this isn't page content but a UI message. horrible. - $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ) ); + $this->mContentObject = new MessageContent( 'missing-revision', [ $oldid ] ); if ( $oldid ) { # $this->mRevision might already be fetched by getOldIDFromRequest() @@ -390,7 +390,7 @@ class Article implements Page { } # Update error message with correct oldid - $this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ) ); + $this->mContentObject = new MessageContent( 'missing-revision', [ $oldid ] ); $this->mRevision = $this->mPage->getRevision(); @@ -417,7 +417,7 @@ class Article implements Page { $this->mContentObject = $content; $this->mRevIdFetched = $this->mRevision->getId(); - Hooks::run( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) ); + Hooks::run( 'ArticleAfterFetchContentObject', [ &$this, &$this->mContentObject ] ); return $this->mContentObject; } @@ -582,7 +582,7 @@ class Article implements Page { while ( !$outputDone && ++$pass ) { switch ( $pass ) { case 1: - Hooks::run( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) ); + Hooks::run( 'ArticleViewHeader', [ &$this, &$outputDone, &$useParserCache ] ); break; case 2: # Early abort if the page doesn't exist @@ -644,12 +644,12 @@ class Article implements Page { $this->showCssOrJsPage(); $outputDone = true; } elseif ( !Hooks::run( 'ArticleContentViewCustom', - array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { + [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) { # Allow extensions do their own custom view for certain pages $outputDone = true; } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', - array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { + [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) { # Allow extensions do their own custom view for certain pages $outputDone = true; @@ -823,7 +823,7 @@ class Article implements Page { // Give hooks a chance to customise the output if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', - array( $this->mContentObject, $this->getTitle(), $outputPage ) ) + [ $this->mContentObject, $this->getTitle(), $outputPage ] ) ) { // If no legacy hooks ran, display the content of the parser output, including RL modules, // but excluding metadata like categories and language links @@ -856,31 +856,31 @@ class Article implements Page { $specificTarget = $titleText; } if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) { - return array( + return [ 'index' => 'noindex', 'follow' => 'nofollow' - ); + ]; } } if ( $this->mPage->getID() === 0 || $this->getOldID() ) { # Non-articles (special pages etc), and old revisions - return array( + return [ 'index' => 'noindex', 'follow' => 'nofollow' - ); + ]; } elseif ( $this->getContext()->getOutput()->isPrintable() ) { # Discourage indexing of printable versions, but encourage following - return array( + return [ 'index' => 'noindex', 'follow' => 'follow' - ); + ]; } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) { # For ?curid=x urls, disallow indexing - return array( + return [ 'index' => 'noindex', 'follow' => 'follow' - ); + ]; } # Otherwise, construct the policy based on the various config variables. @@ -898,7 +898,7 @@ class Article implements Page { # a final sanity check that we have really got the parser output. $policy = array_merge( $policy, - array( 'index' => $pOutput->getIndexPolicy() ) + [ 'index' => $pOutput->getIndexPolicy() ] ); } @@ -924,17 +924,17 @@ class Article implements Page { if ( is_array( $policy ) ) { return $policy; } elseif ( !$policy ) { - return array(); + return []; } $policy = explode( ',', $policy ); $policy = array_map( 'trim', $policy ); - $arr = array(); + $arr = []; foreach ( $policy as $var ) { - if ( in_array( $var, array( 'index', 'noindex' ) ) ) { + if ( in_array( $var, [ 'index', 'noindex' ] ) ) { $arr['index'] = $var; - } elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) { + } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) { $arr['follow'] = $var; } } @@ -970,12 +970,12 @@ class Article implements Page { if ( isset( $this->mRedirectedFrom ) ) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. - if ( Hooks::run( 'ArticleViewRedirect', array( &$this ) ) ) { + if ( Hooks::run( 'ArticleViewRedirect', [ &$this ] ) ) { $redir = Linker::linkKnown( $this->mRedirectedFrom, null, - array(), - array( 'redirect' => 'no' ) + [], + [ 'redirect' => 'no' ] ); $outputPage->addSubtitle( "" . @@ -984,9 +984,9 @@ class Article implements Page { // Add the script to update the displayed URL and // set the fragment if one was specified in the redirect - $outputPage->addJsConfigVars( array( + $outputPage->addJsConfigVars( [ 'wgInternalRedirectTargetUrl' => $redirectTargetUrl, - ) ); + ] ); $outputPage->addModules( 'mediawiki.action.view.redirect' ); // Add a tag @@ -1007,9 +1007,9 @@ class Article implements Page { . "" ); // Add the script to update the displayed URL - $outputPage->addJsConfigVars( array( + $outputPage->addJsConfigVars( [ 'wgInternalRedirectTargetUrl' => $redirectTargetUrl, - ) ); + ] ); $outputPage->addModules( 'mediawiki.action.view.redirect' ); return true; @@ -1028,7 +1028,7 @@ class Article implements Page { if ( !wfMessage( 'talkpageheader' )->isDisabled() ) { $this->getContext()->getOutput()->wrapWikiMsg( "
    \n$1\n
    ", - array( 'talkpageheader' ) + [ 'talkpageheader' ] ); } } @@ -1048,7 +1048,7 @@ class Article implements Page { // Show a footer allowing the user to patrol the shown revision or page if possible $patrolFooterShown = $this->showPatrolFooter(); - Hooks::run( 'ArticleViewFooter', array( $this, $patrolFooterShown ) ); + Hooks::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] ); } /** @@ -1093,7 +1093,7 @@ class Article implements Page { $oldestRevisionTimestamp = $dbr->selectField( 'revision', 'MIN( rev_timestamp )', - array( 'rev_page' => $this->getTitle()->getArticleID() ), + [ 'rev_page' => $this->getTitle()->getArticleID() ], __METHOD__ ); @@ -1109,12 +1109,12 @@ class Article implements Page { // 6h tolerance because the RC might not be cleaned out regularly $recentPageCreation = true; $rc = RecentChange::newFromConds( - array( + [ 'rc_new' => 1, 'rc_timestamp' => $oldestRevisionTimestamp, 'rc_namespace' => $this->getTitle()->getNamespace(), 'rc_cur_id' => $this->getTitle()->getArticleID() - ), + ], __METHOD__ ); if ( $rc ) { @@ -1134,7 +1134,7 @@ class Article implements Page { $newestUploadTimestamp = $dbr->selectField( 'image', 'MAX( img_timestamp )', - array( 'img_name' => $this->getTitle()->getDBkey() ), + [ 'img_name' => $this->getTitle()->getDBkey() ], __METHOD__ ); if ( $newestUploadTimestamp @@ -1143,15 +1143,15 @@ class Article implements Page { // 6h tolerance because the RC might not be cleaned out regularly $recentFileUpload = true; $rc = RecentChange::newFromConds( - array( + [ 'rc_type' => RC_LOG, 'rc_log_type' => 'upload', 'rc_timestamp' => $newestUploadTimestamp, 'rc_namespace' => NS_FILE, 'rc_cur_id' => $this->getTitle()->getArticleID() - ), + ], __METHOD__, - array( 'USE INDEX' => 'rc_timestamp' ) + [ 'USE INDEX' => 'rc_timestamp' ] ); if ( $rc ) { // Use patrol message specific to files @@ -1205,12 +1205,12 @@ class Article implements Page { $link = Linker::linkKnown( $this->getTitle(), $markPatrolledMsg->escaped(), - array(), - array( + [], + [ 'action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token, - ) + ] ); $outputPage->addHTML( @@ -1258,7 +1258,7 @@ class Article implements Page { if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist $outputPage->wrapWikiMsg( "
    \n\$1\n
    ", - array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) ); + [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] ); } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { # Show log extract if the user is currently blocked LogEventsList::showLogExtract( @@ -1266,14 +1266,14 @@ class Article implements Page { 'block', MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(), '', - array( + [ 'lim' => 1, 'showIfEmpty' => false, - 'msgKey' => array( + 'msgKey' => [ 'blocked-notice-logextract', $user->getName() # Support GENDER in notice - ) - ) + ] + ] ); $validUserPage = !$title->isSubpage(); } else { @@ -1281,7 +1281,7 @@ class Article implements Page { } } - Hooks::run( 'ShowMissingArticle', array( $this ) ); + Hooks::run( 'ShowMissingArticle', [ $this ] ); # Show delete and move logs if there were any such events. # The logging query can DOS the site when bots/crawlers cause 404 floods, @@ -1290,24 +1290,24 @@ class Article implements Page { $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) ); $loggedIn = $this->getContext()->getUser()->isLoggedIn(); if ( $loggedIn || $cache->get( $key ) ) { - $logTypes = array( 'delete', 'move' ); - $conds = array( "log_action != 'revision'" ); + $logTypes = [ 'delete', 'move' ]; + $conds = [ "log_action != 'revision'" ]; // Give extensions a chance to hide their (unrelated) log entries - Hooks::run( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) ); + Hooks::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] ); LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '', - array( + [ 'lim' => 10, 'conds' => $conds, 'showIfEmpty' => false, - 'msgKey' => array( $loggedIn + 'msgKey' => [ $loggedIn ? 'moveddeleted-notice' : 'moveddeleted-notice-recent' - ) - ) + ] + ] ); } @@ -1322,7 +1322,7 @@ class Article implements Page { $outputPage->setIndexPolicy( $policy['index'] ); $outputPage->setFollowPolicy( $policy['follow'] ); - $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', array( $this ) ); + $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', [ $this ] ); if ( !$hookResult ) { return; @@ -1346,11 +1346,11 @@ class Article implements Page { $dir = $this->getContext()->getLanguage()->getDir(); $lang = $this->getContext()->getLanguage()->getCode(); - $outputPage->addWikiText( Xml::openElement( 'div', array( + $outputPage->addWikiText( Xml::openElement( 'div', [ 'class' => "noarticletext mw-content-$dir", 'dir' => $dir, 'lang' => $lang, - ) ) . "\n$text\n
    " ); + ] ) . "\n$text\n" ); } } @@ -1382,7 +1382,7 @@ class Article implements Page { $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ? 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide'; $outputPage->wrapWikiMsg( "\n", - array( $msg, $link ) ); + [ $msg, $link ] ); return false; // We are allowed to see... @@ -1404,7 +1404,7 @@ class Article implements Page { * @param int $oldid Revision ID of this article revision */ public function setOldSubtitle( $oldid = 0 ) { - if ( !Hooks::run( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { + if ( !Hooks::run( 'DisplayOldSubtitle', [ &$this, &$oldid ] ) ) { return; } @@ -1412,7 +1412,7 @@ class Article implements Page { $unhide = $context->getRequest()->getInt( 'unhide' ) == 1; # Cascade unhide param in links for easy deletion browsing - $extraParams = array(); + $extraParams = []; if ( $unhide ) { $extraParams['unhide'] = 1; } @@ -1455,7 +1455,7 @@ class Article implements Page { : Linker::linkKnown( $this->getTitle(), $context->msg( 'currentrevisionlink' )->escaped(), - array(), + [], $extraParams ); $curdiff = $current @@ -1463,33 +1463,33 @@ class Article implements Page { : Linker::linkKnown( $this->getTitle(), $context->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'diff' => 'cur', 'oldid' => $oldid - ) + $extraParams + ] + $extraParams ); $prev = $this->getTitle()->getPreviousRevisionID( $oldid ); $prevlink = $prev ? Linker::linkKnown( $this->getTitle(), $context->msg( 'previousrevision' )->escaped(), - array(), - array( + [], + [ 'direction' => 'prev', 'oldid' => $oldid - ) + $extraParams + ] + $extraParams ) : $context->msg( 'previousrevision' )->escaped(); $prevdiff = $prev ? Linker::linkKnown( $this->getTitle(), $context->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'diff' => 'prev', 'oldid' => $oldid - ) + $extraParams + ] + $extraParams ) : $context->msg( 'diff' )->escaped(); $nextlink = $current @@ -1497,22 +1497,22 @@ class Article implements Page { : Linker::linkKnown( $this->getTitle(), $context->msg( 'nextrevision' )->escaped(), - array(), - array( + [], + [ 'direction' => 'next', 'oldid' => $oldid - ) + $extraParams + ] + $extraParams ); $nextdiff = $current ? $context->msg( 'diff' )->escaped() : Linker::linkKnown( $this->getTitle(), $context->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'diff' => 'next', 'oldid' => $oldid - ) + $extraParams + ] + $extraParams ); $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() ); @@ -1561,7 +1561,7 @@ class Article implements Page { */ public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) { if ( !is_array( $target ) ) { - $target = array( $target ); + $target = [ $target ]; } $html = '
      '; @@ -1570,11 +1570,11 @@ class Article implements Page { $html .= '
    • ' . Linker::link( $title, htmlspecialchars( $title->getFullText() ), - array(), + [], // Automatically append redirect=no to each link, since most of them are // redirect pages themselves. - array( 'redirect' => 'no' ), - ( $forceKnown ? array( 'known', 'noclasses' ) : array() ) + [ 'redirect' => 'no' ], + ( $forceKnown ? [ 'known', 'noclasses' ] : [] ) ) . '
    • '; } $html .= '
    '; @@ -1662,7 +1662,7 @@ class Article implements Page { $outputPage = $context->getOutput(); $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) ); $outputPage->wrapWikiMsg( "
    \n$1\n
    ", - array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ) + [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ] ); $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) @@ -1691,7 +1691,7 @@ class Article implements Page { } if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ), - array( 'delete', $this->getTitle()->getPrefixedText() ) ) + [ 'delete', $this->getTitle()->getPrefixedText() ] ) ) { # Flag to hide all contents of the archived revisions $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' ); @@ -1729,7 +1729,7 @@ class Article implements Page { $revisions = $edits = (int)$dbr->selectField( 'revision', 'COUNT(rev_page)', - array( 'rev_page' => $title->getArticleID() ), + [ 'rev_page' => $title->getArticleID() ], __METHOD__ ); @@ -1739,18 +1739,18 @@ class Article implements Page { $context->msg( 'historywarning' )->numParams( $revisions )->parse() . $context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title, $context->msg( 'history' )->escaped(), - array(), - array( 'action' => 'history' ) ) . + [], + [ 'action' => 'history' ] ) . '' ); if ( $title->isBigDeletion() ) { global $wgDeleteRevisionsLimit; $context->getOutput()->wrapWikiMsg( "
    \n$1\n
    \n", - array( + [ 'delete-warning-toobig', $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) - ) + ] ); } } @@ -1780,26 +1780,26 @@ class Article implements Page { } $outputPage->addWikiMsg( 'confirmdeletetext' ); - Hooks::run( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) ); + Hooks::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] ); $user = $this->getContext()->getUser(); if ( $user->isAllowed( 'suppressrevision' ) ) { - $suppress = Html::openElement( 'div', array( 'id' => 'wpDeleteSuppressRow' ) ) . + $suppress = Html::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) . Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(), - 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) . + 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '4' ] ) . Html::closeElement( 'div' ); } else { $suppress = ''; } $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title ); - $form = Html::openElement( 'form', array( 'method' => 'post', - 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) . - Html::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) . + $form = Html::openElement( 'form', [ 'method' => 'post', + 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) . + Html::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) . Html::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) . - Html::openElement( 'div', array( 'id' => 'mw-deleteconfirm-table' ) ) . - Html::openElement( 'div', array( 'id' => 'wpDeleteReasonListRow' ) ) . + Html::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) . + Html::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) . Html::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) . ' ' . Xml::listDropDown( @@ -1811,43 +1811,43 @@ class Article implements Page { 1 ) . Html::closeElement( 'div' ) . - Html::openElement( 'div', array( 'id' => 'wpDeleteReasonRow' ) ) . + Html::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) . Html::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) . ' ' . - Html::input( 'wpReason', $reason, 'text', array( + Html::input( 'wpReason', $reason, 'text', [ 'size' => '60', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason', 'class' => 'mw-ui-input-inline', 'autofocus' - ) ) . + ] ) . Html::closeElement( 'div' ); # Disallow watching if user is not logged in if ( $user->isLoggedIn() ) { $form .= Xml::checkLabel( wfMessage( 'watchthis' )->text(), - 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ); + 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] ); } $form .= Html::openElement( 'div' ) . $suppress . Xml::submitButton( wfMessage( 'deletepage' )->text(), - array( + [ 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '5', 'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button mw-ui-destructive' : '', - ) + ] ) . Html::closeElement( 'div' ) . Html::closeElement( 'div' ) . Xml::closeElement( 'fieldset' ) . Html::hidden( 'wpEditToken', - $user->getEditToken( array( 'delete', $title->getPrefixedText() ) ) + $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) ) . Xml::closeElement( 'form' ); @@ -1855,8 +1855,8 @@ class Article implements Page { $link = Linker::linkKnown( $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(), wfMessage( 'delete-edit-reasonlist' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); $form .= '

    ' . $link . '

    '; } @@ -1890,7 +1890,7 @@ class Article implements Page { $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink ); - Hooks::run( 'ArticleDeleteAfterSuccess', array( $this->getTitle(), $outputPage ) ); + Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] ); $outputPage->returnToMain( false ); } else { @@ -1943,7 +1943,7 @@ class Article implements Page { return true; } else { wfDebug( "Article::tryFileCache(): starting buffer\n" ); - ob_start( array( &$cache, 'saveToFileCache' ) ); + ob_start( [ &$cache, 'saveToFileCache' ] ); } } else { wfDebug( "Article::tryFileCache(): not cacheable\n" ); @@ -1964,7 +1964,7 @@ class Article implements Page { && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect(); // Extension may have reason to disable file caching on some pages. if ( $cacheable ) { - $cacheable = Hooks::run( 'IsFileCacheable', array( &$this ) ); + $cacheable = Hooks::run( 'IsFileCacheable', [ &$this ] ); } } @@ -2076,7 +2076,7 @@ class Article implements Page { # wfWarn( "Access to raw $fname field of " . __CLASS__ ); $this->mPage->$fname = $fvalue; // Note: extensions may want to toss on new fields - } elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) { + } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) { $this->mPage->$fname = $fvalue; } else { trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE ); @@ -2152,7 +2152,7 @@ class Article implements Page { * Call to WikiPage function for backwards compatibility. * @see WikiPage::doEditUpdates */ - public function doEditUpdates( Revision $revision, User $user, array $options = array() ) { + public function doEditUpdates( Revision $revision, User $user, array $options = [] ) { return $this->mPage->doEditUpdates( $revision, $user, $options ); } @@ -2498,7 +2498,7 @@ class Article implements Page { * Call to WikiPage function for backwards compatibility. * @see WikiPage::pageDataFromId */ - public function pageDataFromId( $dbr, $id, $options = array() ) { + public function pageDataFromId( $dbr, $id, $options = [] ) { return $this->mPage->pageDataFromId( $dbr, $id, $options ); } @@ -2506,7 +2506,7 @@ class Article implements Page { * Call to WikiPage function for backwards compatibility. * @see WikiPage::pageDataFromTitle */ - public function pageDataFromTitle( $dbr, $title, $options = array() ) { + public function pageDataFromTitle( $dbr, $title, $options = [] ) { return $this->mPage->pageDataFromTitle( $dbr, $title, $options ); } @@ -2675,8 +2675,8 @@ class Article implements Page { * @param array $expiry * @return bool */ - public function updateRestrictions( $limit = array(), $reason = '', - &$cascade = 0, $expiry = array() + public function updateRestrictions( $limit = [], $reason = '', + &$cascade = 0, $expiry = [] ) { return $this->mPage->doUpdateRestrictions( $limit, diff --git a/includes/page/CategoryPage.php b/includes/page/CategoryPage.php index 50cb96ca0d..55fe1562da 100644 --- a/includes/page/CategoryPage.php +++ b/includes/page/CategoryPage.php @@ -66,7 +66,7 @@ class CategoryPage extends Article { return; } - if ( !Hooks::run( 'CategoryPageView', array( &$this ) ) ) { + if ( !Hooks::run( 'CategoryPageView', [ &$this ] ) ) { return; } @@ -94,8 +94,8 @@ class CategoryPage extends Article { $reqArray = $request->getValues(); - $from = $until = array(); - foreach ( array( 'page', 'subcat', 'file' ) as $type ) { + $from = $until = []; + foreach ( [ 'page', 'subcat', 'file' ] as $type ) { $from[$type] = $request->getVal( "{$type}from", $oldFrom ); $until[$type] = $request->getVal( "{$type}until", $oldUntil ); diff --git a/includes/page/ImageHistoryList.php b/includes/page/ImageHistoryList.php index 4c36729794..607357fcd1 100644 --- a/includes/page/ImageHistoryList.php +++ b/includes/page/ImageHistoryList.php @@ -80,12 +80,12 @@ class ImageHistoryList extends ContextSource { * @return string */ public function beginImageHistoryList( $navLinks = '' ) { - return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) + return Xml::element( 'h2', [ 'id' => 'filehistory' ], $this->msg( 'filehist' )->text() ) . "\n" . "
    \n" . $this->msg( 'filehist-help' )->parseAsBlock() . $navLinks . "\n" - . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n" + . Xml::openElement( 'table', [ 'class' => 'wikitable filehistory' ] ) . "\n" . '' . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '' : '' ) @@ -129,14 +129,14 @@ class ImageHistoryList extends ContextSource { $row .= ''; # Link to remove from history if ( $user->isAllowed( 'delete' ) ) { - $q = array( 'action' => 'delete' ); + $q = [ 'action' => 'delete' ]; if ( !$iscur ) { $q['oldimage'] = $img; } $row .= Linker::linkKnown( $this->title, $this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(), - array(), $q + [], $q ); } # Link to hide content. Don't show useless link to people who cannot hide revisions. @@ -150,11 +150,11 @@ class ImageHistoryList extends ContextSource { $del = Linker::revDeleteLinkDisabled( $canHide ); } else { list( $ts, ) = explode( '!', $img, 2 ); - $query = array( + $query = [ 'type' => 'oldimage', 'target' => $this->title->getPrefixedText(), 'ids' => $ts, - ); + ]; $del = Linker::revDeleteLink( $query, $file->isDeleted( File::DELETED_RESTRICTED ), $canHide ); } @@ -176,12 +176,12 @@ class ImageHistoryList extends ContextSource { $row .= Linker::linkKnown( $this->title, $this->msg( 'filehist-revert' )->escaped(), - array(), - array( + [], + [ 'action' => 'revert', 'oldimage' => $img, 'wpEditToken' => $user->getEditToken( $img ) - ) + ] ); } } @@ -204,12 +204,12 @@ class ImageHistoryList extends ContextSource { $url = Linker::linkKnown( $revdel, $lang->userTimeAndDate( $timestamp, $user ), - array(), - array( + [], + [ 'target' => $this->title->getPrefixedText(), 'file' => $img, 'token' => $user->getEditToken( $img ) - ) + ] ); } else { $url = $lang->userTimeAndDate( $timestamp, $user ); @@ -222,7 +222,7 @@ class ImageHistoryList extends ContextSource { $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img ); $row .= Xml::element( 'a', - array( 'href' => $url ), + [ 'href' => $url ], $lang->userTimeAndDate( $timestamp, $user ) ); } @@ -270,7 +270,7 @@ class ImageHistoryList extends ContextSource { } $rowClass = null; - Hooks::run( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) ); + Hooks::run( 'ImagePageFileHistoryLine', [ $this, $file, &$row, &$rowClass ] ); $classAttr = $rowClass ? " class='$rowClass'" : ''; return "{$row}\n"; @@ -286,20 +286,20 @@ class ImageHistoryList extends ContextSource { if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE, $user ) && !$file->isDeleted( File::DELETED_FILE ) ) { - $params = array( + $params = [ 'width' => '120', 'height' => '120', - ); + ]; $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() ); $thumbnail = $file->transform( $params ); - $options = array( + $options = [ 'alt' => $this->msg( 'filehist-thumbtext', $lang->userTimeAndDate( $timestamp, $user ), $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->text(), 'file-link' => true, - ); + ]; if ( !$thumbnail ) { return $this->msg( 'filehist-nothumb' )->escaped(); diff --git a/includes/page/ImageHistoryPseudoPager.php b/includes/page/ImageHistoryPseudoPager.php index f541387d66..6ab3ffc930 100644 --- a/includes/page/ImageHistoryPseudoPager.php +++ b/includes/page/ImageHistoryPseudoPager.php @@ -40,8 +40,8 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { $this->mTitle = clone $imagePage->getTitle(); $this->mTitle->setFragment( '#filehistory' ); $this->mImg = null; - $this->mHist = array(); - $this->mRange = array( 0, 0 ); // display range + $this->mHist = []; + $this->mRange = [ 0, 0 ]; // display range } /** @@ -122,7 +122,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { // The current rev may not meet the offset/limit $numRows = count( $this->mHist ); if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) { - $this->mHist = array_merge( array( $this->mImg ), $this->mHist ); + $this->mHist = array_merge( [ $this->mImg ], $this->mHist ); } } else { // The current rev may not meet the offset @@ -148,14 +148,14 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { # Index value of bottom item in the list $lastIndex = $this->mHist[1]->getTimestamp(); # Display range - $this->mRange = array( 1, $numRows - 1 ); + $this->mRange = [ 1, $numRows - 1 ]; } else { # Index value of item past the index $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp(); # Index value of bottom item in the list $lastIndex = $this->mHist[$numRows - 2]->getTimestamp(); # Display range - $this->mRange = array( 0, $numRows - 2 ); + $this->mRange = [ 0, $numRows - 2 ]; } } else { # Setting indexes to an empty string means that they will be @@ -167,7 +167,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { $lastIndex = $this->mIsBackwards ? $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp(); # Display range - $this->mRange = array( 0, $numRows - 1 ); + $this->mRange = [ 0, $numRows - 1 ]; } } else { $firstIndex = ''; diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index d171e89bf8..e569762f43 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -81,7 +81,7 @@ class ImagePage extends Article { $this->fileLoaded = true; $this->displayImg = $img = false; - Hooks::run( 'ImagePageFindFile', array( $this, &$img, &$this->displayImg ) ); + Hooks::run( 'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] ); if ( !$img ) { // not set by hook? $img = wfFindFile( $this->getTitle() ); if ( !$img ) { @@ -164,9 +164,9 @@ class ImagePage extends Article { # NS_FILE is in the user language, but this section (the actual wikitext) # should be in page content language $pageLang = $this->getTitle()->getPageViewLanguage(); - $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content', + $out->addHTML( Xml::openElement( 'div', [ 'id' => 'mw-imagepage-content', 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(), - 'class' => 'mw-content-' . $pageLang->getDir() ) ) ); + 'class' => 'mw-content-' . $pageLang->getDir() ] ) ); parent::view(); @@ -192,7 +192,7 @@ class ImagePage extends Article { // TODO: Cleanup the following $out->addHTML( Xml::element( 'h2', - array( 'id' => 'filelinks' ), + [ 'id' => 'filelinks' ], $this->getContext()->msg( 'imagelinks' )->text() ) . "\n" ); $this->imageDupes(); # @todo FIXME: For some freaky reason, we can't redirect to foreign images. @@ -201,7 +201,7 @@ class ImagePage extends Article { # Allow extensions to add something after the image links $html = ''; - Hooks::run( 'ImagePageAfterImageLinks', array( $this, &$html ) ); + Hooks::run( 'ImagePageAfterImageLinks', [ $this, &$html ] ); if ( $html ) { $out->addHTML( $html ); } @@ -209,10 +209,10 @@ class ImagePage extends Article { if ( $showmeta ) { $out->addHTML( Xml::element( 'h2', - array( 'id' => 'metadata' ), + [ 'id' => 'metadata' ], $this->getContext()->msg( 'metadata' )->text() ) . "\n" ); $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) ); - $out->addModules( array( 'mediawiki.action.view.metadata' ) ); + $out->addModules( [ 'mediawiki.action.view.metadata' ] ); } // Add remote Filepage.css @@ -244,13 +244,13 @@ class ImagePage extends Article { * @return string */ protected function showTOC( $metadata ) { - $r = array( + $r = [ '
  • ' . $this->getContext()->msg( 'file-anchor-link' )->escaped() . '
  • ', '
  • ' . $this->getContext()->msg( 'filehist' )->escaped() . '
  • ', '
  • ' . $this->getContext()->msg( 'imagelinks' )->escaped() . '
  • ', - ); + ]; - Hooks::run( 'ImagePageShowTOC', array( $this, &$r ) ); + Hooks::run( 'ImagePageShowTOC', [ $this, &$r ] ); if ( $metadata ) { $r[] = '
  • ' . @@ -323,10 +323,10 @@ class ImagePage extends Article { # image $page = $request->getIntOrNull( 'page' ); if ( is_null( $page ) ) { - $params = array(); + $params = []; $page = 1; } else { - $params = array( 'page' => $page ); + $params = [ 'page' => $page ]; } $renderLang = $request->getVal( 'lang' ); @@ -347,7 +347,7 @@ class ImagePage extends Article { $filename = wfEscapeWikiText( $this->displayImg->getName() ); $linktext = $filename; - Hooks::run( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) ); + Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$this, &$out ] ); if ( $this->displayImg->allowInlineDisplay() ) { # image @@ -363,7 +363,7 @@ class ImagePage extends Article { $thumbSizes = $this->getThumbSizes( $width_orig, $height_orig ); # Generate thumbnails or thumbnail links as needed... - $otherSizes = array(); + $otherSizes = []; foreach ( $thumbSizes as $size ) { // We include a thumbnail size in the list, if it is // less than or equal to the original size of the image @@ -393,7 +393,7 @@ class ImagePage extends Article { $msgsmall .= ' ' . Html::rawElement( 'span', - array( 'class' => 'mw-filepage-other-resolutions' ), + [ 'class' => 'mw-filepage-other-resolutions' ], $this->getContext()->msg( 'show-big-image-other' ) ->rawParams( $lang->pipeList( $otherSizes ) ) ->params( count( $otherSizes ) ) @@ -416,7 +416,7 @@ class ImagePage extends Article { $anchorclose = Html::rawElement( 'div', - array( 'class' => 'mw-filepage-resolutioninfo' ), + [ 'class' => 'mw-filepage-resolutioninfo' ], $msgsmall ); @@ -427,10 +427,10 @@ class ImagePage extends Article { } if ( $thumbnail ) { - $options = array( + $options = [ 'alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true, - ); + ]; $out->addHTML( '\n" ); @@ -446,8 +446,8 @@ class ImagePage extends Article { $link = Linker::linkKnown( $this->getTitle(), $label, - array(), - array( 'page' => $page - 1 ) + [], + [ 'page' => $page - 1 ] ); $thumb1 = Linker::makeThumbLinkObj( $this->getTitle(), @@ -455,7 +455,7 @@ class ImagePage extends Article { $link, $label, 'none', - array( 'page' => $page - 1 ) + [ 'page' => $page - 1 ] ); } else { $thumb1 = ''; @@ -466,8 +466,8 @@ class ImagePage extends Article { $link = Linker::linkKnown( $this->getTitle(), $label, - array(), - array( 'page' => $page + 1 ) + [], + [ 'page' => $page + 1 ] ); $thumb2 = Linker::makeThumbLinkObj( $this->getTitle(), @@ -475,7 +475,7 @@ class ImagePage extends Article { $link, $label, 'none', - array( 'page' => $page + 1 ) + [ 'page' => $page + 1 ] ); } else { $thumb2 = ''; @@ -483,16 +483,16 @@ class ImagePage extends Article { global $wgScript; - $formParams = array( + $formParams = [ 'name' => 'pageselector', 'action' => $wgScript, - ); - $options = array(); + ]; + $options = []; for ( $i = 1; $i <= $count; $i++ ) { $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page ); } $select = Xml::tags( 'select', - array( 'id' => 'pageselector', 'name' => 'page' ), + [ 'id' => 'pageselector', 'name' => 'page' ], implode( "\n", $options ) ); $out->addHTML( @@ -510,7 +510,7 @@ class ImagePage extends Article { $icon = $this->displayImg->iconThumb(); $out->addHTML( '\n" ); } @@ -597,24 +597,24 @@ EOT # Show deletion log to be consistent with normal articles LogEventsList::showLogExtract( $out, - array( 'delete', 'move' ), + [ 'delete', 'move' ], $this->getTitle()->getPrefixedText(), '', - array( 'lim' => 10, - 'conds' => array( "log_action != 'revision'" ), + [ 'lim' => 10, + 'conds' => [ "log_action != 'revision'" ], 'showIfEmpty' => false, - 'msgKey' => array( 'moveddeleted-notice' ) - ) + 'msgKey' => [ 'moveddeleted-notice' ] + ] ); } if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) { // Only show an upload link if the user can upload $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); - $nofile = array( + $nofile = [ 'filepage-nofile-link', - $uploadTitle->getFullURL( array( 'wpDestFile' => $this->mPage->getFile()->getName() ) ) - ); + $uploadTitle->getFullURL( [ 'wpDestFile' => $this->mPage->getFile()->getName() ] ) + ]; } else { $nofile = 'filepage-nofile'; } @@ -682,10 +682,10 @@ EOT $params['height'] = $height; $thumbnail = $this->displayImg->transform( $params ); if ( $thumbnail && !$thumbnail->isError() ) { - return Html::rawElement( 'a', array( + return Html::rawElement( 'a', [ 'href' => $thumbnail->getUrl(), 'class' => 'mw-thumbnail-link' - ), $this->getContext()->msg( 'show-big-image-size' )->numParams( + ], $this->getContext()->msg( 'show-big-image-size' )->numParams( $thumbnail->getWidth(), $thumbnail->getHeight() )->parse() ); } else { @@ -715,13 +715,13 @@ EOT $descText && $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-' ) { - $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) ); + $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-here', $repo, $descUrl ] ); } elseif ( $descUrl && $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-' ) { - $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) ); + $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-there', $repo, $descUrl ] ); } else { - $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ ); + $out->wrapWikiMsg( $wrap, [ 'sharedupload', $repo ], ''/*BACKCOMPAT*/ ); } if ( $descText ) { @@ -732,10 +732,10 @@ EOT public function getUploadUrl() { $this->loadFile(); $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); - return $uploadTitle->getFullURL( array( + return $uploadTitle->getFullURL( [ 'wpDestFile' => $this->mPage->getFile()->getName(), 'wpForReUpload' => 1 - ) ); + ] ); } /** @@ -812,11 +812,11 @@ EOT $dbr = wfGetDB( DB_SLAVE ); return $dbr->select( - array( 'imagelinks', 'page' ), - array( 'page_namespace', 'page_title', 'il_to' ), - array( 'il_to' => $target, 'il_from = page_id' ), + [ 'imagelinks', 'page' ], + [ 'page_namespace', 'page_title', 'il_to' ], + [ 'il_to' => $target, 'il_from = page_id' ], __METHOD__, - array( 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', ) + [ 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', ] ); } @@ -825,14 +825,14 @@ EOT $out = $this->getContext()->getOutput(); - $rows = array(); - $redirects = array(); + $rows = []; + $redirects = []; foreach ( $this->getTitle()->getRedirectsHere( NS_FILE ) as $redir ) { - $redirects[$redir->getDBkey()] = array(); - $rows[] = (object)array( + $redirects[$redir->getDBkey()] = []; + $rows[] = (object)[ 'page_namespace' => NS_FILE, 'page_title' => $redir->getDBkey(), - ); + ]; } $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 ); @@ -855,7 +855,7 @@ EOT if ( $count == 0 ) { $out->wrapWikiMsg( Html::rawElement( 'div', - array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ), + [ 'id' => 'mw-imagepage-nolinkstoimage' ], "\n$1\n" ), 'nolinkstoimage' ); return; @@ -874,12 +874,12 @@ EOT $out->addHTML( Html::openElement( 'ul', - array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n" + [ 'class' => 'mw-imagepage-linkstoimage' ] ) . "\n" ); $count = 0; // Sort the list by namespace:title - usort( $rows, array( $this, 'compare' ) ); + usort( $rows, [ $this, 'compare' ] ); // Create links for every element $currentCount = 0; @@ -889,14 +889,14 @@ EOT break; } - $query = array(); + $query = []; # Add a redirect=no to make redirect pages reachable if ( isset( $redirects[$element->page_title] ) ) { $query['redirect'] = 'no'; } $link = Linker::linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ), - null, array(), $query + null, [], $query ); if ( !isset( $redirects[$element->page_title] ) ) { # No redirects @@ -918,14 +918,14 @@ EOT $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) ); $li .= Html::rawElement( 'li', - array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ), + [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ], $link2 ) . "\n"; } $ul = Html::rawElement( 'ul', - array( 'class' => 'mw-imagepage-redirectstofile' ), + [ 'class' => 'mw-imagepage-redirectstofile' ], $li ) . "\n"; $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams( @@ -933,7 +933,7 @@ EOT } $out->addHTML( Html::rawElement( 'li', - array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ), + [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ], $liContents ) . "\n" ); @@ -1054,7 +1054,7 @@ EOT return isset( $wgImageLimits[$option] ) ? $wgImageLimits[$option] - : array( 800, 600 ); // if nothing is set, fallback to a hardcoded default + : [ 800, 600 ]; // if nothing is set, fallback to a hardcoded default } /** @@ -1117,7 +1117,7 @@ EOT $select = Html::rawElement( 'select', - array( 'id' => 'mw-imglangselector', 'name' => 'lang' ), + [ 'id' => 'mw-imglangselector', 'name' => 'lang' ], $opts ); $submit = Xml::submitButton( $this->getContext()->msg( 'img-lang-go' )->text() ); @@ -1127,8 +1127,8 @@ EOT ->parse(); $formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ); - $langSelectLine = Html::rawElement( 'div', array( 'id' => 'mw-imglangselector-line' ), - Html::rawElement( 'form', array( 'action' => $wgScript ), $formContents ) + $langSelectLine = Html::rawElement( 'div', [ 'id' => 'mw-imglangselector-line' ], + Html::rawElement( 'form', [ 'action' => $wgScript ], $formContents ) ); return $langSelectLine; } @@ -1154,7 +1154,7 @@ EOT } if ( !$width || !$height ) { - return array( 0, 0 ); + return [ 0, 0 ]; } # Calculate the thumbnail size. @@ -1172,7 +1172,7 @@ EOT # Note that $height <= $maxHeight now, but might not be identical # because of rounding. } - return array( $width, $height ); + return [ $width, $height ]; } /** @@ -1193,17 +1193,17 @@ EOT // that we mustRender, some users have indicated that they would // find it useful to have the full size image in the rendered // image format. - $thumbSizes[] = array( $origWidth, $origHeight ); + $thumbSizes[] = [ $origWidth, $origHeight ]; } else { # Creating thumb links triggers thumbnail generation. # Just generate the thumb for the current users prefs. - $thumbSizes = array( + $thumbSizes = [ $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' ) - ); + ]; if ( !$this->displayImg->mustRender() ) { // We can safely include a link to the "full-size" preview, // without actually rendering. - $thumbSizes[] = array( $origWidth, $origHeight ); + $thumbSizes[] = [ $origWidth, $origHeight ]; } } return $thumbSizes; diff --git a/includes/page/WikiFilePage.php b/includes/page/WikiFilePage.php index 92a14afa95..a6b991588d 100644 --- a/includes/page/WikiFilePage.php +++ b/includes/page/WikiFilePage.php @@ -137,7 +137,7 @@ class WikiFilePage extends WikiPage { } $hash = $this->mFile->getSha1(); if ( !( $hash ) ) { - $this->mDupes = array(); + $this->mDupes = []; return $this->mDupes; } $dupes = RepoGroup::singleton()->findBySha1( $hash ); @@ -171,13 +171,13 @@ class WikiFilePage extends WikiPage { wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" ); DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) ); $this->mFile->upgradeRow(); - $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) ); + $this->mFile->purgeCache( [ 'forThumbRefresh' => true ] ); } else { wfDebug( 'ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n" ); // even if the file supposedly doesn't exist, force any cached information // to be updated (in case the cached information is wrong) - $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) ); + $this->mFile->purgeCache( [ 'forThumbRefresh' => true ] ); } if ( $this->mRepo ) { // Purge redirect cache @@ -202,7 +202,7 @@ class WikiFilePage extends WikiPage { if ( !$file instanceof LocalFile ) { wfDebug( __CLASS__ . '::' . __METHOD__ . " is not supported for this file\n" ); - return TitleArray::newFromResult( new FakeResultWrapper( array() ) ); + return TitleArray::newFromResult( new FakeResultWrapper( [] ) ); } /** @var LocalRepo $repo */ @@ -210,18 +210,18 @@ class WikiFilePage extends WikiPage { $dbr = $repo->getSlaveDB(); $res = $dbr->select( - array( 'page', 'categorylinks' ), - array( + [ 'page', 'categorylinks' ], + [ 'page_title' => 'cl_to', 'page_namespace' => NS_CATEGORY, - ), - array( + ], + [ 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), - ), + ], __METHOD__, - array(), - array( 'categorylinks' => array( 'INNER JOIN', 'page_id = cl_from' ) ) + [], + [ 'categorylinks' => [ 'INNER JOIN', 'page_id = cl_from' ] ] ); return TitleArray::newFromResult( $res ); diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index cfd8d6bf8e..330889081d 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -144,7 +144,7 @@ class WikiPage implements Page, IDBAccessObject { $from = self::convertSelectType( $from ); $db = wfGetDB( $from === self::READ_LATEST ? DB_MASTER : DB_SLAVE ); $row = $db->selectRow( - 'page', self::selectFields(), array( 'page_id' => $id ), __METHOD__ ); + 'page', self::selectFields(), [ 'page_id' => $id ], __METHOD__ ); if ( !$row ) { return null; } @@ -272,7 +272,7 @@ class WikiPage implements Page, IDBAccessObject { public static function selectFields() { global $wgContentHandlerUseDB, $wgPageLanguageUseDB; - $fields = array( + $fields = [ 'page_id', 'page_namespace', 'page_title', @@ -284,7 +284,7 @@ class WikiPage implements Page, IDBAccessObject { 'page_links_updated', 'page_latest', 'page_len', - ); + ]; if ( $wgContentHandlerUseDB ) { $fields[] = 'page_content_model'; @@ -304,14 +304,14 @@ class WikiPage implements Page, IDBAccessObject { * @param array $options * @return object|bool Database result resource, or false on failure */ - protected function pageData( $dbr, $conditions, $options = array() ) { + protected function pageData( $dbr, $conditions, $options = [] ) { $fields = self::selectFields(); - Hooks::run( 'ArticlePageDataBefore', array( &$this, &$fields ) ); + Hooks::run( 'ArticlePageDataBefore', [ &$this, &$fields ] ); $row = $dbr->selectRow( 'page', $fields, $conditions, __METHOD__, $options ); - Hooks::run( 'ArticlePageDataAfter', array( &$this, &$row ) ); + Hooks::run( 'ArticlePageDataAfter', [ &$this, &$row ] ); return $row; } @@ -325,10 +325,10 @@ class WikiPage implements Page, IDBAccessObject { * @param array $options * @return object|bool Database result resource, or false on failure */ - public function pageDataFromTitle( $dbr, $title, $options = array() ) { - return $this->pageData( $dbr, array( + public function pageDataFromTitle( $dbr, $title, $options = [] ) { + return $this->pageData( $dbr, [ 'page_namespace' => $title->getNamespace(), - 'page_title' => $title->getDBkey() ), $options ); + 'page_title' => $title->getDBkey() ], $options ); } /** @@ -339,8 +339,8 @@ class WikiPage implements Page, IDBAccessObject { * @param array $options * @return object|bool Database result resource, or false on failure */ - public function pageDataFromId( $dbr, $id, $options = array() ) { - return $this->pageData( $dbr, array( 'page_id' => $id ), $options ); + public function pageDataFromId( $dbr, $id, $options = [] ) { + return $this->pageData( $dbr, [ 'page_id' => $id ], $options ); } /** @@ -562,17 +562,17 @@ class WikiPage implements Page, IDBAccessObject { $row = null; while ( $continue ) { $row = $db->selectRow( - array( 'page', 'revision' ), + [ 'page', 'revision' ], $revSelectFields, - array( + [ 'page_namespace' => $this->mTitle->getNamespace(), 'page_title' => $this->mTitle->getDBkey(), 'rev_page = page_id' - ), + ], __METHOD__, - array( + [ 'ORDER BY' => 'rev_timestamp ASC' - ) + ] ); if ( $row ) { @@ -834,7 +834,7 @@ class WikiPage implements Page, IDBAccessObject { $hasLinks = (bool)count( $editInfo->output->getLinks() ); } else { $hasLinks = (bool)wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1, - array( 'pl_from' => $this->getId() ), __METHOD__ ); + [ 'pl_from' => $this->getId() ], __METHOD__ ); } } @@ -860,8 +860,8 @@ class WikiPage implements Page, IDBAccessObject { // Query the redirect table $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'redirect', - array( 'rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki' ), - array( 'rd_from' => $this->getId() ), + [ 'rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki' ], + [ 'rd_from' => $this->getId() ], __METHOD__ ); @@ -915,14 +915,14 @@ class WikiPage implements Page, IDBAccessObject { if ( !$oldLatest || $oldLatest == $this->lockAndGetLatest() ) { $dbw->replace( 'redirect', - array( 'rd_from' ), - array( + [ 'rd_from' ], + [ 'rd_from' => $this->getId(), 'rd_namespace' => $rt->getNamespace(), 'rd_title' => $rt->getDBkey(), 'rd_fragment' => $rt->getFragment(), 'rd_interwiki' => $rt->getInterwiki(), - ), + ], __METHOD__ ); } @@ -957,7 +957,7 @@ class WikiPage implements Page, IDBAccessObject { // This can be hard to reverse and may produce loops, // so they may be disabled in the site configuration. $source = $this->mTitle->getFullURL( 'redirect=no' ); - return $rt->getFullURL( array( 'rdfrom' => $source ) ); + return $rt->getFullURL( [ 'rdfrom' => $source ] ); } else { // External pages without "local" bit set are not valid // redirect targets @@ -995,16 +995,16 @@ class WikiPage implements Page, IDBAccessObject { $realNameField = 'MIN(user_real_name) AS user_real_name'; } - $tables = array( 'revision', 'user' ); + $tables = [ 'revision', 'user' ]; - $fields = array( + $fields = [ 'user_id' => 'rev_user', 'user_name' => 'rev_user_text', $realNameField, 'timestamp' => 'MAX(rev_timestamp)', - ); + ]; - $conds = array( 'rev_page' => $this->getId() ); + $conds = [ 'rev_page' => $this->getId() ]; // The user who made the top revision gets credited as "this page was last edited by // John, based on contributions by Tom, Dick and Harry", so don't include them twice. @@ -1018,14 +1018,14 @@ class WikiPage implements Page, IDBAccessObject { // Username hidden? $conds[] = "{$dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER )} = 0"; - $jconds = array( - 'user' => array( 'LEFT JOIN', 'rev_user = user_id' ), - ); + $jconds = [ + 'user' => [ 'LEFT JOIN', 'rev_user = user_id' ], + ]; - $options = array( - 'GROUP BY' => array( 'rev_user', 'rev_user_text' ), + $options = [ + 'GROUP BY' => [ 'rev_user', 'rev_user_text' ], 'ORDER BY' => 'timestamp DESC', - ); + ]; $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $jconds ); return new UserArrayFromResult( $res ); @@ -1094,7 +1094,7 @@ class WikiPage implements Page, IDBAccessObject { return; } - Hooks::run( 'PageViewUpdates', array( $this, $user ) ); + Hooks::run( 'PageViewUpdates', [ $this, $user ] ); // Update newtalk / watchlist notification status try { $user->clearNotification( $this->mTitle, $oldid ); @@ -1109,7 +1109,7 @@ class WikiPage implements Page, IDBAccessObject { * @return bool */ public function doPurge() { - if ( !Hooks::run( 'ArticlePurge', array( &$this ) ) ) { + if ( !Hooks::run( 'ArticlePurge', [ &$this ] ) ) { return false; } @@ -1163,7 +1163,7 @@ class WikiPage implements Page, IDBAccessObject { $pageIdForInsert = $pageId ?: $dbw->nextSequenceValue( 'page_page_id_seq' ); $dbw->insert( 'page', - array( + [ 'page_id' => $pageIdForInsert, 'page_namespace' => $this->mTitle->getNamespace(), 'page_title' => $this->mTitle->getDBkey(), @@ -1174,7 +1174,7 @@ class WikiPage implements Page, IDBAccessObject { 'page_touched' => $dbw->timestamp(), 'page_latest' => 0, // Fill this in shortly... 'page_len' => 0, // Fill this in shortly... - ), + ], __METHOD__, 'IGNORE' ); @@ -1219,20 +1219,20 @@ class WikiPage implements Page, IDBAccessObject { $len = $content ? $content->getSize() : 0; $rt = $content ? $content->getUltimateRedirectTarget() : null; - $conditions = array( 'page_id' => $this->getId() ); + $conditions = [ 'page_id' => $this->getId() ]; if ( !is_null( $lastRevision ) ) { // An extra check against threads stepping on each other $conditions['page_latest'] = $lastRevision; } - $row = array( /* SET */ + $row = [ /* SET */ 'page_latest' => $revision->getId(), 'page_touched' => $dbw->timestamp( $revision->getTimestamp() ), 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0, 'page_is_redirect' => $rt !== null ? 1 : 0, 'page_len' => $len, - ); + ]; if ( $wgContentHandlerUseDB ) { $row['page_content_model'] = $revision->getContentModel(); @@ -1288,7 +1288,7 @@ class WikiPage implements Page, IDBAccessObject { $this->insertRedirectEntry( $redirectTitle ); } else { // This is not a redirect, remove row from redirect table - $where = array( 'rd_from' => $this->getId() ); + $where = [ 'rd_from' => $this->getId() ]; $dbw->delete( 'redirect', $where, __METHOD__ ); } @@ -1312,11 +1312,11 @@ class WikiPage implements Page, IDBAccessObject { public function updateIfNewerOn( $dbw, $revision ) { $row = $dbw->selectRow( - array( 'revision', 'page' ), - array( 'rev_id', 'rev_timestamp', 'page_is_redirect' ), - array( + [ 'revision', 'page' ], + [ 'rev_id', 'rev_timestamp', 'page_is_redirect' ], + [ 'page_id' => $this->getId(), - 'page_latest=rev_id' ), + 'page_latest=rev_id' ], __METHOD__ ); if ( $row ) { @@ -1685,9 +1685,9 @@ class WikiPage implements Page, IDBAccessObject { $flags = $this->checkFlags( $flags ); // Trigger pre-save hook (using provided edit summary) - $hookStatus = Status::newGood( array() ); - $hook_args = array( &$this, &$user, &$content, &$summary, - $flags & EDIT_MINOR, null, null, &$flags, &$hookStatus ); + $hookStatus = Status::newGood( [] ); + $hook_args = [ &$this, &$user, &$content, &$summary, + $flags & EDIT_MINOR, null, null, &$flags, &$hookStatus ]; // Check if the hook rejected the attempted save if ( !Hooks::run( 'PageContentSave', $hook_args ) || !ContentHandler::runLegacyHooks( 'ArticleSave', $hook_args ) @@ -1712,7 +1712,7 @@ class WikiPage implements Page, IDBAccessObject { // Get the pre-save transform content and final parser output $editInfo = $this->prepareContentForEdit( $content, null, $user, $serialFormat ); $pstContent = $editInfo->pstContent; // Content object - $meta = array( + $meta = [ 'bot' => ( $flags & EDIT_FORCE_BOT ), 'minor' => ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' ), 'serialized' => $editInfo->pst, @@ -1723,8 +1723,8 @@ class WikiPage implements Page, IDBAccessObject { 'oldId' => $this->getLatest(), 'oldIsRedirect' => $this->isRedirect(), 'oldCountable' => $this->isCountable(), - 'tags' => ( $tags !== null ) ? (array)$tags : array() - ); + 'tags' => ( $tags !== null ) ? (array)$tags : [] + ]; // Actually create the revision and create/update the page if ( $flags & EDIT_UPDATE ) { @@ -1760,7 +1760,7 @@ class WikiPage implements Page, IDBAccessObject { global $wgUseRCPatrol; // Update article, but only if changed. - $status = Status::newGood( array( 'new' => false, 'revision' => null ) ); + $status = Status::newGood( [ 'new' => false, 'revision' => null ] ); // Convenience variables $now = wfTimestampNow(); @@ -1780,7 +1780,7 @@ class WikiPage implements Page, IDBAccessObject { } // @TODO: pass content object?! - $revision = new Revision( array( + $revision = new Revision( [ 'page' => $this->getId(), 'title' => $this->mTitle, // for determining the default content model 'comment' => $summary, @@ -1793,7 +1793,7 @@ class WikiPage implements Page, IDBAccessObject { 'timestamp' => $now, 'content_model' => $content->getModel(), 'content_format' => $meta['serialFormat'], - ) ); + ] ); $changed = !$content->equals( $oldContent ); @@ -1833,7 +1833,7 @@ class WikiPage implements Page, IDBAccessObject { } Hooks::run( 'NewRevisionFromEditComplete', - array( $this, $revision, $meta['baseRevId'], $user ) ); + [ $this, $revision, $meta['baseRevId'], $user ] ); // Update recentchanges if ( !( $flags & EDIT_SUPPRESS_RC ) ) { @@ -1892,15 +1892,15 @@ class WikiPage implements Page, IDBAccessObject { $that->doEditUpdates( $revision, $user, - array( + [ 'changed' => $changed, 'oldcountable' => $meta['oldCountable'], 'oldrevision' => $meta['oldRevision'] - ) + ] ); // Trigger post-save hook - $params = array( &$that, &$user, $content, $summary, $flags & EDIT_MINOR, - null, null, &$flags, $revision, &$status, $meta['baseRevId'] ); + $params = [ &$that, &$user, $content, $summary, $flags & EDIT_MINOR, + null, null, &$flags, $revision, &$status, $meta['baseRevId'] ]; ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); Hooks::run( 'PageContentSaveComplete', $params ); } @@ -1926,7 +1926,7 @@ class WikiPage implements Page, IDBAccessObject { ) { global $wgUseRCPatrol, $wgUseNPPatrol; - $status = Status::newGood( array( 'new' => true, 'revision' => null ) ); + $status = Status::newGood( [ 'new' => true, 'revision' => null ] ); $now = wfTimestampNow(); $newsize = $content->getSize(); @@ -1954,7 +1954,7 @@ class WikiPage implements Page, IDBAccessObject { // unless they actually try to catch exceptions (which is rare). // @TODO: pass content object?! - $revision = new Revision( array( + $revision = new Revision( [ 'page' => $newid, 'title' => $this->mTitle, // for determining the default content model 'comment' => $summary, @@ -1966,7 +1966,7 @@ class WikiPage implements Page, IDBAccessObject { 'timestamp' => $now, 'content_model' => $content->getModel(), 'content_format' => $meta['serialFormat'], - ) ); + ] ); // Save the revision text... $revisionId = $revision->insertOn( $dbw ); @@ -1976,7 +1976,7 @@ class WikiPage implements Page, IDBAccessObject { throw new MWException( "Failed to update page row to use new revision." ); } - Hooks::run( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) ); + Hooks::run( 'NewRevisionFromEditComplete', [ $this, $revision, false, $user ] ); // Update recentchanges if ( !( $flags & EDIT_SUPPRESS_RC ) ) { @@ -2016,14 +2016,14 @@ class WikiPage implements Page, IDBAccessObject { // Do per-page updates in a transaction $dbw->setFlag( DBO_TRX ); // Update links, etc. - $that->doEditUpdates( $revision, $user, array( 'created' => true ) ); + $that->doEditUpdates( $revision, $user, [ 'created' => true ] ); // Trigger post-create hook - $params = array( &$that, &$user, $content, $summary, - $flags & EDIT_MINOR, null, null, &$flags, $revision ); + $params = [ &$that, &$user, $content, $summary, + $flags & EDIT_MINOR, null, null, &$flags, $revision ]; ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params ); Hooks::run( 'PageContentInsertComplete', $params ); // Trigger post-save hook - $params = array_merge( $params, array( &$status, $meta['baseRevId'] ) ); + $params = array_merge( $params, [ &$status, $meta['baseRevId'] ] ); ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); Hooks::run( 'PageContentSaveComplete', $params ); @@ -2134,9 +2134,9 @@ class WikiPage implements Page, IDBAccessObject { : false; $popts = ParserOptions::newFromUserAndLang( $user, $wgContLang ); - Hooks::run( 'ArticlePrepareTextForEdit', array( $this, $popts ) ); + Hooks::run( 'ArticlePrepareTextForEdit', [ $this, $popts ] ); - $edit = (object)array(); + $edit = (object)[]; if ( $cachedEdit ) { $edit->timestamp = $cachedEdit->timestamp; } else { @@ -2216,17 +2216,17 @@ class WikiPage implements Page, IDBAccessObject { * is true, do update the article count * - 'no-change': don't update the article count, ever */ - public function doEditUpdates( Revision $revision, User $user, array $options = array() ) { + public function doEditUpdates( Revision $revision, User $user, array $options = [] ) { global $wgRCWatchCategoryMembership, $wgContLang; - $options += array( + $options += [ 'changed' => true, 'created' => false, 'moved' => false, 'restored' => false, 'oldrevision' => null, 'oldcountable' => null - ); + ]; $content = $revision->getContent(); // Parse the text @@ -2269,17 +2269,17 @@ class WikiPage implements Page, IDBAccessObject { // bot/deletion/IP flags, ect. JobQueueGroup::singleton()->lazyPush( new CategoryMembershipChangeJob( $this->getTitle(), - array( + [ 'pageId' => $this->getId(), 'revTimestamp' => $revision->getTimestamp() - ) + ] ) ); } } - Hooks::run( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) ); + Hooks::run( 'ArticleEditUpdates', [ &$this, &$editInfo, $options['changed'] ] ); - if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { + if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', [ &$this ] ) ) { // Flush old entries from the `recentchanges` table if ( mt_rand( 0, 9 ) == 0 ) { JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newPurgeJob() ); @@ -2325,7 +2325,7 @@ class WikiPage implements Page, IDBAccessObject { } else { // Allow extensions to prevent user notification // when a new message is added to their talk page - if ( Hooks::run( 'ArticleEditUpdateNewTalk', array( &$this, $recipient ) ) ) { + if ( Hooks::run( 'ArticleEditUpdateNewTalk', [ &$this, $recipient ] ) ) { if ( User::isIP( $shortTitle ) ) { // An anonymous user $recipient->setNewtalk( true, $revision ); @@ -2377,7 +2377,7 @@ class WikiPage implements Page, IDBAccessObject { $serialized = $content->serialize( $serialFormat ); $dbw = wfGetDB( DB_MASTER ); - $revision = new Revision( array( + $revision = new Revision( [ 'title' => $this->getTitle(), // for determining the default content model 'page' => $this->getId(), 'user_text' => $user->getName(), @@ -2386,11 +2386,11 @@ class WikiPage implements Page, IDBAccessObject { 'length' => $content->getSize(), 'comment' => $comment, 'minor_edit' => $minor ? 1 : 0, - ) ); // XXX: set the content object? + ] ); // XXX: set the content object? $revision->insertOn( $dbw ); $this->updateRevisionOn( $dbw, $revision ); - Hooks::run( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) ); + Hooks::run( 'NewRevisionFromEditComplete', [ $this, $revision, false, $user ] ); } @@ -2484,18 +2484,18 @@ class WikiPage implements Page, IDBAccessObject { // Truncate for whole multibyte characters $reason = $wgContLang->truncate( $reason, 255 ); - $logRelationsValues = array(); + $logRelationsValues = []; $logRelationsField = null; - $logParamsDetails = array(); + $logParamsDetails = []; if ( $id ) { // Protection of existing page - if ( !Hooks::run( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) { + if ( !Hooks::run( 'ArticleProtect', [ &$this, &$user, $limit, $reason ] ) ) { return Status::newGood(); } // Only certain restrictions can cascade... $editrestriction = isset( $limit['edit'] ) - ? array( $limit['edit'] ) + ? [ $limit['edit'] ] : $this->mTitle->getRestrictions( 'edit' ); foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) { $editrestriction[$key] = 'editprotected'; // backwards compatibility @@ -2538,55 +2538,55 @@ class WikiPage implements Page, IDBAccessObject { foreach ( $limit as $action => $restrictions ) { $dbw->delete( 'page_restrictions', - array( + [ 'pr_page' => $id, 'pr_type' => $action - ), + ], __METHOD__ ); if ( $restrictions != '' ) { $cascadeValue = ( $cascade && $action == 'edit' ) ? 1 : 0; $dbw->insert( 'page_restrictions', - array( + [ 'pr_id' => $dbw->nextSequenceValue( 'page_restrictions_pr_id_seq' ), 'pr_page' => $id, 'pr_type' => $action, 'pr_level' => $restrictions, 'pr_cascade' => $cascadeValue, 'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] ) - ), + ], __METHOD__ ); $logRelationsValues[] = $dbw->insertId(); - $logParamsDetails[] = array( + $logParamsDetails[] = [ 'type' => $action, 'level' => $restrictions, 'expiry' => $expiry[$action], 'cascade' => (bool)$cascadeValue, - ); + ]; } } // Clear out legacy restriction fields $dbw->update( 'page', - array( 'page_restrictions' => '' ), - array( 'page_id' => $id ), + [ 'page_restrictions' => '' ], + [ 'page_id' => $id ], __METHOD__ ); Hooks::run( 'NewRevisionFromEditComplete', - array( $this, $nullRevision, $latest, $user ) ); - Hooks::run( 'ArticleProtectComplete', array( &$this, &$user, $limit, $reason ) ); + [ $this, $nullRevision, $latest, $user ] ); + Hooks::run( 'ArticleProtectComplete', [ &$this, &$user, $limit, $reason ] ); } else { // Protection of non-existing page (also known as "title protection") // Cascade protection is meaningless in this case $cascade = false; if ( $limit['create'] != '' ) { $dbw->replace( 'protected_titles', - array( array( 'pt_namespace', 'pt_title' ) ), - array( + [ [ 'pt_namespace', 'pt_title' ] ], + [ 'pt_namespace' => $this->mTitle->getNamespace(), 'pt_title' => $this->mTitle->getDBkey(), 'pt_create_perm' => $limit['create'], @@ -2594,19 +2594,19 @@ class WikiPage implements Page, IDBAccessObject { 'pt_expiry' => $dbw->encodeExpiry( $expiry['create'] ), 'pt_user' => $user->getId(), 'pt_reason' => $reason, - ), __METHOD__ + ], __METHOD__ ); - $logParamsDetails[] = array( + $logParamsDetails[] = [ 'type' => 'create', 'level' => $limit['create'], 'expiry' => $expiry['create'], - ); + ]; } else { $dbw->delete( 'protected_titles', - array( + [ 'pt_namespace' => $this->mTitle->getNamespace(), 'pt_title' => $this->mTitle->getDBkey() - ), __METHOD__ + ], __METHOD__ ); } } @@ -2615,14 +2615,14 @@ class WikiPage implements Page, IDBAccessObject { InfoAction::invalidateCache( $this->mTitle ); if ( $logAction == 'unprotect' ) { - $params = array(); + $params = []; } else { $protectDescriptionLog = $this->protectDescriptionLog( $limit, $expiry ); - $params = array( + $params = [ '4::description' => $protectDescriptionLog, // parameter for IRC '5:bool:cascade' => $cascade, 'details' => $logParamsDetails, // parameter for localize and api - ); + ]; } // Update the protection log @@ -2632,7 +2632,7 @@ class WikiPage implements Page, IDBAccessObject { $logEntry->setPerformer( $user ); $logEntry->setParameters( $params ); if ( $logRelationsField !== null && count( $logRelationsValues ) ) { - $logEntry->setRelations( array( $logRelationsField => $logRelationsValues ) ); + $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] ); } $logId = $logEntry->insert(); $logEntry->publish( $logId ); @@ -2789,7 +2789,7 @@ class WikiPage implements Page, IDBAccessObject { throw new MWException( __METHOD__ . ' given non-array restriction set' ); } - $bits = array(); + $bits = []; ksort( $limit ); foreach ( array_filter( $limit ) as $action => $restrictions ) { @@ -2856,7 +2856,7 @@ class WikiPage implements Page, IDBAccessObject { $user = is_null( $user ) ? $wgUser : $user; if ( !Hooks::run( 'ArticleDelete', - array( &$this, &$user, &$reason, &$error, &$status, $suppress ) + [ &$this, &$user, &$reason, &$error, &$status, $suppress ] ) ) { if ( $status->isOK() ) { // Hook aborted but didn't set a fatal status @@ -2916,7 +2916,7 @@ class WikiPage implements Page, IDBAccessObject { * the rev_deleted field, which is reserved for this purpose. */ - $row = array( + $row = [ 'ar_namespace' => 'page_namespace', 'ar_title' => 'page_title', 'ar_comment' => 'rev_comment', @@ -2933,7 +2933,7 @@ class WikiPage implements Page, IDBAccessObject { 'ar_page_id' => 'page_id', 'ar_deleted' => $bitfield, 'ar_sha1' => 'rev_sha1', - ); + ]; if ( $wgContentHandlerUseDB ) { $row['ar_content_model'] = 'rev_content_model'; @@ -2943,20 +2943,20 @@ class WikiPage implements Page, IDBAccessObject { // Copy all the page revisions into the archive table $dbw->insertSelect( 'archive', - array( 'page', 'revision' ), + [ 'page', 'revision' ], $row, - array( + [ 'page_id' => $id, 'page_id = rev_page' - ), + ], __METHOD__ ); // Now that it's safely backed up, delete it - $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ ); + $dbw->delete( 'page', [ 'page_id' => $id ], __METHOD__ ); if ( !$dbw->cascadingDeletes() ) { - $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ ); + $dbw->delete( 'revision', [ 'rev_page' => $id ], __METHOD__ ); } // Clone the title, so we have the information we need when we log @@ -2981,7 +2981,7 @@ class WikiPage implements Page, IDBAccessObject { $this->doDeleteUpdates( $id, $content ); Hooks::run( 'ArticleDeleteComplete', - array( &$this, &$user, $reason, $id, $content, $logEntry ) ); + [ &$this, &$user, $reason, $id, $content, $logEntry ] ); $status->value = $logid; // Show log excerpt on 404 pages rather than just a link @@ -3002,15 +3002,15 @@ class WikiPage implements Page, IDBAccessObject { return (int)wfGetDB( DB_MASTER )->selectField( 'page', 'page_latest', - array( + [ 'page_id' => $this->getId(), // Typically page_id is enough, but some code might try to do // updates assuming the title is the same, so verify that 'page_namespace' => $this->getTitle()->getNamespace(), 'page_title' => $this->getTitle()->getDBkey() - ), + ], __METHOD__, - array( 'FOR UPDATE' ) + [ 'FOR UPDATE' ] ); } @@ -3088,12 +3088,12 @@ class WikiPage implements Page, IDBAccessObject { $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $user ); $errors = array_merge( $editErrors, wfArrayDiff2( $rollbackErrors, $editErrors ) ); - if ( !$user->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) { - $errors[] = array( 'sessionfailure' ); + if ( !$user->matchEditToken( $token, [ $this->mTitle->getPrefixedText(), $fromP ] ) ) { + $errors[] = [ 'sessionfailure' ]; } if ( $user->pingLimiter( 'rollback' ) || $user->pingLimiter() ) { - $errors[] = array( 'actionthrottledtext' ); + $errors[] = [ 'actionthrottledtext' ]; } // If there were errors, bail out now @@ -3132,26 +3132,26 @@ class WikiPage implements Page, IDBAccessObject { $dbw = wfGetDB( DB_MASTER ); if ( wfReadOnly() ) { - return array( array( 'readonlytext' ) ); + return [ [ 'readonlytext' ] ]; } // Get the last editor $current = $this->getRevision(); if ( is_null( $current ) ) { // Something wrong... no page? - return array( array( 'notanarticle' ) ); + return [ [ 'notanarticle' ] ]; } $from = str_replace( '_', ' ', $fromP ); // User name given should match up with the top revision. // If the user was deleted then $from should be empty. if ( $from != $current->getUserText() ) { - $resultDetails = array( 'current' => $current ); - return array( array( 'alreadyrolled', + $resultDetails = [ 'current' => $current ]; + return [ [ 'alreadyrolled', htmlspecialchars( $this->mTitle->getPrefixedText() ), htmlspecialchars( $fromP ), htmlspecialchars( $current->getUserText() ) - ) ); + ] ]; } // Get the last edit not by this person... @@ -3159,21 +3159,21 @@ class WikiPage implements Page, IDBAccessObject { $user = intval( $current->getUser( Revision::RAW ) ); $user_text = $dbw->addQuotes( $current->getUserText( Revision::RAW ) ); $s = $dbw->selectRow( 'revision', - array( 'rev_id', 'rev_timestamp', 'rev_deleted' ), - array( 'rev_page' => $current->getPage(), + [ 'rev_id', 'rev_timestamp', 'rev_deleted' ], + [ 'rev_page' => $current->getPage(), "rev_user != {$user} OR rev_user_text != {$user_text}" - ), __METHOD__, - array( 'USE INDEX' => 'page_timestamp', - 'ORDER BY' => 'rev_timestamp DESC' ) + ], __METHOD__, + [ 'USE INDEX' => 'page_timestamp', + 'ORDER BY' => 'rev_timestamp DESC' ] ); if ( $s === false ) { // No one else ever edited this page - return array( array( 'cantrollback' ) ); + return [ [ 'cantrollback' ] ]; } elseif ( $s->rev_deleted & Revision::DELETED_TEXT || $s->rev_deleted & Revision::DELETED_USER ) { // Only admins can see this text - return array( array( 'notvisiblerev' ) ); + return [ [ 'notvisiblerev' ] ]; } // Generate the edit summary if necessary @@ -3187,11 +3187,11 @@ class WikiPage implements Page, IDBAccessObject { } // Allow the custom summary to use the same args as the default message - $args = array( + $args = [ $target->getUserText(), $from, $s->rev_id, $wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ), $current->getId(), $wgContLang->timeanddate( $current->getTimestamp() ) - ); + ]; if ( $summary instanceof Message ) { $summary = $summary->params( $args )->inContentLanguage()->text(); } else { @@ -3228,7 +3228,7 @@ class WikiPage implements Page, IDBAccessObject { // Set patrolling and bot flag on the edits, which gets rollbacked. // This is done even on edit failure to have patrolling in that case (bug 62157). - $set = array(); + $set = []; if ( $bot && $guser->isAllowed( 'markbotedits' ) ) { // Mark all reverted edits as bot $set['rc_bot'] = 1; @@ -3241,11 +3241,11 @@ class WikiPage implements Page, IDBAccessObject { if ( count( $set ) ) { $dbw->update( 'recentchanges', $set, - array( /* WHERE */ + [ /* WHERE */ 'rc_cur_id' => $current->getPage(), 'rc_user_text' => $current->getUserText(), 'rc_timestamp > ' . $dbw->addQuotes( $s->rev_timestamp ), - ), + ], __METHOD__ ); } @@ -3259,26 +3259,26 @@ class WikiPage implements Page, IDBAccessObject { ? $status->value['revision'] : null; if ( !( $statusRev instanceof Revision ) ) { - $resultDetails = array( 'current' => $current ); - return array( array( 'alreadyrolled', + $resultDetails = [ 'current' => $current ]; + return [ [ 'alreadyrolled', htmlspecialchars( $this->mTitle->getPrefixedText() ), htmlspecialchars( $fromP ), htmlspecialchars( $current->getUserText() ) - ) ); + ] ]; } $revId = $statusRev->getId(); - Hooks::run( 'ArticleRollbackComplete', array( $this, $guser, $target, $current ) ); + Hooks::run( 'ArticleRollbackComplete', [ $this, $guser, $target, $current ] ); - $resultDetails = array( + $resultDetails = [ 'summary' => $summary, 'current' => $current, 'target' => $target, 'newid' => $revId - ); + ]; - return array(); + return []; } /** @@ -3384,15 +3384,15 @@ class WikiPage implements Page, IDBAccessObject { public function getCategories() { $id = $this->getId(); if ( $id == 0 ) { - return TitleArray::newFromResult( new FakeResultWrapper( array() ) ); + return TitleArray::newFromResult( new FakeResultWrapper( [] ) ); } $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'categorylinks', - array( 'cl_to AS page_title, ' . NS_CATEGORY . ' AS page_namespace' ), + [ 'cl_to AS page_title, ' . NS_CATEGORY . ' AS page_namespace' ], // Have to do that since DatabaseBase::fieldNamesWithAlias treats numeric indexes // as not being aliases, and NS_CATEGORY is numeric - array( 'cl_from' => $id ), + [ 'cl_from' => $id ], __METHOD__ ); return TitleArray::newFromResult( $res ); @@ -3405,18 +3405,18 @@ class WikiPage implements Page, IDBAccessObject { * @return array Array of Title objects */ public function getHiddenCategories() { - $result = array(); + $result = []; $id = $this->getId(); if ( $id == 0 ) { - return array(); + return []; } $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ), - array( 'cl_to' ), - array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat', - 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ), + $res = $dbr->select( [ 'categorylinks', 'page_props', 'page' ], + [ 'cl_to' ], + [ 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat', + 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ], __METHOD__ ); if ( $res !== false ) { @@ -3478,8 +3478,8 @@ class WikiPage implements Page, IDBAccessObject { function () use ( $dbw, $that, $method, $added, $deleted ) { $ns = $that->getTitle()->getNamespace(); - $addFields = array( 'cat_pages = cat_pages + 1' ); - $removeFields = array( 'cat_pages = cat_pages - 1' ); + $addFields = [ 'cat_pages = cat_pages + 1' ]; + $removeFields = [ 'cat_pages = cat_pages - 1' ]; if ( $ns == NS_CATEGORY ) { $addFields[] = 'cat_subcats = cat_subcats + 1'; $removeFields[] = 'cat_subcats = cat_subcats - 1'; @@ -3492,7 +3492,7 @@ class WikiPage implements Page, IDBAccessObject { $existingAdded = $dbw->selectFieldValues( 'category', 'cat_title', - array( 'cat_title' => $added ), + [ 'cat_title' => $added ], __METHOD__ ); @@ -3503,26 +3503,26 @@ class WikiPage implements Page, IDBAccessObject { $dbw->update( 'category', $addFields, - array( 'cat_title' => $existingAdded ), + [ 'cat_title' => $existingAdded ], __METHOD__ ); } $missingAdded = array_diff( $added, $existingAdded ); if ( count( $missingAdded ) ) { - $insertRows = array(); + $insertRows = []; foreach ( $missingAdded as $cat ) { - $insertRows[] = array( + $insertRows[] = [ 'cat_title' => $cat, 'cat_pages' => 1, 'cat_subcats' => ( $ns == NS_CATEGORY ) ? 1 : 0, 'cat_files' => ( $ns == NS_FILE ) ? 1 : 0, - ); + ]; } $dbw->upsert( 'category', $insertRows, - array( 'cat_title' ), + [ 'cat_title' ], $addFields, $method ); @@ -3533,19 +3533,19 @@ class WikiPage implements Page, IDBAccessObject { $dbw->update( 'category', $removeFields, - array( 'cat_title' => $deleted ), + [ 'cat_title' => $deleted ], $method ); } foreach ( $added as $catName ) { $cat = Category::newFromName( $catName ); - Hooks::run( 'CategoryAfterPageAdded', array( $cat, $that ) ); + Hooks::run( 'CategoryAfterPageAdded', [ $cat, $that ] ); } foreach ( $deleted as $catName ) { $cat = Category::newFromName( $catName ); - Hooks::run( 'CategoryAfterPageRemoved', array( $cat, $that ) ); + Hooks::run( 'CategoryAfterPageRemoved', [ $cat, $that ] ); } } ); @@ -3563,15 +3563,15 @@ class WikiPage implements Page, IDBAccessObject { } if ( !Hooks::run( 'OpportunisticLinksUpdate', - array( $this, $this->mTitle, $parserOutput ) + [ $this, $this->mTitle, $parserOutput ] ) ) { return; } - $params = array( + $params = [ 'isOpportunistic' => true, 'rootJobTimestamp' => $parserOutput->getCacheTime() - ); + ]; if ( $this->mTitle->areRestrictionsCascading() ) { // If the page is cascade protecting, the links should really be up-to-date @@ -3616,12 +3616,12 @@ class WikiPage implements Page, IDBAccessObject { } if ( !$content ) { - $updates = array(); + $updates = []; } else { $updates = $content->getDeletionUpdates( $this ); } - Hooks::run( 'WikiPageDeletionUpdates', array( $this, $content, &$updates ) ); + Hooks::run( 'WikiPageDeletionUpdates', [ $this, $content, &$updates ] ); return $updates; } } diff --git a/includes/pager/AlphabeticPager.php b/includes/pager/AlphabeticPager.php index 34c78976cb..54036eb846 100644 --- a/includes/pager/AlphabeticPager.php +++ b/includes/pager/AlphabeticPager.php @@ -42,12 +42,12 @@ abstract class AlphabeticPager extends IndexPager { return $this->mNavigationBar; } - $linkTexts = array( + $linkTexts = [ 'prev' => $this->msg( 'prevn' )->numParams( $this->mLimit )->escaped(), 'next' => $this->msg( 'nextn' )->numParams( $this->mLimit )->escaped(), 'first' => $this->msg( 'page_first' )->escaped(), 'last' => $this->msg( 'page_last' )->escaped() - ); + ]; $lang = $this->getLanguage(); @@ -56,8 +56,8 @@ abstract class AlphabeticPager extends IndexPager { $limits = $lang->pipeList( $limitLinks ); $this->mNavigationBar = $this->msg( 'parentheses' )->rawParams( - $lang->pipeList( array( $pagingLinks['first'], - $pagingLinks['last'] ) ) )->escaped() . " " . + $lang->pipeList( [ $pagingLinks['first'], + $pagingLinks['last'] ] ) )->escaped() . " " . $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'], $pagingLinks['next'], $limits )->escaped(); @@ -81,7 +81,7 @@ abstract class AlphabeticPager extends IndexPager { } else { $extra .= $this->makeLink( $this->msg( $msgs[$order] )->escaped(), - array( 'order' => $order ) + [ 'order' => $order ] ); } } diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index f0e7f3e809..393644fc9d 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -73,7 +73,7 @@ abstract class IndexPager extends ContextSource implements Pager { const DIR_DESCENDING = true; public $mRequest; - public $mLimitsShown = array( 20, 50, 100, 250, 500 ); + public $mLimitsShown = [ 20, 50, 100, 250, 500 ]; public $mDefaultLimit = 50; public $mOffset, $mLimit; public $mQueryDone = false; @@ -156,14 +156,14 @@ abstract class IndexPager extends ContextSource implements Pager { $this->mIndexField = $index[$order]; $this->mExtraSortFields = isset( $extraSort[$order] ) ? (array)$extraSort[$order] - : array(); + : []; } elseif ( is_array( $index ) ) { # First element is the default reset( $index ); list( $this->mOrderType, $this->mIndexField ) = each( $index ); $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] ) ? (array)$extraSort[$this->mOrderType] - : array(); + : []; } else { # $index is not an array $this->mOrderType = null; @@ -378,15 +378,15 @@ abstract class IndexPager extends ContextSource implements Pager { $info = $this->getQueryInfo(); $tables = $info['tables']; $fields = $info['fields']; - $conds = isset( $info['conds'] ) ? $info['conds'] : array(); - $options = isset( $info['options'] ) ? $info['options'] : array(); - $join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : array(); - $sortColumns = array_merge( array( $this->mIndexField ), $this->mExtraSortFields ); + $conds = isset( $info['conds'] ) ? $info['conds'] : []; + $options = isset( $info['options'] ) ? $info['options'] : []; + $join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : []; + $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields ); if ( $descending ) { $options['ORDER BY'] = $sortColumns; $operator = $this->mIncludeOffset ? '>=' : '>'; } else { - $orderBy = array(); + $orderBy = []; foreach ( $sortColumns as $col ) { $orderBy[] = $col . ' DESC'; } @@ -397,7 +397,7 @@ abstract class IndexPager extends ContextSource implements Pager { $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset ); } $options['LIMIT'] = intval( $limit ); - return array( $tables, $fields, $conds, $fname, $options, $join_conds ); + return [ $tables, $fields, $conds, $fname, $options, $join_conds ]; } /** @@ -463,12 +463,12 @@ abstract class IndexPager extends ContextSource implements Pager { return $text; } - $attrs = array(); - if ( in_array( $type, array( 'prev', 'next' ) ) ) { + $attrs = []; + if ( in_array( $type, [ 'prev', 'next' ] ) ) { $attrs['rel'] = $type; } - if ( in_array( $type, array( 'asc', 'desc' ) ) ) { + if ( in_array( $type, [ 'asc', 'desc' ] ) ) { $attrs['title'] = wfMessage( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text(); } @@ -573,26 +573,26 @@ abstract class IndexPager extends ContextSource implements Pager { $prev = false; $first = false; } else { - $prev = array( + $prev = [ 'dir' => 'prev', 'offset' => $this->mFirstShown, 'limit' => $urlLimit - ); - $first = array( 'limit' => $urlLimit ); + ]; + $first = [ 'limit' => $urlLimit ]; } if ( $this->mIsLast ) { $next = false; $last = false; } else { - $next = array( 'offset' => $this->mLastShown, 'limit' => $urlLimit ); - $last = array( 'dir' => 'prev', 'limit' => $urlLimit ); + $next = [ 'offset' => $this->mLastShown, 'limit' => $urlLimit ]; + $last = [ 'dir' => 'prev', 'limit' => $urlLimit ]; } - return array( + return [ 'prev' => $prev, 'next' => $next, 'first' => $first, 'last' => $last - ); + ]; } /** @@ -618,9 +618,9 @@ abstract class IndexPager extends ContextSource implements Pager { * @param array $disabledTexts * @return array */ - function getPagingLinks( $linkTexts, $disabledTexts = array() ) { + function getPagingLinks( $linkTexts, $disabledTexts = [] ) { $queries = $this->getPagingQueries(); - $links = array(); + $links = []; foreach ( $queries as $type => $query ) { if ( $query !== false ) { @@ -640,7 +640,7 @@ abstract class IndexPager extends ContextSource implements Pager { } function getLimitLinks() { - $links = array(); + $links = []; if ( $this->mIsBackwards ) { $offset = $this->mPastTheEndIndex; } else { @@ -649,7 +649,7 @@ abstract class IndexPager extends ContextSource implements Pager { foreach ( $this->mLimitsShown as $limit ) { $links[] = $this->makeLink( $this->getLanguage()->formatNum( $limit ), - array( 'offset' => $offset, 'limit' => $limit ), + [ 'offset' => $offset, 'limit' => $limit ], 'num' ); } @@ -711,7 +711,7 @@ abstract class IndexPager extends ContextSource implements Pager { * @return array */ protected function getExtraSortFields() { - return array(); + return []; } /** diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php index ee6e26c02f..2c415d6843 100644 --- a/includes/pager/ReverseChronologicalPager.php +++ b/includes/pager/ReverseChronologicalPager.php @@ -39,12 +39,12 @@ abstract class ReverseChronologicalPager extends IndexPager { return $this->mNavigationBar; } - $linkTexts = array( + $linkTexts = [ 'prev' => $this->msg( 'pager-newer-n' )->numParams( $this->mLimit )->escaped(), 'next' => $this->msg( 'pager-older-n' )->numParams( $this->mLimit )->escaped(), 'first' => $this->msg( 'histlast' )->escaped(), 'last' => $this->msg( 'histfirst' )->escaped() - ); + ]; $pagingLinks = $this->getPagingLinks( $linkTexts ); $limitLinks = $this->getLimitLinks(); diff --git a/includes/pager/TablePager.php b/includes/pager/TablePager.php index ea619f1a72..e22cebad87 100644 --- a/includes/pager/TablePager.php +++ b/includes/pager/TablePager.php @@ -119,9 +119,9 @@ abstract class TablePager extends IndexPager { // Make table header foreach ( $fields as $field => $name ) { if ( strval( $name ) == '' ) { - $s .= Html::rawElement( 'th', array(), ' ' ) . "\n"; + $s .= Html::rawElement( 'th', [], ' ' ) . "\n"; } elseif ( $this->isFieldSortable( $field ) ) { - $query = array( 'sort' => $field, 'limit' => $this->mLimit ); + $query = [ 'sort' => $field, 'limit' => $this->mLimit ]; $linkType = null; $class = null; @@ -142,17 +142,17 @@ abstract class TablePager extends IndexPager { } $link = $this->makeLink( htmlspecialchars( $name ), $query, $linkType ); - $s .= Html::rawElement( 'th', array( 'class' => $class ), $link ) . "\n"; + $s .= Html::rawElement( 'th', [ 'class' => $class ], $link ) . "\n"; } else { - $s .= Html::element( 'th', array(), $name ) . "\n"; + $s .= Html::element( 'th', [], $name ) . "\n"; } } $tableClass = $this->getTableClass(); - $ret = Html::openElement( 'table', array( - 'class' => "mw-datatable $tableClass" ) + $ret = Html::openElement( 'table', [ + 'class' => "mw-datatable $tableClass" ] ); - $ret .= Html::rawElement( 'thead', array(), Html::rawElement( 'tr', array(), "\n" . $s . "\n" ) ); + $ret .= Html::rawElement( 'thead', [], Html::rawElement( 'tr', [], "\n" . $s . "\n" ) ); $ret .= Html::openElement( 'tbody' ) . "\n"; return $ret; @@ -173,8 +173,8 @@ abstract class TablePager extends IndexPager { function getEmptyBody() { $colspan = count( $this->getFieldNames() ); $msgEmpty = $this->msg( 'table_pager_empty' )->text(); - return Html::rawElement( 'tr', array(), - Html::element( 'td', array( 'colspan' => $colspan ), $msgEmpty ) ); + return Html::rawElement( 'tr', [], + Html::element( 'td', [ 'colspan' => $colspan ], $msgEmpty ) ); } /** @@ -227,9 +227,9 @@ abstract class TablePager extends IndexPager { $class = $this->getRowClass( $row ); if ( $class === '' ) { // Return an empty array to avoid clutter in HTML like class="" - return array(); + return []; } else { - return array( 'class' => $this->getRowClass( $row ) ); + return [ 'class' => $this->getRowClass( $row ) ]; } } @@ -252,7 +252,7 @@ abstract class TablePager extends IndexPager { * @return array Array of attr => value */ function getCellAttrs( $field, $value ) { - return array( 'class' => 'TablePager_col_' . $field ); + return [ 'class' => 'TablePager_col_' . $field ]; } /** @@ -296,15 +296,15 @@ abstract class TablePager extends IndexPager { return ''; } - $labels = array( + $labels = [ 'first' => 'table_pager_first', 'prev' => 'table_pager_prev', 'next' => 'table_pager_next', 'last' => 'table_pager_last', - ); + ]; - $linkTexts = array(); - $disabledTexts = array(); + $linkTexts = []; + $disabledTexts = []; foreach ( $labels as $type => $label ) { $msgLabel = $this->msg( $label )->escaped(); $linkTexts[$type] = "
    $msgLabel
    "; @@ -312,7 +312,7 @@ abstract class TablePager extends IndexPager { } $links = $this->getPagingLinks( $linkTexts, $disabledTexts ); - $s = Html::openElement( 'table', array( 'class' => $this->getNavClass() ) ); + $s = Html::openElement( 'table', [ 'class' => $this->getNavClass() ] ); $s .= Html::openElement( 'tr' ) . "\n"; $width = 100 / count( $links ) . '%'; foreach ( $labels as $type => $label ) { @@ -320,7 +320,7 @@ abstract class TablePager extends IndexPager { // but it only works if we specify the width of a cell or the table and we don't want to. // There is no better way. $s .= Html::rawElement( 'td', - array( 'style' => "width: $width;", 'class' => "TablePager_nav-$type" ), + [ 'style' => "width: $width;", 'class' => "TablePager_nav-$type" ], $links[$type] ) . "\n"; } $s .= Html::closeElement( 'tr' ) . Html::closeElement( 'table' ) . "\n"; @@ -333,7 +333,7 @@ abstract class TablePager extends IndexPager { * @return string[] */ public function getModuleStyles() { - return array( 'mediawiki.pager.tablePager' ); + return [ 'mediawiki.pager.tablePager' ]; } /** @@ -342,7 +342,7 @@ abstract class TablePager extends IndexPager { * @param string $attribs Extra attributes to set * @return string HTML fragment */ - public function getLimitSelect( $attribs = array() ) { + public function getLimitSelect( $attribs = [] ) { $select = new XmlSelect( 'limit', false, $this->mLimit ); $select->addOptions( $this->getLimitSelectList() ); foreach ( $attribs as $name => $value ) { @@ -365,7 +365,7 @@ abstract class TablePager extends IndexPager { $this->mLimitsShown[] = $this->mLimit; sort( $this->mLimitsShown ); } - $ret = array(); + $ret = []; foreach ( $this->mLimitsShown as $key => $value ) { # The pair is either $index => $limit, in which case the $value # will be numeric, or $limit => $text, in which case the $value @@ -390,7 +390,7 @@ abstract class TablePager extends IndexPager { * @param array $blacklist Parameters from the request query which should not be resubmitted * @return string HTML fragment */ - function getHiddenFields( $blacklist = array() ) { + function getHiddenFields( $blacklist = [] ) { $blacklist = (array)$blacklist; $query = $this->getRequest()->getQueryValues(); foreach ( $blacklist as $name ) { @@ -411,10 +411,10 @@ abstract class TablePager extends IndexPager { function getLimitForm() { return Html::rawElement( 'form', - array( + [ 'method' => 'get', 'action' => wfScript(), - ), + ], "\n" . $this->getLimitDropdown() ) . "\n"; } @@ -431,7 +431,7 @@ abstract class TablePager extends IndexPager { return $this->msg( 'table_pager_limit' ) ->rawParams( $this->getLimitSelect() )->escaped() . "\n\n" . - $this->getHiddenFields( array( 'limit' ) ); + $this->getHiddenFields( [ 'limit' ] ); } /** diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 91b6080c32..1cc0efccda 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -38,7 +38,7 @@ class CoreParserFunctions { # function callback, # optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}} # instead of {{#int:...}}) - $noHashFunctions = array( + $noHashFunctions = [ 'ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 'uc', 'localurl', 'localurle', 'fullurl', 'fullurle', 'canonicalurl', 'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural', 'bidi', @@ -55,33 +55,33 @@ class CoreParserFunctions { 'subjectpagenamee', 'pageid', 'revisionid', 'revisionday', 'revisionday2', 'revisionmonth', 'revisionmonth1', 'revisionyear', 'revisiontimestamp', 'revisionuser', 'cascadingsources', - ); + ]; foreach ( $noHashFunctions as $func ) { - $parser->setFunctionHook( $func, array( __CLASS__, $func ), Parser::SFH_NO_HASH ); + $parser->setFunctionHook( $func, [ __CLASS__, $func ], Parser::SFH_NO_HASH ); } $parser->setFunctionHook( 'namespace', - array( __CLASS__, 'mwnamespace' ), + [ __CLASS__, 'mwnamespace' ], Parser::SFH_NO_HASH ); - $parser->setFunctionHook( 'int', array( __CLASS__, 'intFunction' ), Parser::SFH_NO_HASH ); - $parser->setFunctionHook( 'special', array( __CLASS__, 'special' ) ); - $parser->setFunctionHook( 'speciale', array( __CLASS__, 'speciale' ) ); - $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), Parser::SFH_OBJECT_ARGS ); - $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) ); + $parser->setFunctionHook( 'int', [ __CLASS__, 'intFunction' ], Parser::SFH_NO_HASH ); + $parser->setFunctionHook( 'special', [ __CLASS__, 'special' ] ); + $parser->setFunctionHook( 'speciale', [ __CLASS__, 'speciale' ] ); + $parser->setFunctionHook( 'tag', [ __CLASS__, 'tagObj' ], Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionHook( 'formatdate', [ __CLASS__, 'formatDate' ] ); if ( $wgAllowDisplayTitle ) { $parser->setFunctionHook( 'displaytitle', - array( __CLASS__, 'displaytitle' ), + [ __CLASS__, 'displaytitle' ], Parser::SFH_NO_HASH ); } if ( $wgAllowSlowParserFunctions ) { $parser->setFunctionHook( 'pagesinnamespace', - array( __CLASS__, 'pagesinnamespace' ), + [ __CLASS__, 'pagesinnamespace' ], Parser::SFH_NO_HASH ); } @@ -102,9 +102,9 @@ class CoreParserFunctions { // and can result in a tag, therefore escape the angles return $message->escaped(); } - return array( $message->plain(), 'noparse' => false ); + return [ $message->plain(), 'noparse' => false ]; } else { - return array( 'found' => false ); + return [ 'found' => false ]; } } @@ -129,7 +129,7 @@ class CoreParserFunctions { $pref = $defaultPref; } - $date = $df->reformat( $pref, $date, array( 'match-whole' ) ); + $date = $df->reformat( $pref, $date, [ 'match-whole' ] ); return $date; } @@ -143,7 +143,7 @@ class CoreParserFunctions { if ( $index !== false ) { return $wgContLang->getFormattedNsText( $index ); } else { - return array( 'found' => false ); + return [ 'found' => false ]; } } @@ -170,7 +170,7 @@ class CoreParserFunctions { public static function urlencode( $parser, $s = '', $arg = null ) { static $magicWords = null; if ( is_null( $magicWords ) ) { - $magicWords = new MagicWordArray( array( 'url_path', 'url_query', 'url_wiki' ) ); + $magicWords = new MagicWordArray( [ 'url_path', 'url_query', 'url_wiki' ] ); } switch ( $magicWords->matchStartToEnd( $arg ) ) { @@ -212,7 +212,7 @@ class CoreParserFunctions { */ public static function lc( $parser, $s = '' ) { global $wgContLang; - return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) ); + return $parser->markerSkipCallback( $s, [ $wgContLang, 'lc' ] ); } /** @@ -222,7 +222,7 @@ class CoreParserFunctions { */ public static function uc( $parser, $s = '' ) { global $wgContLang; - return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) ); + return $parser->markerSkipCallback( $s, [ $wgContLang, 'uc' ] ); } public static function localurl( $parser, $s = '', $arg = null ) { @@ -285,7 +285,7 @@ class CoreParserFunctions { } return $text; } else { - return array( 'found' => false ); + return [ 'found' => false ]; } } @@ -297,11 +297,11 @@ class CoreParserFunctions { */ public static function formatnum( $parser, $num = '', $arg = null ) { if ( self::matchAgainstMagicword( 'rawsuffix', $arg ) ) { - $func = array( $parser->getFunctionLang(), 'parseFormattedNumber' ); + $func = [ $parser->getFunctionLang(), 'parseFormattedNumber' ]; } elseif ( self::matchAgainstMagicword( 'nocommafysuffix', $arg ) ) { - $func = array( $parser->getFunctionLang(), 'formatNumNoSeparators' ); + $func = [ $parser->getFunctionLang(), 'formatNumNoSeparators' ]; } else { - $func = array( $parser->getFunctionLang(), 'formatNum' ); + $func = [ $parser->getFunctionLang(), 'formatNum' ]; } return $parser->markerSkipCallback( $num, $func ); } @@ -390,7 +390,7 @@ class CoreParserFunctions { static $magicWords = null; if ( is_null( $magicWords ) ) { - $magicWords = new MagicWordArray( array( 'displaytitle_noerror', 'displaytitle_noreplace' ) ); + $magicWords = new MagicWordArray( [ 'displaytitle_noerror', 'displaytitle_noreplace' ] ); } $arg = $magicWords->matchStartToEnd( $uarg ); @@ -402,8 +402,8 @@ class CoreParserFunctions { // list of disallowed tags for DISPLAYTITLE // these will be escaped even though they are allowed in normal wiki text - $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr', - 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ); + $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr', + 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ]; // disallow some styles that could be used to bypass $wgRestrictDisplayTitle if ( $wgRestrictDisplayTitle ) { @@ -432,8 +432,8 @@ class CoreParserFunctions { $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $text, $htmlTagsCallback, - array(), - array(), + [], + [], $bad ) ); $title = Title::newFromText( Sanitizer::stripAllTags( $text ) ); @@ -693,14 +693,14 @@ class CoreParserFunctions { global $wgContLang; static $magicWords = null; if ( is_null( $magicWords ) ) { - $magicWords = new MagicWordArray( array( + $magicWords = new MagicWordArray( [ 'pagesincategory_all', 'pagesincategory_pages', 'pagesincategory_subcats', 'pagesincategory_files' - ) ); + ] ); } - static $cache = array(); + static $cache = []; // split the given option to its variable if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) { @@ -920,7 +920,7 @@ class CoreParserFunctions { public static function defaultsort( $parser, $text, $uarg = '' ) { static $magicWords = null; if ( is_null( $magicWords ) ) { - $magicWords = new MagicWordArray( array( 'defaultsort_noerror', 'defaultsort_noreplace' ) ); + $magicWords = new MagicWordArray( [ 'defaultsort_noerror', 'defaultsort_noreplace' ] ); } $arg = $magicWords->matchStartToEnd( $uarg ); @@ -984,7 +984,7 @@ class CoreParserFunctions { } } if ( $isNowiki ) { - return array( $url, 'nowiki' => true ); + return [ $url, 'nowiki' => true ]; } return $url; } else { @@ -1011,7 +1011,7 @@ class CoreParserFunctions { $inner = null; } - $attributes = array(); + $attributes = []; foreach ( $args as $arg ) { $bits = $arg->splitArg(); if ( strval( $bits['index'] ) === '' ) { @@ -1037,12 +1037,12 @@ class CoreParserFunctions { return "<$tagName$attrText>$inner"; } - $params = array( + $params = [ 'name' => $tagName, 'inner' => $inner, 'attributes' => $attributes, 'close' => "", - ); + ]; return $parser->extensionSubstitution( $params, $frame ); } @@ -1293,7 +1293,7 @@ class CoreParserFunctions { if ( $titleObject->areCascadeProtectionSourcesLoaded() || $parser->incrementExpensiveFunctionCount() ) { - $names = array(); + $names = []; $sources = $titleObject->getCascadeProtectionSources(); foreach ( $sources[0] as $sourceTitle ) { $names[] = $sourceTitle->getPrefixedText(); diff --git a/includes/parser/CoreTagHooks.php b/includes/parser/CoreTagHooks.php index 9755ea93f6..d4c4f6d2d0 100644 --- a/includes/parser/CoreTagHooks.php +++ b/includes/parser/CoreTagHooks.php @@ -32,12 +32,12 @@ class CoreTagHooks { */ public static function register( $parser ) { global $wgRawHtml; - $parser->setHook( 'pre', array( __CLASS__, 'pre' ) ); - $parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) ); - $parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) ); - $parser->setHook( 'indicator', array( __CLASS__, 'indicator' ) ); + $parser->setHook( 'pre', [ __CLASS__, 'pre' ] ); + $parser->setHook( 'nowiki', [ __CLASS__, 'nowiki' ] ); + $parser->setHook( 'gallery', [ __CLASS__, 'gallery' ] ); + $parser->setHook( 'indicator', [ __CLASS__, 'indicator' ] ); if ( $wgRawHtml ) { - $parser->setHook( 'html', array( __CLASS__, 'html' ) ); + $parser->setHook( 'html', [ __CLASS__, 'html' ] ); } } @@ -79,7 +79,7 @@ class CoreTagHooks { public static function html( $content, $attributes, $parser ) { global $wgRawHtml; if ( $wgRawHtml ) { - return array( $content, 'markerType' => 'nowiki' ); + return [ $content, 'markerType' => 'nowiki' ]; } else { throw new MWException( ' extension tag encountered unexpectedly' ); } @@ -98,8 +98,8 @@ class CoreTagHooks { * @return array */ public static function nowiki( $content, $attributes, $parser ) { - $content = strtr( $content, array( '-{' => '-{', '}-' => '}-' ) ); - return array( Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' ); + $content = strtr( $content, [ '-{' => '-{', '}-' => '}-' ] ); + return [ Xml::escapeTagsOnly( $content ), 'markerType' => 'nowiki' ]; } /** diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index edb9ff1d28..40da3685ab 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -108,13 +108,13 @@ class DateFormatter { $this->rules[self::ALL][self::DM] = self::DM; $this->rules[self::NONE][self::ISO2] = self::ISO1; - $this->preferences = array( + $this->preferences = [ 'default' => self::NONE, 'dmy' => self::DMY, 'mdy' => self::MDY, 'ymd' => self::YMD, 'ISO 8601' => self::ISO1, - ); + ]; } /** @@ -151,7 +151,7 @@ class DateFormatter { * * @return string */ - public function reformat( $preference, $text, $options = array( 'linked' ) ) { + public function reformat( $preference, $text, $options = [ 'linked' ] ) { $linked = in_array( 'linked', $options ); $match_whole = in_array( 'match-whole', $options ); @@ -179,7 +179,7 @@ class DateFormatter { // Horrible hack if ( !$linked ) { - $regex = str_replace( array( '\[\[', '\]\]' ), '', $regex ); + $regex = str_replace( [ '\[\[', '\]\]' ], '', $regex ); } if ( $match_whole ) { @@ -191,7 +191,7 @@ class DateFormatter { // Another horrible hack $this->mLinked = $linked; - $text = preg_replace_callback( $regex, array( &$this, 'replace' ), $text ); + $text = preg_replace_callback( $regex, [ &$this, 'replace' ], $text ); unset( $this->mLinked ); } return $text; @@ -208,7 +208,7 @@ class DateFormatter { $linked = $this->mLinked; } - $bits = array(); + $bits = []; $key = $this->keys[$this->mSource]; $keyLength = strlen( $key ); for ( $p = 0; $p < $keyLength; $p++ ) { @@ -232,7 +232,7 @@ class DateFormatter { // strip piped links $format = preg_replace( '/\[\[[^|]+\|([^\]]+)\]\]/', '$1', $format ); // strip remaining links - $format = str_replace( array( '[[', ']]' ), '', $format ); + $format = str_replace( [ '[[', ']]' ], '', $format ); } # Construct new date @@ -304,7 +304,7 @@ class DateFormatter { $text = $matches[0]; } - $isoBits = array(); + $isoBits = []; if ( isset( $bits['y'] ) ) { $isoBits[] = $bits['y']; } @@ -314,7 +314,7 @@ class DateFormatter { // Output is not strictly HTML (it's wikitext), but is whitelisted. $text = Html::rawElement( 'span', - array( 'class' => 'mw-formatted-date', 'title' => $isoDate ), $text ); + [ 'class' => 'mw-formatted-date', 'title' => $isoDate ], $text ); return $text; } @@ -324,7 +324,7 @@ class DateFormatter { * @return string regex to find the months with */ public function getMonthRegex() { - $names = array(); + $names = []; for ( $i = 1; $i <= 12; $i++ ) { $names[] = $this->lang->getMonthName( $i ); $names[] = $this->lang->getMonthAbbreviation( $i ); diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index dfc4b535fb..04b5614be6 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -25,8 +25,8 @@ * @ingroup Parser */ class LinkHolderArray { - public $internals = array(); - public $interwikis = array(); + public $internals = []; + public $interwikis = []; public $size = 0; /** @@ -73,7 +73,7 @@ class LinkHolderArray { } unset( $entry ); - return array( 'internals', 'interwikis', 'size' ); + return [ 'internals', 'interwikis', 'size' ]; } /** @@ -135,7 +135,7 @@ class LinkHolderArray { } } $texts = preg_replace_callback( '/()/', - array( $this, 'mergeForeignCallback' ), $texts ); + [ $this, 'mergeForeignCallback' ], $texts ); # Renumber interwiki links foreach ( $other->interwikis as $key => $entry ) { @@ -144,7 +144,7 @@ class LinkHolderArray { $maxId = $newKey > $maxId ? $newKey : $maxId; } $texts = preg_replace_callback( '/()/', - array( $this, 'mergeForeignCallback' ), $texts ); + [ $this, 'mergeForeignCallback' ], $texts ); # Set the parent link ID to be beyond the highest used ID $this->parent->setLinkID( $maxId + 1 ); @@ -210,8 +210,8 @@ class LinkHolderArray { * Make sure you don't have any text left using these link holders, before you call this */ public function clear() { - $this->internals = array(); - $this->interwikis = array(); + $this->internals = []; + $this->interwikis = []; $this->size = 0; } @@ -228,7 +228,7 @@ class LinkHolderArray { * @param string $prefix [optional] * @return string */ - public function makeHolder( $nt, $text = '', $query = array(), $trail = '', $prefix = '' ) { + public function makeHolder( $nt, $text = '', $query = [], $trail = '', $prefix = '' ) { if ( !is_object( $nt ) ) { # Fail gracefully $retVal = "{$prefix}{$text}{$trail}"; @@ -236,12 +236,12 @@ class LinkHolderArray { # Separate the link trail from the rest of the link list( $inside, $trail ) = Linker::splitTrail( $trail ); - $entry = array( + $entry = [ 'title' => $nt, 'text' => $prefix . $text . $inside, 'pdbk' => $nt->getPrefixedDBkey(), - ); - if ( $query !== array() ) { + ]; + if ( $query !== [] ) { $entry['query'] = $query; } @@ -284,7 +284,7 @@ class LinkHolderArray { global $wgContLang, $wgContentHandlerUseDB, $wgPageLanguageUseDB; - $colours = array(); + $colours = []; $linkCache = LinkCache::singleton(); $output = $this->parent->getOutput(); @@ -294,10 +294,10 @@ class LinkHolderArray { # Sort by namespace ksort( $this->internals ); - $linkcolour_ids = array(); + $linkcolour_ids = []; # Generate query - $queries = array(); + $queries = []; foreach ( $this->internals as $ns => $entries ) { foreach ( $entries as $entry ) { /** @var Title $title */ @@ -331,19 +331,19 @@ class LinkHolderArray { } } if ( $queries ) { - $where = array(); + $where = []; foreach ( $queries as $ns => $pages ) { $where[] = $dbr->makeList( - array( + [ 'page_namespace' => $ns, 'page_title' => array_unique( $pages ), - ), + ], LIST_AND ); } - $fields = array( 'page_id', 'page_namespace', 'page_title', - 'page_is_redirect', 'page_len', 'page_latest' ); + $fields = [ 'page_id', 'page_namespace', 'page_title', + 'page_is_redirect', 'page_len', 'page_latest' ]; if ( $wgContentHandlerUseDB ) { $fields[] = 'page_content_model'; @@ -377,7 +377,7 @@ class LinkHolderArray { } if ( count( $linkcolour_ids ) ) { // pass an array of page_ids to an extension - Hooks::run( 'GetLinkColours', array( $linkcolour_ids, &$colours ) ); + Hooks::run( 'GetLinkColours', [ $linkcolour_ids, &$colours ] ); } # Do a second query for different language variants of links and categories @@ -386,12 +386,12 @@ class LinkHolderArray { } # Construct search and replace arrays - $replacePairs = array(); + $replacePairs = []; foreach ( $this->internals as $ns => $entries ) { foreach ( $entries as $index => $entry ) { $pdbk = $entry['pdbk']; $title = $entry['title']; - $query = isset( $entry['query'] ) ? $entry['query'] : array(); + $query = isset( $entry['query'] ) ? $entry['query'] : []; $key = "$ns:$index"; $searchkey = ""; $displayText = $entry['text']; @@ -405,16 +405,16 @@ class LinkHolderArray { if ( !isset( $colours[$pdbk] ) ) { $colours[$pdbk] = 'new'; } - $attribs = array(); + $attribs = []; if ( $colours[$pdbk] == 'new' ) { $linkCache->addBadLinkObj( $title ); $output->addLink( $title, 0 ); - $type = array( 'broken' ); + $type = [ 'broken' ]; } else { if ( $colours[$pdbk] != '' ) { $attribs['class'] = $colours[$pdbk]; } - $type = array( 'known', 'noclasses' ); + $type = [ 'known', 'noclasses' ]; } $replacePairs[$searchkey] = Linker::link( $title, $displayText, $attribs, $query, $type ); @@ -442,12 +442,12 @@ class LinkHolderArray { # Make interwiki link HTML $output = $this->parent->getOutput(); - $replacePairs = array(); - $options = array( + $replacePairs = []; + $options = [ 'stubThreshold' => $this->parent->getOptions()->getStubThreshold(), - ); + ]; foreach ( $this->interwikis as $key => $link ) { - $replacePairs[$key] = Linker::link( $link['title'], $link['text'], array(), array(), $options ); + $replacePairs[$key] = Linker::link( $link['title'], $link['text'], [], [], $options ); $output->addInterwikiLink( $link['title'] ); } $replacer = new HashtableReplacer( $replacePairs, 1 ); @@ -465,12 +465,12 @@ class LinkHolderArray { protected function doVariants( &$colours ) { global $wgContLang, $wgContentHandlerUseDB, $wgPageLanguageUseDB; $linkBatch = new LinkBatch(); - $variantMap = array(); // maps $pdbkey_Variant => $keys (of link holders) + $variantMap = []; // maps $pdbkey_Variant => $keys (of link holders) $output = $this->parent->getOutput(); $linkCache = LinkCache::singleton(); $threshold = $this->parent->getOptions()->getStubThreshold(); $titlesToBeConverted = ''; - $titlesAttrs = array(); + $titlesAttrs = []; // Concatenate titles to a single string, thus we only need auto convert the // single string to all variants. This would improve parser's performance @@ -483,7 +483,7 @@ class LinkHolderArray { $pdbk = $entry['pdbk']; // we only deal with new links (in its first query) if ( !isset( $colours[$pdbk] ) || $colours[$pdbk] === 'new' ) { - $titlesAttrs[] = array( $index, $entry['title'] ); + $titlesAttrs[] = [ $index, $entry['title'] ]; // separate titles with \0 because it would never appears // in a valid title $titlesToBeConverted .= $entry['title']->getText() . "\0"; @@ -531,8 +531,8 @@ class LinkHolderArray { } // process categories, check if a category exists in some variant - $categoryMap = array(); // maps $category_variant => $category (dbkeys) - $varCategories = array(); // category replacements oldDBkey => newDBkey + $categoryMap = []; // maps $category_variant => $category (dbkeys) + $varCategories = []; // category replacements oldDBkey => newDBkey foreach ( $output->getCategoryLinks() as $category ) { $categoryTitle = Title::makeTitleSafe( NS_CATEGORY, $category ); $linkBatch->addObj( $categoryTitle ); @@ -544,7 +544,7 @@ class LinkHolderArray { continue; } $linkBatch->addObj( $variantTitle ); - $categoryMap[$variant] = array( $category, $categoryTitle ); + $categoryMap[$variant] = [ $category, $categoryTitle ]; } } } @@ -552,8 +552,8 @@ class LinkHolderArray { if ( !$linkBatch->isEmpty() ) { // construct query $dbr = wfGetDB( DB_SLAVE ); - $fields = array( 'page_id', 'page_namespace', 'page_title', - 'page_is_redirect', 'page_len', 'page_latest' ); + $fields = [ 'page_id', 'page_namespace', 'page_title', + 'page_is_redirect', 'page_len', 'page_latest' ]; if ( $wgContentHandlerUseDB ) { $fields[] = 'page_content_model'; @@ -568,7 +568,7 @@ class LinkHolderArray { __METHOD__ ); - $linkcolour_ids = array(); + $linkcolour_ids = []; // for each found variants, figure out link holders and replace foreach ( $varRes as $s ) { @@ -576,7 +576,7 @@ class LinkHolderArray { $varPdbk = $variantTitle->getPrefixedDBkey(); $vardbk = $variantTitle->getDBkey(); - $holderKeys = array(); + $holderKeys = []; if ( isset( $variantMap[$varPdbk] ) ) { $holderKeys = $variantMap[$varPdbk]; $linkCache->addGoodLinkObjFromRow( $variantTitle, $s ); @@ -611,11 +611,11 @@ class LinkHolderArray { } } } - Hooks::run( 'GetLinkColours', array( $linkcolour_ids, &$colours ) ); + Hooks::run( 'GetLinkColours', [ $linkcolour_ids, &$colours ] ); // rebuild the categories in original order (if there are replacements) if ( count( $varCategories ) > 0 ) { - $newCats = array(); + $newCats = []; $originalCats = $output->getCategories(); foreach ( $originalCats as $cat => $sortkey ) { // make the replacement @@ -641,7 +641,7 @@ class LinkHolderArray { $text = preg_replace_callback( '//', - array( &$this, 'replaceTextCallback' ), + [ &$this, 'replaceTextCallback' ], $text ); return $text; diff --git a/includes/parser/MWTidy.php b/includes/parser/MWTidy.php index 746e15be3e..bdf3efba56 100644 --- a/includes/parser/MWTidy.php +++ b/includes/parser/MWTidy.php @@ -63,9 +63,9 @@ class MWTidy { public static function getModuleStyles() { $driver = self::singleton(); if ( $driver && $driver instanceof MediaWiki\Tidy\RaggettBase ) { - return array( 'mediawiki.raggett' ); + return [ 'mediawiki.raggett' ]; } else { - return array(); + return []; } } @@ -102,11 +102,11 @@ class MWTidy { $config = $wgTidyConfig; } elseif ( $wgUseTidy ) { // b/c configuration - $config = array( + $config = [ 'tidyConfigFile' => $wgTidyConf, 'debugComment' => $wgDebugTidy, 'tidyBin' => $wgTidyBin, - 'tidyCommandLine' => $wgTidyOpts ); + 'tidyCommandLine' => $wgTidyOpts ]; if ( $wgTidyInternal ) { if ( wfIsHHVM() ) { $config['driver'] = 'RaggettInternalHHVM'; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index bec83e1c82..67e7ff74a6 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -140,16 +140,16 @@ class Parser { const TOC_END = ''; # Persistent: - public $mTagHooks = array(); - public $mTransparentTagHooks = array(); - public $mFunctionHooks = array(); - public $mFunctionSynonyms = array( 0 => array(), 1 => array() ); - public $mFunctionTagHooks = array(); - public $mStripList = array(); - public $mDefaultStripList = array(); - public $mVarCache = array(); - public $mImageParams = array(); - public $mImageParamsMagicArray = array(); + public $mTagHooks = []; + public $mTransparentTagHooks = []; + public $mFunctionHooks = []; + public $mFunctionSynonyms = [ 0 => [], 1 => [] ]; + public $mFunctionTagHooks = []; + public $mStripList = []; + public $mDefaultStripList = []; + public $mVarCache = []; + public $mImageParams = []; + public $mImageParamsMagicArray = []; public $mMarkerIndex = 0; public $mFirstCall = true; @@ -256,7 +256,7 @@ class Parser { /** * @param array $conf */ - public function __construct( $conf = array() ) { + public function __construct( $conf = [] ) { $this->mConf = $conf; $this->mUrlProtocols = wfUrlProtocols(); $this->mExtLinkBracketedRegex = '/\[(((?i)' . $this->mUrlProtocols . ')' . @@ -303,7 +303,7 @@ class Parser { // reference is copied as a reference in the new object. Both of these // are defined PHP5 behaviors, as inconvenient as it is for us when old // hooks from PHP4 days are passing fields by reference. - foreach ( array( 'mStripState', 'mVarCache' ) as $k ) { + foreach ( [ 'mStripState', 'mVarCache' ] as $k ) { // Make a non-reference copy of the field, then rebind the field to // reference the new copy. $tmp = $this->$k; @@ -311,7 +311,7 @@ class Parser { unset( $tmp ); } - Hooks::run( 'ParserCloned', array( $this ) ); + Hooks::run( 'ParserCloned', [ $this ] ); } /** @@ -327,7 +327,7 @@ class Parser { CoreTagHooks::register( $this ); $this->initialiseVariables(); - Hooks::run( 'ParserFirstCallInit', array( &$this ) ); + Hooks::run( 'ParserFirstCallInit', [ &$this ] ); } /** @@ -340,39 +340,39 @@ class Parser { $this->firstCallInit(); } $this->mOutput = new ParserOutput; - $this->mOptions->registerWatcher( array( $this->mOutput, 'recordOption' ) ); + $this->mOptions->registerWatcher( [ $this->mOutput, 'recordOption' ] ); $this->mAutonumber = 0; $this->mLastSection = ''; $this->mDTopen = false; - $this->mIncludeCount = array(); + $this->mIncludeCount = []; $this->mArgStack = false; $this->mInPre = false; $this->mLinkHolders = new LinkHolderArray( $this ); $this->mLinkID = 0; $this->mRevisionObject = $this->mRevisionTimestamp = $this->mRevisionId = $this->mRevisionUser = $this->mRevisionSize = null; - $this->mVarCache = array(); + $this->mVarCache = []; $this->mUser = null; - $this->mLangLinkLanguages = array(); + $this->mLangLinkLanguages = []; $this->currentRevisionCache = null; $this->mStripState = new StripState; # Clear these on every parse, bug 4549 - $this->mTplRedirCache = $this->mTplDomCache = array(); + $this->mTplRedirCache = $this->mTplDomCache = []; $this->mShowToc = true; $this->mForceTocPosition = false; - $this->mIncludeSizes = array( + $this->mIncludeSizes = [ 'post-expand' => 0, 'arg' => 0, - ); + ]; $this->mPPNodeCount = 0; $this->mGeneratedPPNodeCount = 0; $this->mHighestExpansionDepth = 0; $this->mDefaultSort = false; - $this->mHeadings = array(); - $this->mDoubleUnderscores = array(); + $this->mHeadings = []; + $this->mDoubleUnderscores = []; $this->mExpensiveFunctionCount = 0; # Fix cloning @@ -382,7 +382,7 @@ class Parser { $this->mProfiler = new SectionProfiler(); - Hooks::run( 'ParserClearState', array( &$this ) ); + Hooks::run( 'ParserClearState', [ &$this ] ); } /** @@ -435,11 +435,11 @@ class Parser { $this->mRevisionSize = null; } - Hooks::run( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'ParserBeforeStrip', [ &$this, &$text, &$this->mStripState ] ); # No more strip! - Hooks::run( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'ParserAfterStrip', [ &$this, &$text, &$this->mStripState ] ); $text = $this->internalParse( $text ); - Hooks::run( 'ParserAfterParse', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'ParserAfterParse', [ &$this, &$text, &$this->mStripState ] ); $text = $this->internalParseHalfParsed( $text, true, $linestart ); @@ -488,24 +488,24 @@ class Parser { ); $this->mOutput->setLimitReportData( 'limitreport-ppvisitednodes', - array( $this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount() ) + [ $this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount() ] ); $this->mOutput->setLimitReportData( 'limitreport-ppgeneratednodes', - array( $this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount() ) + [ $this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount() ] ); $this->mOutput->setLimitReportData( 'limitreport-postexpandincludesize', - array( $this->mIncludeSizes['post-expand'], $max ) + [ $this->mIncludeSizes['post-expand'], $max ] ); $this->mOutput->setLimitReportData( 'limitreport-templateargumentsize', - array( $this->mIncludeSizes['arg'], $max ) + [ $this->mIncludeSizes['arg'], $max ] ); $this->mOutput->setLimitReportData( 'limitreport-expansiondepth', - array( $this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth() ) + [ $this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth() ] ); $this->mOutput->setLimitReportData( 'limitreport-expensivefunctioncount', - array( $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit() ) + [ $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit() ] ); - Hooks::run( 'ParserLimitReportPrepare', array( $this, $this->mOutput ) ); + Hooks::run( 'ParserLimitReportPrepare', [ $this, $this->mOutput ] ); $limitReport = "NewPP limit report\n"; if ( $wgShowHostnames ) { @@ -519,10 +519,10 @@ class Parser { foreach ( $this->mOutput->getLimitReportData() as $key => $value ) { if ( Hooks::run( 'ParserLimitReportFormat', - array( $key, &$value, &$limitReport, false, false ) + [ $key, &$value, &$limitReport, false, false ] ) ) { $keyMsg = wfMessage( $key )->inLanguage( 'en' )->useDatabase( false ); - $valueMsg = wfMessage( array( "$key-value-text", "$key-value" ) ) + $valueMsg = wfMessage( [ "$key-value-text", "$key-value" ] ) ->inLanguage( 'en' )->useDatabase( false ); if ( !$valueMsg->exists() ) { $valueMsg = new RawMessage( '$1' ); @@ -536,11 +536,11 @@ class Parser { // Since we're not really outputting HTML, decode the entities and // then re-encode the things that need hiding inside HTML comments. $limitReport = htmlspecialchars_decode( $limitReport ); - Hooks::run( 'ParserLimitReport', array( $this, &$limitReport ) ); + Hooks::run( 'ParserLimitReport', [ $this, &$limitReport ] ); // Sanitize for comment. Note '‐' in the replacement is U+2010, // which looks much like the problematic '-'. - $limitReport = str_replace( array( '-', '&' ), array( '‐', '&' ), $limitReport ); + $limitReport = str_replace( [ '-', '&' ], [ '‐', '&' ], $limitReport ); $text .= "\n\n"; // Add on template profiling data @@ -597,8 +597,8 @@ class Parser { * @return string UNSAFE half-parsed HTML */ public function recursiveTagParse( $text, $frame = false ) { - Hooks::run( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) ); - Hooks::run( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'ParserBeforeStrip', [ &$this, &$text, &$this->mStripState ] ); + Hooks::run( 'ParserAfterStrip', [ &$this, &$text, &$this->mStripState ] ); $text = $this->internalParse( $text, false, $frame ); return $text; } @@ -645,8 +645,8 @@ class Parser { if ( $revid !== null ) { $this->mRevisionId = $revid; } - Hooks::run( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) ); - Hooks::run( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'ParserBeforeStrip', [ &$this, &$text, &$this->mStripState ] ); + Hooks::run( 'ParserAfterStrip', [ &$this, &$text, &$this->mStripState ] ); $text = $this->replaceVariables( $text, $frame ); $text = $this->mStripState->unstripBoth( $text ); return $text; @@ -680,7 +680,7 @@ class Parser { * @param array $params * @return string */ - public function getPreloadText( $text, Title $title, ParserOptions $options, $params = array() ) { + public function getPreloadText( $text, Title $title, ParserOptions $options, $params = [] ) { $msg = new RawMessage( $text ); $text = $msg->params( $params )->plain(); @@ -773,12 +773,12 @@ class Parser { public function setOutputType( $ot ) { $this->mOutputType = $ot; # Shortcut alias - $this->ot = array( + $this->ot = [ 'html' => $ot == self::OT_HTML, 'wiki' => $ot == self::OT_WIKI, 'pre' => $ot == self::OT_PREPROCESS, 'plain' => $ot == self::OT_PLAIN, - ); + ]; } /** @@ -925,7 +925,7 @@ class Parser { } static $n = 1; $stripped = ''; - $matches = array(); + $matches = []; $taglist = implode( '|', $elements ); $start = "/<($taglist)(\\s+[^>]*?|\\s*?)(\/?" . ">)|<(!--)/i"; @@ -976,10 +976,10 @@ class Parser { } } - $matches[$marker] = array( $element, + $matches[$marker] = [ $element, $content, Sanitizer::decodeTagAttributes( $attributes ), - "<$element$attributes$close$content$tail" ); + "<$element$attributes$close$content$tail" ]; } return $stripped; } @@ -1020,11 +1020,11 @@ class Parser { $lines = StringUtils::explode( "\n", $text ); $out = ''; - $td_history = array(); # Is currently a td tag open? - $last_tag_history = array(); # Save history of last lag activated (td, th or caption) - $tr_history = array(); # Is currently a tr tag open? - $tr_attributes = array(); # history of tr attributes - $has_opened_tr = array(); # Did this table open a element? + $td_history = []; # Is currently a td tag open? + $last_tag_history = []; # Save history of last lag activated (td, th or caption) + $tr_history = []; # Is currently a tr tag open? + $tr_attributes = []; # history of tr attributes + $has_opened_tr = []; # Did this table open a element? $indent_level = 0; # indent level of the table foreach ( $lines as $outLine ) { @@ -1037,7 +1037,7 @@ class Parser { $first_character = $line[0]; $first_two = substr( $line, 0, 2 ); - $matches = array(); + $matches = []; if ( preg_match( '/^(:*)\s*\{\|(.*)$/', $line, $matches ) ) { # First check if we are starting a new table @@ -1224,7 +1224,7 @@ class Parser { $origText = $text; # Hook to suspend the parser in this state - if ( !Hooks::run( 'ParserBeforeInternalParse', array( &$this, &$text, &$this->mStripState ) ) ) { + if ( !Hooks::run( 'ParserBeforeInternalParse', [ &$this, &$text, &$this->mStripState ] ) ) { return $text; } @@ -1244,14 +1244,14 @@ class Parser { $text = $this->replaceVariables( $text ); } - Hooks::run( 'InternalParseBeforeSanitize', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'InternalParseBeforeSanitize', [ &$this, &$text, &$this->mStripState ] ); $text = Sanitizer::removeHTMLtags( $text, - array( &$this, 'attributeStripCallback' ), + [ &$this, 'attributeStripCallback' ], false, array_keys( $this->mTransparentTagHooks ) ); - Hooks::run( 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState ) ); + Hooks::run( 'InternalParseBeforeLinks', [ &$this, &$text, &$this->mStripState ] ); # Tables need to come after variable replacement for things to work # properly; putting them before other transformations should keep @@ -1291,18 +1291,18 @@ class Parser { $text = $this->mStripState->unstripGeneral( $text ); if ( $isMain ) { - Hooks::run( 'ParserAfterUnstrip', array( &$this, &$text ) ); + Hooks::run( 'ParserAfterUnstrip', [ &$this, &$text ] ); } # Clean up special characters, only run once, next-to-last before doBlockLevels - $fixtags = array( + $fixtags = [ # french spaces, last one Guillemet-left # only if there is something before the space '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 ', # french spaces, Guillemet-right '/(\\302\\253) /' => '\\1 ', '/ (!\s*important)/' => ' \\1', # Beware of CSS magic word !important, bug #11874. - ); + ]; $text = preg_replace( array_keys( $fixtags ), array_values( $fixtags ), $text ); $text = $this->doBlockLevels( $text, $linestart ); @@ -1330,7 +1330,7 @@ class Parser { $text = $this->mStripState->unstripNoWiki( $text ); if ( $isMain ) { - Hooks::run( 'ParserBeforeTidy', array( &$this, &$text ) ); + Hooks::run( 'ParserBeforeTidy', [ &$this, &$text ] ); } $text = $this->replaceTransparentTags( $text ); @@ -1344,7 +1344,7 @@ class Parser { } else { # attempt to sanitize at least some nesting problems # (bug #2702 and quite a few others) - $tidyregs = array( + $tidyregs = [ # ''Something [http://www.cool.com cool''] --> # Something
    cool> '/(<([bi])>)(<([bi])>)?([^<]*)(<\/?a[^<]*>)([^<]*)(<\/\\4>)?(<\/\\2>)/' => @@ -1361,7 +1361,7 @@ class Parser { # remove empty italic or bold tag pairs, some # introduced by rules above '/<([bi])><\/\\1>/' => '', - ); + ]; $text = preg_replace( array_keys( $tidyregs ), @@ -1370,7 +1370,7 @@ class Parser { } if ( $isMain ) { - Hooks::run( 'ParserAfterTidy', array( &$this, &$text ) ); + Hooks::run( 'ParserAfterTidy', [ &$this, &$text ] ); } return $text; @@ -1408,7 +1408,7 @@ class Parser { (?: [0-9] $spdash? ){9} # 9 digits with opt. delimiters [0-9Xx] # check digit )\b - )!xu", array( &$this, 'magicLinkCallback' ), $text ); + )!xu", [ &$this, 'magicLinkCallback' ], $text ); return $text; } @@ -1450,11 +1450,11 @@ class Parser { $isbn = $m[6]; $space = self::SPACE_NOT_NL; # non-newline space $isbn = preg_replace( "/$space/", ' ', $isbn ); - $num = strtr( $isbn, array( + $num = strtr( $isbn, [ '-' => '', ' ' => '', 'x' => 'X', - ) ); + ] ); $titleObj = SpecialPage::getTitleFor( 'Booksources', $num ); return 'conf['parsers'] as $i => $parserConf ) { if ( !is_array( $parserConf ) ) { $class = $parserConf; - $parserConf = array( 'class' => $parserConf ); + $parserConf = [ 'class' => $parserConf ]; } else { $class = $parserConf['class']; } @@ -59,12 +59,12 @@ class ParserDiffTest public function __call( $name, $args ) { $this->init(); - $results = array(); + $results = []; $mismatch = false; $lastResult = null; $first = true; foreach ( $this->parsers as $i => $parser ) { - $currentResult = call_user_func_array( array( &$this->parsers[$i], $name ), $args ); + $currentResult = call_user_func_array( [ &$this->parsers[$i], $name ], $args ); if ( $first ) { $first = false; } else { @@ -83,7 +83,7 @@ class ParserDiffTest } if ( $mismatch ) { if ( count( $results ) == 2 ) { - $resultsList = array(); + $resultsList = []; foreach ( $this->parsers as $i => $parser ) { $resultsList[] = var_export( $results[$i], true ); } diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 49c6ce94e2..d2559f748b 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -120,13 +120,13 @@ class ParserOptions { * Callback for current revision fetching. Used as first argument to call_user_func(). */ private $mCurrentRevisionCallback = - array( 'Parser', 'statelessFetchRevision' ); + [ 'Parser', 'statelessFetchRevision' ]; /** * Callback for template fetching. Used as first argument to call_user_func(). */ private $mTemplateCallback = - array( 'Parser', 'statelessFetchTemplate' ); + [ 'Parser', 'statelessFetchTemplate' ]; /** * Enable limit report in an HTML comment on output @@ -690,10 +690,10 @@ class ParserOptions { */ public function matches( ParserOptions $other ) { $fields = array_keys( get_class_vars( __CLASS__ ) ); - $fields = array_diff( $fields, array( + $fields = array_diff( $fields, [ 'mEnableLimitReport', // only effects HTML comments 'onAccessCallback', // only used for ParserOutput option tracking - ) ); + ] ); foreach ( $fields as $field ) { if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) { return false; @@ -736,14 +736,14 @@ class ParserOptions { * @return array */ public static function legacyOptions() { - return array( + return [ 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' - ); + ]; } /** @@ -832,7 +832,7 @@ class ParserOptions { // Give a chance for extensions to modify the hash, if they have // extra options or other effects on the parser cache. - Hooks::run( 'PageRenderingHash', array( &$confstr, $this->getUser(), &$forOptions ) ); + Hooks::run( 'PageRenderingHash', [ &$confstr, $this->getUser(), &$forOptions ] ); // Make it a valid memcached key fragment $confstr = str_replace( ' ', '_', $confstr ); @@ -856,14 +856,14 @@ class ParserOptions { $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback ) { if ( $titleToCheck->equals( $title ) ) { - return new Revision( array( + return new Revision( [ 'page' => $title->getArticleID(), 'user_text' => $user->getName(), 'user' => $user->getId(), 'parent_id' => $title->getLatestRevId(), 'title' => $title, 'content' => $content - ) ); + ] ); } else { return call_user_func( $oldCallback, $titleToCheck, $parser ); } diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 656e580aea..40c67dd785 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -41,7 +41,7 @@ class ParserOutput extends CacheTime { /** * @var array $mIndicators Page status indicators, usually displayed in top-right corner. */ - public $mIndicators = array(); + public $mIndicators = []; /** * @var string $mTitleText Title text of the chosen language variant, as HTML. @@ -52,40 +52,40 @@ class ParserOutput extends CacheTime { * @var array $mLinks 2-D map of NS/DBK to ID for the links in the document. * ID=zero for broken. */ - public $mLinks = array(); + public $mLinks = []; /** * @var array $mTemplates 2-D map of NS/DBK to ID for the template references. * ID=zero for broken. */ - public $mTemplates = array(); + public $mTemplates = []; /** * @var array $mTemplateIds 2-D map of NS/DBK to rev ID for the template references. * ID=zero for broken. */ - public $mTemplateIds = array(); + public $mTemplateIds = []; /** * @var array $mImages DB keys of the images used, in the array key only */ - public $mImages = array(); + public $mImages = []; /** * @var array $mFileSearchOptions DB keys of the images used mapped to sha1 and MW timestamp. */ - public $mFileSearchOptions = array(); + public $mFileSearchOptions = []; /** * @var array $mExternalLinks External link URLs, in the key only. */ - public $mExternalLinks = array(); + public $mExternalLinks = []; /** * @var array $mInterwikiLinks 2-D map of prefix/DBK (in keys only) * for the inline interwiki links in the document. */ - public $mInterwikiLinks = array(); + public $mInterwikiLinks = []; /** * @var bool $mNewSection Show a new section link? @@ -105,43 +105,43 @@ class ParserOutput extends CacheTime { /** * @var array $mHeadItems Items to put in the section */ - public $mHeadItems = array(); + public $mHeadItems = []; /** * @var array $mModules Modules to be loaded by ResourceLoader */ - public $mModules = array(); + public $mModules = []; /** * @var array $mModuleScripts Modules of which only the JS will be loaded by ResourceLoader. */ - public $mModuleScripts = array(); + public $mModuleScripts = []; /** * @var array $mModuleStyles Modules of which only the CSSS will be loaded by ResourceLoader. */ - public $mModuleStyles = array(); + public $mModuleStyles = []; /** * @var array $mJsConfigVars JavaScript config variable for mw.config combined with this page. */ - public $mJsConfigVars = array(); + public $mJsConfigVars = []; /** * @var array $mOutputHooks Hook tags as per $wgParserOutputHooks. */ - public $mOutputHooks = array(); + public $mOutputHooks = []; /** * @var array $mWarnings Warning text to be returned to the user. * Wikitext formatted, in the key only. */ - public $mWarnings = array(); + public $mWarnings = []; /** * @var array $mSections Table of contents */ - public $mSections = array(); + public $mSections = []; /** * @var bool $mEditSectionTokens prefix/suffix markers if edit sections were output as tokens. @@ -151,7 +151,7 @@ class ParserOutput extends CacheTime { /** * @var array $mProperties Name/value pairs to be cached in the DB. */ - public $mProperties = array(); + public $mProperties = []; /** * @var string $mTOCHTML HTML of the TOC. @@ -181,22 +181,22 @@ class ParserOutput extends CacheTime { /** * @var array $mAccessedOptions List of ParserOptions (stored in the keys). */ - private $mAccessedOptions = array(); + private $mAccessedOptions = []; /** * @var array $mExtensionData extra data used by extensions. */ - private $mExtensionData = array(); + private $mExtensionData = []; /** * @var array $mLimitReportData Parser limit report data. */ - private $mLimitReportData = array(); + private $mLimitReportData = []; /** * @var array $mParseStartTime Timestamps for getTimeSinceStart(). */ - private $mParseStartTime = array(); + private $mParseStartTime = []; /** * @var bool $mPreventClickjacking Whether to emit X-Frame-Options: DENY. @@ -206,12 +206,12 @@ class ParserOutput extends CacheTime { /** * @var array $mFlags Generic flags. */ - private $mFlags = array(); + private $mFlags = []; const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)())#'; - public function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(), + public function __construct( $text = '', $languageLinks = [], $categoryLinks = [], $unused = false, $titletext = '' ) { $this->mText = $text; @@ -248,9 +248,9 @@ class ParserOutput extends CacheTime { $skin = $wgOut->getSkin(); return call_user_func_array( - array( $skin, 'doEditSectionLink' ), - array( $editsectionPage, $editsectionSection, - $editsectionContent, $wgLang->getCode() ) + [ $skin, 'doEditSectionLink' ], + [ $editsectionPage, $editsectionSection, + $editsectionContent, $wgLang->getCode() ] ); }, $text @@ -261,7 +261,7 @@ class ParserOutput extends CacheTime { // If you have an old cached version of this class - sorry, you can't disable the TOC if ( isset( $this->mTOCEnabled ) && $this->mTOCEnabled ) { - $text = str_replace( array( Parser::TOC_START, Parser::TOC_END ), '', $text ); + $text = str_replace( [ Parser::TOC_START, Parser::TOC_END ], '', $text ); } else { $text = preg_replace( '#' . preg_quote( Parser::TOC_START, '#' ) . '.*?' . preg_quote( Parser::TOC_END, '#' ) . '#s', @@ -357,7 +357,7 @@ class ParserOutput extends CacheTime { */ public function getModuleMessages() { wfDeprecated( __METHOD__, '1.26' ); - return array(); + return []; } /** @since 1.23 */ @@ -468,7 +468,7 @@ class ParserOutput extends CacheTime { } public function addOutputHook( $hook, $data = false ) { - $this->mOutputHooks[] = array( $hook, $data ); + $this->mOutputHooks[] = [ $hook, $data ]; } public function setNewSection( $value ) { @@ -541,7 +541,7 @@ class ParserOutput extends CacheTime { return; } if ( !isset( $this->mLinks[$ns] ) ) { - $this->mLinks[$ns] = array(); + $this->mLinks[$ns] = []; } if ( is_null( $id ) ) { $id = $title->getArticleID(); @@ -559,7 +559,7 @@ class ParserOutput extends CacheTime { public function addImage( $name, $timestamp = null, $sha1 = null ) { $this->mImages[$name] = 1; if ( $timestamp !== null && $sha1 !== null ) { - $this->mFileSearchOptions[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 ); + $this->mFileSearchOptions[$name] = [ 'time' => $timestamp, 'sha1' => $sha1 ]; } } @@ -574,11 +574,11 @@ class ParserOutput extends CacheTime { $ns = $title->getNamespace(); $dbk = $title->getDBkey(); if ( !isset( $this->mTemplates[$ns] ) ) { - $this->mTemplates[$ns] = array(); + $this->mTemplates[$ns] = []; } $this->mTemplates[$ns][$dbk] = $page_id; if ( !isset( $this->mTemplateIds[$ns] ) ) { - $this->mTemplateIds[$ns] = array(); + $this->mTemplateIds[$ns] = []; } $this->mTemplateIds[$ns][$dbk] = $rev_id; // For versioning } @@ -593,7 +593,7 @@ class ParserOutput extends CacheTime { } $prefix = $title->getInterwiki(); if ( !isset( $this->mInterwikiLinks[$prefix] ) ) { - $this->mInterwikiLinks[$prefix] = array(); + $this->mInterwikiLinks[$prefix] = []; } $this->mInterwikiLinks[$prefix][$title->getDBkey()] = 1; } @@ -833,7 +833,7 @@ class ParserOutput extends CacheTime { public function getProperties() { if ( !isset( $this->mProperties ) ) { - $this->mProperties = array(); + $this->mProperties = []; } return $this->mProperties; } @@ -845,7 +845,7 @@ class ParserOutput extends CacheTime { */ public function getUsedOptions() { if ( !isset( $this->mAccessedOptions ) ) { - return array(); + return []; } return array_keys( $this->mAccessedOptions ); } @@ -934,7 +934,7 @@ class ParserOutput extends CacheTime { } private static function getTimes( $clock = null ) { - $ret = array(); + $ret = []; if ( !$clock || $clock === 'wall' ) { $ret['wall'] = microtime( true ); } @@ -1033,7 +1033,7 @@ class ParserOutput extends CacheTime { public function __sleep() { return array_diff( array_keys( get_object_vars( $this ) ), - array( 'mParseStartTime' ) + [ 'mParseStartTime' ] ); } } diff --git a/includes/parser/Preprocessor.php b/includes/parser/Preprocessor.php index df5d4995b4..255fef8adc 100644 --- a/includes/parser/Preprocessor.php +++ b/includes/parser/Preprocessor.php @@ -33,23 +33,23 @@ abstract class Preprocessor { /** * @var array Brace matching rules. */ - protected $rules = array( - '{' => array( + protected $rules = [ + '{' => [ 'end' => '}', - 'names' => array( + 'names' => [ 2 => 'template', 3 => 'tplarg', - ), + ], 'min' => 2, 'max' => 3, - ), - '[' => array( + ], + '[' => [ 'end' => ']', - 'names' => array( 2 => null ), + 'names' => [ 2 => null ], 'min' => 2, 'max' => 2, - ) - ); + ] + ]; /** * Store a document tree in the cache. diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 4ca3a878bd..79a66e05e8 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -198,8 +198,8 @@ class Preprocessor_DOM extends Preprocessor { $xmlishElements = $this->parser->getStripList(); $enableOnlyinclude = false; if ( $forInclusion ) { - $ignoredTags = array( 'includeonly', '/includeonly' ); - $ignoredElements = array( 'noinclude' ); + $ignoredTags = [ 'includeonly', '/includeonly' ]; + $ignoredElements = [ 'noinclude' ]; $xmlishElements[] = 'noinclude'; if ( strpos( $text, '' ) !== false && strpos( $text, '' ) !== false @@ -207,8 +207,8 @@ class Preprocessor_DOM extends Preprocessor { $enableOnlyinclude = true; } } else { - $ignoredTags = array( 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' ); - $ignoredElements = array( 'includeonly' ); + $ignoredTags = [ 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' ]; + $ignoredElements = [ 'includeonly' ]; $xmlishElements[] = 'includeonly'; } $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) ); @@ -364,14 +364,14 @@ class Preprocessor_DOM extends Preprocessor { // Keep looking forward as long as we're finding more // comments. - $comments = array( array( $wsStart, $wsEnd ) ); + $comments = [ [ $wsStart, $wsEnd ] ]; while ( substr( $text, $wsEnd + 1, 4 ) == '', $wsEnd + 4 ); if ( $c === false ) { break; } $c = $c + 2 + strspn( $text, " \t", $c + 3 ); - $comments[] = array( $wsEnd + 1, $c ); + $comments[] = [ $wsEnd + 1, $c ]; $wsEnd = $c; } @@ -509,12 +509,12 @@ class Preprocessor_DOM extends Preprocessor { // methods for completely correct disambiguation are very // complex. } elseif ( $count > 0 ) { - $piece = array( + $piece = [ 'open' => "\n", 'close' => "\n", - 'parts' => array( new PPDPart( str_repeat( '=', $count ) ) ), + 'parts' => [ new PPDPart( str_repeat( '=', $count ) ) ], 'startPos' => $i, - 'count' => $count ); + 'count' => $count ]; $stack->push( $piece ); $accum =& $stack->getAccum(); $flags = $stack->getFlags(); @@ -585,12 +585,12 @@ class Preprocessor_DOM extends Preprocessor { # we need to add to stack only if opening brace count is enough for one of the rules if ( $count >= $rule['min'] ) { # Add it to the stack - $piece = array( + $piece = [ 'open' => $curChar, 'close' => $rule['end'], 'count' => $count, 'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ), - ); + ]; $stack->push( $piece ); $accum =& $stack->getAccum(); @@ -675,7 +675,7 @@ class Preprocessor_DOM extends Preprocessor { # Re-add the old stack element if it still has unmatched opening characters remaining if ( $matchingCount < $piece->count ) { - $piece->parts = array( new PPDPart ); + $piece->parts = [ new PPDPart ]; $piece->count -= $matchingCount; # do we still qualify for any callback with remaining count? $min = $this->rules[$piece->open]['min']; @@ -732,7 +732,7 @@ class PPDStack { public static $false = false; public function __construct() { - $this->stack = array(); + $this->stack = []; $this->top = false; $this->rootAccum = ''; $this->accum =& $this->rootAccum; @@ -794,11 +794,11 @@ class PPDStack { */ public function getFlags() { if ( !count( $this->stack ) ) { - return array( + return [ 'findEquals' => false, 'findPipe' => false, 'inHeading' => false, - ); + ]; } else { return $this->top->getFlags(); } @@ -837,9 +837,9 @@ class PPDStackElement { public $partClass = 'PPDPart'; - public function __construct( $data = array() ) { + public function __construct( $data = [] ) { $class = $this->partClass; - $this->parts = array( new $class ); + $this->parts = [ new $class ]; foreach ( $data as $name => $value ) { $this->$name = $value; @@ -865,11 +865,11 @@ class PPDStackElement { public function getFlags() { $partCount = count( $this->parts ); $findPipe = $this->open != "\n" && $this->open != '['; - return array( + return [ 'findPipe' => $findPipe, 'findEquals' => $findPipe && $partCount > 1 && !isset( $this->parts[$partCount - 1]->eqpos ), 'inHeading' => $this->open == "\n", - ); + ]; } /** @@ -971,10 +971,10 @@ class PPFrame_DOM implements PPFrame { $this->preprocessor = $preprocessor; $this->parser = $preprocessor->parser; $this->title = $this->parser->mTitle; - $this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false ); - $this->loopCheckHash = array(); + $this->titleCache = [ $this->title ? $this->title->getPrefixedDBkey() : false ]; + $this->loopCheckHash = []; $this->depth = 0; - $this->childExpansionCache = array(); + $this->childExpansionCache = []; } /** @@ -987,8 +987,8 @@ class PPFrame_DOM implements PPFrame { * @return PPTemplateFrame_DOM */ public function newChild( $args = false, $title = false, $indexOffset = 0 ) { - $namedArgs = array(); - $numberedArgs = array(); + $namedArgs = []; + $numberedArgs = []; if ( $title === false ) { $title = $this->title; } @@ -1089,9 +1089,9 @@ class PPFrame_DOM implements PPFrame { $root = $root->documentElement; } - $outStack = array( '', '' ); - $iteratorStack = array( false, $root ); - $indexStack = array( 0, 0 ); + $outStack = [ '', '' ]; + $iteratorStack = [ false, $root ]; + $indexStack = [ 0, 0 ]; while ( count( $iteratorStack ) > 1 ) { $level = count( $outStack ) - 1; @@ -1153,10 +1153,10 @@ class PPFrame_DOM implements PPFrame { $newIterator = $this->virtualBracketedImplode( '{{', '|', '}}', $title, $parts ); } else { $lineStart = $contextNode->getAttribute( 'lineStart' ); - $params = array( + $params = [ 'title' => new PPNode_DOM( $title ), 'parts' => new PPNode_DOM( $parts ), - 'lineStart' => $lineStart ); + 'lineStart' => $lineStart ]; $ret = $this->parser->braceSubstitution( $params, $this ); if ( isset( $ret['object'] ) ) { $newIterator = $ret['object']; @@ -1173,9 +1173,9 @@ class PPFrame_DOM implements PPFrame { if ( $flags & PPFrame::NO_ARGS ) { $newIterator = $this->virtualBracketedImplode( '{{{', '|', '}}}', $title, $parts ); } else { - $params = array( + $params = [ 'title' => new PPNode_DOM( $title ), - 'parts' => new PPNode_DOM( $parts ) ); + 'parts' => new PPNode_DOM( $parts ) ]; $ret = $this->parser->argSubstitution( $params, $this ); if ( isset( $ret['object'] ) ) { $newIterator = $ret['object']; @@ -1236,12 +1236,12 @@ class PPFrame_DOM implements PPFrame { } $out .= $s; } else { - $params = array( + $params = [ 'name' => new PPNode_DOM( $names->item( 0 ) ), 'attr' => $attrs->length > 0 ? new PPNode_DOM( $attrs->item( 0 ) ) : null, 'inner' => $inners->length > 0 ? new PPNode_DOM( $inners->item( 0 ) ) : null, 'close' => $closes->length > 0 ? new PPNode_DOM( $closes->item( 0 ) ) : null, - ); + ]; $out .= $this->parser->extensionSubstitution( $params, $this ); } } elseif ( $contextNode->nodeName == 'h' ) { @@ -1254,7 +1254,7 @@ class PPFrame_DOM implements PPFrame { # Insert heading index marker $headingIndex = $contextNode->getAttribute( 'i' ); $titleText = $this->title->getPrefixedDBkey(); - $this->parser->mHeadings[] = array( $titleText, $headingIndex ); + $this->parser->mHeadings[] = [ $titleText, $headingIndex ]; $serial = count( $this->parser->mHeadings ) - 1; $marker = Parser::MARKER_PREFIX . "-h-$serial-" . Parser::MARKER_SUFFIX; $count = $contextNode->getAttribute( 'level' ); @@ -1309,7 +1309,7 @@ class PPFrame_DOM implements PPFrame { $root = $root->node; } if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1341,7 +1341,7 @@ class PPFrame_DOM implements PPFrame { $root = $root->node; } if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1365,7 +1365,7 @@ class PPFrame_DOM implements PPFrame { */ public function virtualImplode( $sep /*, ... */ ) { $args = array_slice( func_get_args(), 1 ); - $out = array(); + $out = []; $first = true; foreach ( $args as $root ) { @@ -1373,7 +1373,7 @@ class PPFrame_DOM implements PPFrame { $root = $root->node; } if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1397,7 +1397,7 @@ class PPFrame_DOM implements PPFrame { */ public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) { $args = array_slice( func_get_args(), 3 ); - $out = array( $start ); + $out = [ $start ]; $first = true; foreach ( $args as $root ) { @@ -1405,7 +1405,7 @@ class PPFrame_DOM implements PPFrame { $root = $root->node; } if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1436,21 +1436,21 @@ class PPFrame_DOM implements PPFrame { * @return array */ public function getArguments() { - return array(); + return []; } /** * @return array */ public function getNumberedArguments() { - return array(); + return []; } /** * @return array */ public function getNamedArguments() { - return array(); + return []; } /** @@ -1556,8 +1556,8 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { * @param array $namedArgs * @param bool|Title $title */ - public function __construct( $preprocessor, $parent = false, $numberedArgs = array(), - $namedArgs = array(), $title = false + public function __construct( $preprocessor, $parent = false, $numberedArgs = [], + $namedArgs = [], $title = false ) { parent::__construct( $preprocessor ); @@ -1573,7 +1573,7 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { $this->loopCheckHash[$pdbk] = true; } $this->depth = $parent->depth + 1; - $this->numberedExpansionCache = $this->namedExpansionCache = array(); + $this->numberedExpansionCache = $this->namedExpansionCache = []; } public function __toString() { @@ -1621,7 +1621,7 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { } public function getArguments() { - $arguments = array(); + $arguments = []; foreach ( array_merge( array_keys( $this->numberedArgs ), array_keys( $this->namedArgs ) ) as $key ) { @@ -1631,7 +1631,7 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { } public function getNumberedArguments() { - $arguments = array(); + $arguments = []; foreach ( array_keys( $this->numberedArgs ) as $key ) { $arguments[$key] = $this->getArgument( $key ); } @@ -1639,7 +1639,7 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { } public function getNamedArguments() { - $arguments = array(); + $arguments = []; foreach ( array_keys( $this->namedArgs ) as $key ) { $arguments[$key] = $this->getArgument( $key ); } @@ -1868,10 +1868,10 @@ class PPNode_DOM implements PPNode { } $name = $names->item( 0 ); $index = $name->getAttribute( 'index' ); - return array( + return [ 'name' => new self( $name ), 'index' => $index, - 'value' => new self( $values->item( 0 ) ) ); + 'value' => new self( $values->item( 0 ) ) ]; } /** @@ -1890,9 +1890,9 @@ class PPNode_DOM implements PPNode { if ( !$names->length || !$attrs->length ) { throw new MWException( 'Invalid ext node passed to ' . __METHOD__ ); } - $parts = array( + $parts = [ 'name' => new self( $names->item( 0 ) ), - 'attr' => new self( $attrs->item( 0 ) ) ); + 'attr' => new self( $attrs->item( 0 ) ) ]; if ( $inners->length ) { $parts['inner'] = new self( $inners->item( 0 ) ); } @@ -1911,10 +1911,10 @@ class PPNode_DOM implements PPNode { if ( $this->getName() !== 'h' ) { throw new MWException( 'Invalid h node passed to ' . __METHOD__ ); } - return array( + return [ 'i' => $this->node->getAttribute( 'i' ), 'level' => $this->node->getAttribute( 'level' ), 'contents' => $this->getChildren() - ); + ]; } } diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 50eaefbce3..df0e38618c 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -62,7 +62,7 @@ class Preprocessor_Hash extends Preprocessor { * @return PPNode_Hash_Array */ public function newPartNodeArray( $values ) { - $list = array(); + $list = []; foreach ( $values as $k => $val ) { $partNode = new PPNode_Hash_Tree( 'part' ); @@ -122,8 +122,8 @@ class Preprocessor_Hash extends Preprocessor { $xmlishElements = $this->parser->getStripList(); $enableOnlyinclude = false; if ( $forInclusion ) { - $ignoredTags = array( 'includeonly', '/includeonly' ); - $ignoredElements = array( 'noinclude' ); + $ignoredTags = [ 'includeonly', '/includeonly' ]; + $ignoredElements = [ 'noinclude' ]; $xmlishElements[] = 'noinclude'; if ( strpos( $text, '' ) !== false && strpos( $text, '' ) !== false @@ -131,8 +131,8 @@ class Preprocessor_Hash extends Preprocessor { $enableOnlyinclude = true; } } else { - $ignoredTags = array( 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' ); - $ignoredElements = array( 'includeonly' ); + $ignoredTags = [ 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' ]; + $ignoredElements = [ 'includeonly' ]; $xmlishElements[] = 'includeonly'; } $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) ); @@ -287,14 +287,14 @@ class Preprocessor_Hash extends Preprocessor { // Keep looking forward as long as we're finding more // comments. - $comments = array( array( $wsStart, $wsEnd ) ); + $comments = [ [ $wsStart, $wsEnd ] ]; while ( substr( $text, $wsEnd + 1, 4 ) == '', $wsEnd + 4 ); if ( $c === false ) { break; } $c = $c + 2 + strspn( $text, " \t", $c + 3 ); - $comments[] = array( $wsEnd + 1, $c ); + $comments[] = [ $wsEnd + 1, $c ]; $wsEnd = $c; } @@ -434,12 +434,12 @@ class Preprocessor_Hash extends Preprocessor { // heading. This is heuristic, but AFAICT the methods for // completely correct disambiguation are very complex. } elseif ( $count > 0 ) { - $piece = array( + $piece = [ 'open' => "\n", 'close' => "\n", - 'parts' => array( new PPDPart_Hash( str_repeat( '=', $count ) ) ), + 'parts' => [ new PPDPart_Hash( str_repeat( '=', $count ) ) ], 'startPos' => $i, - 'count' => $count ); + 'count' => $count ]; $stack->push( $piece ); $accum =& $stack->getAccum(); extract( $stack->getFlags() ); @@ -515,12 +515,12 @@ class Preprocessor_Hash extends Preprocessor { # we need to add to stack only if opening brace count is enough for one of the rules if ( $count >= $rule['min'] ) { # Add it to the stack - $piece = array( + $piece = [ 'open' => $curChar, 'close' => $rule['end'], 'count' => $count, 'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ), - ); + ]; $stack->push( $piece ); $accum =& $stack->getAccum(); @@ -646,7 +646,7 @@ class Preprocessor_Hash extends Preprocessor { # Re-add the old stack element if it still has unmatched opening characters remaining if ( $matchingCount < $piece->count ) { - $piece->parts = array( new PPDPart_Hash ); + $piece->parts = [ new PPDPart_Hash ]; $piece->count -= $matchingCount; # do we still qualify for any callback with remaining count? $min = $this->rules[$piece->open]['min']; @@ -896,10 +896,10 @@ class PPFrame_Hash implements PPFrame { $this->preprocessor = $preprocessor; $this->parser = $preprocessor->parser; $this->title = $this->parser->mTitle; - $this->titleCache = array( $this->title ? $this->title->getPrefixedDBkey() : false ); - $this->loopCheckHash = array(); + $this->titleCache = [ $this->title ? $this->title->getPrefixedDBkey() : false ]; + $this->loopCheckHash = []; $this->depth = 0; - $this->childExpansionCache = array(); + $this->childExpansionCache = []; } /** @@ -913,8 +913,8 @@ class PPFrame_Hash implements PPFrame { * @return PPTemplateFrame_Hash */ public function newChild( $args = false, $title = false, $indexOffset = 0 ) { - $namedArgs = array(); - $numberedArgs = array(); + $namedArgs = []; + $numberedArgs = []; if ( $title === false ) { $title = $this->title; } @@ -999,9 +999,9 @@ class PPFrame_Hash implements PPFrame { $this->parser->mHighestExpansionDepth = $expansionDepth; } - $outStack = array( '', '' ); - $iteratorStack = array( false, $root ); - $indexStack = array( 0, 0 ); + $outStack = [ '', '' ]; + $iteratorStack = [ false, $root ]; + $indexStack = [ 0, 0 ]; while ( count( $iteratorStack ) > 1 ) { $level = count( $outStack ) - 1; @@ -1114,7 +1114,7 @@ class PPFrame_Hash implements PPFrame { } } elseif ( $contextNode->name == 'ext' ) { # Extension tag - $bits = $contextNode->splitExt() + array( 'attr' => null, 'inner' => null, 'close' => null ); + $bits = $contextNode->splitExt() + [ 'attr' => null, 'inner' => null, 'close' => null ]; if ( $flags & PPFrame::NO_TAGS ) { $s = '<' . $bits['name']->firstChild->value; if ( $bits['attr'] ) { @@ -1143,7 +1143,7 @@ class PPFrame_Hash implements PPFrame { $bits = $contextNode->splitHeading(); $titleText = $this->title->getPrefixedDBkey(); - $this->parser->mHeadings[] = array( $titleText, $bits['i'] ); + $this->parser->mHeadings[] = [ $titleText, $bits['i'] ]; $serial = count( $this->parser->mHeadings ) - 1; $marker = Parser::MARKER_PREFIX . "-h-$serial-" . Parser::MARKER_SUFFIX; $s = substr( $s, 0, $bits['level'] ) . $marker . substr( $s, $bits['level'] ); @@ -1197,7 +1197,7 @@ class PPFrame_Hash implements PPFrame { $root = $root->value; } if ( !is_array( $root ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1228,7 +1228,7 @@ class PPFrame_Hash implements PPFrame { $root = $root->value; } if ( !is_array( $root ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1252,7 +1252,7 @@ class PPFrame_Hash implements PPFrame { */ public function virtualImplode( $sep /*, ... */ ) { $args = array_slice( func_get_args(), 1 ); - $out = array(); + $out = []; $first = true; foreach ( $args as $root ) { @@ -1260,7 +1260,7 @@ class PPFrame_Hash implements PPFrame { $root = $root->value; } if ( !is_array( $root ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1285,7 +1285,7 @@ class PPFrame_Hash implements PPFrame { */ public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) { $args = array_slice( func_get_args(), 3 ); - $out = array( $start ); + $out = [ $start ]; $first = true; foreach ( $args as $root ) { @@ -1293,7 +1293,7 @@ class PPFrame_Hash implements PPFrame { $root = $root->value; } if ( !is_array( $root ) ) { - $root = array( $root ); + $root = [ $root ]; } foreach ( $root as $node ) { if ( $first ) { @@ -1328,21 +1328,21 @@ class PPFrame_Hash implements PPFrame { * @return array */ public function getArguments() { - return array(); + return []; } /** * @return array */ public function getNumberedArguments() { - return array(); + return []; } /** * @return array */ public function getNamedArguments() { - return array(); + return []; } /** @@ -1448,8 +1448,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { * @param array $namedArgs * @param bool|Title $title */ - public function __construct( $preprocessor, $parent = false, $numberedArgs = array(), - $namedArgs = array(), $title = false + public function __construct( $preprocessor, $parent = false, $numberedArgs = [], + $namedArgs = [], $title = false ) { parent::__construct( $preprocessor ); @@ -1465,7 +1465,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { $this->loopCheckHash[$pdbk] = true; } $this->depth = $parent->depth + 1; - $this->numberedExpansionCache = $this->namedExpansionCache = array(); + $this->numberedExpansionCache = $this->namedExpansionCache = []; } public function __toString() { @@ -1516,7 +1516,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { * @return array */ public function getArguments() { - $arguments = array(); + $arguments = []; foreach ( array_merge( array_keys( $this->numberedArgs ), array_keys( $this->namedArgs ) ) as $key ) { @@ -1529,7 +1529,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { * @return array */ public function getNumberedArguments() { - $arguments = array(); + $arguments = []; foreach ( array_keys( $this->numberedArgs ) as $key ) { $arguments[$key] = $this->getArgument( $key ); } @@ -1540,7 +1540,7 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { * @return array */ public function getNamedArguments() { - $arguments = array(); + $arguments = []; foreach ( array_keys( $this->namedArgs ) as $key ) { $arguments[$key] = $this->getArgument( $key ); } @@ -1722,7 +1722,7 @@ class PPNode_Hash_Tree implements PPNode { * @return PPNode_Hash_Array */ public function getChildren() { - $children = array(); + $children = []; for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) { $children[] = $child; } @@ -1738,7 +1738,7 @@ class PPNode_Hash_Tree implements PPNode { } public function getChildrenOfType( $name ) { - $children = array(); + $children = []; for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) { if ( isset( $child->name ) && $child->name === $name ) { $children[] = $child; @@ -1779,7 +1779,7 @@ class PPNode_Hash_Tree implements PPNode { * @return array */ public function splitArg() { - $bits = array(); + $bits = []; for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) { if ( !isset( $child->name ) ) { continue; @@ -1813,7 +1813,7 @@ class PPNode_Hash_Tree implements PPNode { * @return array */ public function splitExt() { - $bits = array(); + $bits = []; for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) { if ( !isset( $child->name ) ) { continue; @@ -1844,7 +1844,7 @@ class PPNode_Hash_Tree implements PPNode { if ( $this->name !== 'h' ) { throw new MWException( 'Invalid h node passed to ' . __METHOD__ ); } - $bits = array(); + $bits = []; for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) { if ( !isset( $child->name ) ) { continue; @@ -1868,8 +1868,8 @@ class PPNode_Hash_Tree implements PPNode { * @return array */ public function splitTemplate() { - $parts = array(); - $bits = array( 'lineStart' => '' ); + $parts = []; + $bits = [ 'lineStart' => '' ]; for ( $child = $this->firstChild; $child; $child = $child->nextSibling ) { if ( !isset( $child->name ) ) { continue; diff --git a/includes/parser/StripState.php b/includes/parser/StripState.php index b11dc8c388..c168aa69fa 100644 --- a/includes/parser/StripState.php +++ b/includes/parser/StripState.php @@ -46,12 +46,12 @@ class StripState { wfDeprecated( __METHOD__ . ' with called with $prefix argument' . ' (call with no arguments instead)', '1.26' ); } - $this->data = array( - 'nowiki' => array(), - 'general' => array() - ); + $this->data = [ + 'nowiki' => [], + 'general' => [] + ]; $this->regex = '/' . Parser::MARKER_PREFIX . "([^\x7f]+)" . Parser::MARKER_SUFFIX . '/'; - $this->circularRefGuard = array(); + $this->circularRefGuard = []; } /** @@ -124,7 +124,7 @@ class StripState { $oldType = $this->tempType; $this->tempType = $type; - $text = preg_replace_callback( $this->regex, array( $this, 'unstripCallback' ), $text ); + $text = preg_replace_callback( $this->regex, [ $this, 'unstripCallback' ], $text ); $this->tempType = $oldType; return $text; } @@ -216,7 +216,7 @@ class StripState { } $this->tempMergePrefix = $mergePrefix; - $texts = preg_replace_callback( $otherState->regex, array( $this, 'mergeCallback' ), $texts ); + $texts = preg_replace_callback( $otherState->regex, [ $this, 'mergeCallback' ], $texts ); $this->tempMergePrefix = null; return $texts; } diff --git a/includes/password/BcryptPassword.php b/includes/password/BcryptPassword.php index dd806e26c0..f811e3f514 100644 --- a/includes/password/BcryptPassword.php +++ b/includes/password/BcryptPassword.php @@ -30,9 +30,9 @@ */ class BcryptPassword extends ParameterizedPassword { protected function getDefaultParams() { - return array( + return [ 'rounds' => $this->config['cost'], - ); + ]; } protected function getDelimiter() { diff --git a/includes/password/EncryptedPassword.php b/includes/password/EncryptedPassword.php index 6723793cc1..7b3d9f9cf7 100644 --- a/includes/password/EncryptedPassword.php +++ b/includes/password/EncryptedPassword.php @@ -32,10 +32,10 @@ class EncryptedPassword extends ParameterizedPassword { } protected function getDefaultParams() { - return array( + return [ 'cipher' => $this->config['cipher'], 'secret' => count( $this->config['secrets'] ) - 1 - ); + ]; } public function crypt( $password ) { @@ -55,7 +55,7 @@ class EncryptedPassword extends ParameterizedPassword { $this->hash = openssl_encrypt( $underlyingPassword->toString(), $this->params['cipher'], $secret, 0, $iv ); - $this->args = array( base64_encode( $iv ) ); + $this->args = [ base64_encode( $iv ) ]; } /** @@ -91,7 +91,7 @@ class EncryptedPassword extends ParameterizedPassword { 0, $iv ) ); - $this->args = array( base64_encode( $iv ) ); + $this->args = [ base64_encode( $iv ) ]; return true; } diff --git a/includes/password/LayeredParameterizedPassword.php b/includes/password/LayeredParameterizedPassword.php index 5735e28213..841305481a 100644 --- a/includes/password/LayeredParameterizedPassword.php +++ b/includes/password/LayeredParameterizedPassword.php @@ -36,7 +36,7 @@ class LayeredParameterizedPassword extends ParameterizedPassword { } protected function getDefaultParams() { - $params = array(); + $params = []; foreach ( $this->config['types'] as $type ) { $passObj = $this->factory->newFromType( $type ); diff --git a/includes/password/MWOldPassword.php b/includes/password/MWOldPassword.php index afa5cacc78..2150e56215 100644 --- a/includes/password/MWOldPassword.php +++ b/includes/password/MWOldPassword.php @@ -28,7 +28,7 @@ */ class MWOldPassword extends ParameterizedPassword { protected function getDefaultParams() { - return array(); + return []; } protected function getDelimiter() { @@ -41,7 +41,7 @@ class MWOldPassword extends ParameterizedPassword { if ( $wgPasswordSalt && count( $this->args ) === 1 ) { $this->hash = md5( $this->args[0] . '-' . md5( $plaintext ) ); } else { - $this->args = array(); + $this->args = []; $this->hash = md5( $plaintext ); } } diff --git a/includes/password/MWSaltedPassword.php b/includes/password/MWSaltedPassword.php index f061f52857..26730b17b3 100644 --- a/includes/password/MWSaltedPassword.php +++ b/includes/password/MWSaltedPassword.php @@ -29,7 +29,7 @@ */ class MWSaltedPassword extends ParameterizedPassword { protected function getDefaultParams() { - return array(); + return []; } protected function getDelimiter() { diff --git a/includes/password/ParameterizedPassword.php b/includes/password/ParameterizedPassword.php index 187f895421..954d403bf8 100644 --- a/includes/password/ParameterizedPassword.php +++ b/includes/password/ParameterizedPassword.php @@ -40,14 +40,14 @@ abstract class ParameterizedPassword extends Password { * Named parameters that have default values for this password type * @var array */ - protected $params = array(); + protected $params = []; /** * Extra arguments that were found in the hash. This may or may not make * the hash invalid. * @var array */ - protected $args = array(); + protected $args = []; protected function parseHash( $hash ) { parent::parseHash( $hash ); diff --git a/includes/password/PasswordFactory.php b/includes/password/PasswordFactory.php index f80e158b9d..3383fe385e 100644 --- a/includes/password/PasswordFactory.php +++ b/includes/password/PasswordFactory.php @@ -40,9 +40,9 @@ final class PasswordFactory { * @see PasswordFactory::register * @see Setup.php */ - private $types = array( - '' => array( 'type' => '', 'class' => 'InvalidPassword' ), - ); + private $types = [ + '' => [ 'type' => '', 'class' => 'InvalidPassword' ], + ]; /** * Register a new type of password hash @@ -112,7 +112,7 @@ final class PasswordFactory { */ public function newFromCiphertext( $hash ) { if ( $hash === null || $hash === false || $hash === '' ) { - return new InvalidPassword( $this, array( 'type' => '' ), null ); + return new InvalidPassword( $this, [ 'type' => '' ], null ); } elseif ( $hash[0] !== ':' ) { throw new PasswordError( 'Invalid hash given' ); } @@ -156,7 +156,7 @@ final class PasswordFactory { */ public function newFromPlaintext( $password, Password $existing = null ) { if ( $password === null ) { - return new InvalidPassword( $this, array( 'type' => '' ), null ); + return new InvalidPassword( $this, [ 'type' => '' ], null ); } if ( $existing === null ) { @@ -216,7 +216,7 @@ final class PasswordFactory { if ( $password === null ) { $factory = new self(); - $password = new InvalidPassword( $factory, array( 'type' => '' ), null ); + $password = new InvalidPassword( $factory, [ 'type' => '' ], null ); } return $password; diff --git a/includes/password/PasswordPolicyChecks.php b/includes/password/PasswordPolicyChecks.php index b1098f5b84..7ea87c37b8 100644 --- a/includes/password/PasswordPolicyChecks.php +++ b/includes/password/PasswordPolicyChecks.php @@ -98,10 +98,10 @@ class PasswordPolicyChecks { * @return Status error if username and password match, and policy is true */ public static function checkPasswordCannotMatchBlacklist( $policyVal, User $user, $password ) { - static $blockedLogins = array( + static $blockedLogins = [ 'Useruser' => 'Passpass', 'Useruser1' => 'Passpass1', # r75589 'Apitestsysop' => 'testpass', 'Apitestuser' => 'testpass' # r75605 - ); + ]; $status = Status::newGood(); $username = $user->getName(); @@ -136,7 +136,7 @@ class PasswordPolicyChecks { // in the common password file. Also check '' for people who use // just whitespace. $sitename = $langEn->lc( trim( $wgSitename ) ); - $hardcodedCommonPasswords = array( '', 'wiki', 'mediawiki', $sitename ); + $hardcodedCommonPasswords = [ '', 'wiki', 'mediawiki', $sitename ]; if ( in_array( $passwordKey, $hardcodedCommonPasswords ) ) { $status->error( 'passwordtoopopular' ); return $status; diff --git a/includes/password/Pbkdf2Password.php b/includes/password/Pbkdf2Password.php index 080e3b0ddb..8ef6f8de28 100644 --- a/includes/password/Pbkdf2Password.php +++ b/includes/password/Pbkdf2Password.php @@ -30,11 +30,11 @@ */ class Pbkdf2Password extends ParameterizedPassword { protected function getDefaultParams() { - return array( + return [ 'algo' => $this->config['algo'], 'rounds' => $this->config['cost'], 'length' => $this->config['length'] - ); + ]; } protected function getDelimiter() { diff --git a/includes/password/UserPasswordPolicy.php b/includes/password/UserPasswordPolicy.php index d57adb8e15..5584f6f162 100644 --- a/includes/password/UserPasswordPolicy.php +++ b/includes/password/UserPasswordPolicy.php @@ -147,7 +147,7 @@ class UserPasswordPolicy { ); } - Hooks::run( 'PasswordPoliciesForUser', array( $user, &$effectivePolicy, $purpose ) ); + Hooks::run( 'PasswordPoliciesForUser', [ $user, &$effectivePolicy, $purpose ] ); return $effectivePolicy; } @@ -184,7 +184,7 @@ class UserPasswordPolicy { * @return array containing the more restrictive values of $p1 and $p2 */ public static function maxOfPolicies( array $p1, array $p2 ) { - $ret = array(); + $ret = []; $keys = array_merge( array_keys( $p1 ), array_keys( $p2 ) ); foreach ( $keys as $key ) { if ( !isset( $p1[$key] ) ) { diff --git a/includes/poolcounter/PoolCounterRedis.php b/includes/poolcounter/PoolCounterRedis.php index 6dd0b353f5..f2c59d2da1 100644 --- a/includes/poolcounter/PoolCounterRedis.php +++ b/includes/poolcounter/PoolCounterRedis.php @@ -93,8 +93,8 @@ class PoolCounterRedis extends PoolCounter { $this->lockTTL = $met ? 2 * $met : 3600; if ( self::$active === null ) { - self::$active = array(); - register_shutdown_function( array( __CLASS__, 'releaseAll' ) ); + self::$active = []; + register_shutdown_function( [ __CLASS__, 'releaseAll' ] ); } } @@ -191,7 +191,7 @@ LUA; try { $conn->luaEval( $script, - array( + [ $this->getSlotListKey(), $this->getSlotRTimeSetKey(), $this->getWakeupListKey(), @@ -202,7 +202,7 @@ LUA; $this->slotTime, // used for CAS-style sanity check ( $this->onRelease === self::AWAKE_ALL ) ? 1 : 0, microtime( true ) - ), + ], 4 # number of first argument(s) that are keys ); } catch ( RedisException $e ) { @@ -247,12 +247,12 @@ LUA; // This process is now registered as waiting $keys = ( $doWakeup == self::AWAKE_ALL ) // Wait for an open slot or wake-up signal (preferring the later) - ? array( $this->getWakeupListKey(), $this->getSlotListKey() ) + ? [ $this->getWakeupListKey(), $this->getSlotListKey() ] // Just wait for an actual pool slot - : array( $this->getSlotListKey() ); + : [ $this->getSlotListKey() ]; $res = $conn->blPop( $keys, $this->timeout ); - if ( $res === array() ) { + if ( $res === [] ) { $conn->zRem( $this->getWaitSetKey(), $this->session ); // no longer waiting return Status::newGood( PoolCounter::TIMEOUT ); } @@ -332,7 +332,7 @@ LUA; return slot LUA; return $conn->luaEval( $script, - array( + [ $this->getSlotListKey(), $this->getSlotRTimeSetKey(), $this->getWaitSetKey(), @@ -342,7 +342,7 @@ LUA; $this->lockTTL, $this->session, $now - ), + ], 3 # number of first argument(s) that are keys ); } @@ -371,7 +371,7 @@ LUA; return 1 LUA; return $conn->luaEval( $script, - array( + [ $this->getSlotListKey(), $this->getSlotRTimeSetKey(), $this->getWaitSetKey(), @@ -379,7 +379,7 @@ LUA; $this->lockTTL, $this->session, $now - ), + ], 3 # number of first argument(s) that are keys ); } diff --git a/includes/poolcounter/PoolCounterWork.php b/includes/poolcounter/PoolCounterWork.php index c0be7a1b08..e61b65ad72 100644 --- a/includes/poolcounter/PoolCounterWork.php +++ b/includes/poolcounter/PoolCounterWork.php @@ -146,9 +146,9 @@ abstract class PoolCounterWork { /* These two cases should never be hit... */ case PoolCounter::ERROR: default: - $errors = array( + $errors = [ PoolCounter::QUEUE_FULL => 'pool-queuefull', - PoolCounter::TIMEOUT => 'pool-timeout' ); + PoolCounter::TIMEOUT => 'pool-timeout' ]; $status = Status::newFatal( isset( $errors[$status->value] ) ? $errors[$status->value] diff --git a/includes/poolcounter/PoolCounterWorkViaCallback.php b/includes/poolcounter/PoolCounterWorkViaCallback.php index af83d2e069..85a7cef6ef 100644 --- a/includes/poolcounter/PoolCounterWorkViaCallback.php +++ b/includes/poolcounter/PoolCounterWorkViaCallback.php @@ -51,7 +51,7 @@ class PoolCounterWorkViaCallback extends PoolCounterWork { */ public function __construct( $type, $key, array $callbacks ) { parent::__construct( $type, $key ); - foreach ( array( 'doWork', 'doCachedWork', 'fallback', 'error' ) as $name ) { + foreach ( [ 'doWork', 'doCachedWork', 'fallback', 'error' ] as $name ) { if ( isset( $callbacks[$name] ) ) { if ( !is_callable( $callbacks[$name] ) ) { throw new MWException( "Invalid callback provided for '$name' function." ); @@ -66,26 +66,26 @@ class PoolCounterWorkViaCallback extends PoolCounterWork { } public function doWork() { - return call_user_func_array( $this->doWork, array() ); + return call_user_func_array( $this->doWork, [] ); } public function getCachedWork() { if ( $this->doCachedWork ) { - return call_user_func_array( $this->doCachedWork, array() ); + return call_user_func_array( $this->doCachedWork, [] ); } return false; } public function fallback() { if ( $this->fallback ) { - return call_user_func_array( $this->fallback, array() ); + return call_user_func_array( $this->fallback, [] ); } return false; } public function error( $status ) { if ( $this->error ) { - return call_user_func_array( $this->error, array( $status ) ); + return call_user_func_array( $this->error, [ $status ] ); } return false; } diff --git a/includes/poolcounter/PoolWorkArticleView.php b/includes/poolcounter/PoolWorkArticleView.php index 3c60ea9f53..7ddedb93f4 100644 --- a/includes/poolcounter/PoolWorkArticleView.php +++ b/includes/poolcounter/PoolWorkArticleView.php @@ -144,11 +144,11 @@ class PoolWorkArticleView extends PoolCounterWork { if ( $time > 3 ) { // TODO: Use Parser's logger (once it has one) $logger = MediaWiki\Logger\LoggerFactory::getInstance( 'slow-parse' ); - $logger->info( '{time} {title}', array( + $logger->info( '{time} {title}', [ 'time' => number_format( $time, 2 ), 'title' => $this->page->getTitle()->getPrefixedDBkey(), 'trigger' => 'view', - ) ); + ] ); } if ( $this->cacheable && $this->parserOutput->isCacheable() && $isCurrent ) { diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index 4d643bf44a..297dcb20a1 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -34,7 +34,7 @@ abstract class Profiler { /** @var bool Whether MediaWiki is in a SkinTemplate output context */ protected $templated = false; /** @var array All of the params passed from $wgProfiler */ - protected $params = array(); + protected $params = []; /** @var IContextSource Current request context */ protected $context = null; /** @var TransactionProfiler */ @@ -61,12 +61,12 @@ abstract class Profiler { if ( self::$instance === null ) { global $wgProfiler, $wgProfileLimit; - $params = array( + $params = [ 'class' => 'ProfilerStub', 'sampling' => 1, 'threshold' => $wgProfileLimit, - 'output' => array(), - ); + 'output' => [], + ]; if ( is_array( $wgProfiler ) ) { $params = array_merge( $params, $wgProfiler ); } @@ -77,7 +77,7 @@ abstract class Profiler { } if ( !is_array( $params['output'] ) ) { - $params['output'] = array( $params['output'] ); + $params['output'] = [ $params['output'] ]; } self::$instance = new $params['class']( $params ); @@ -189,7 +189,7 @@ abstract class Profiler { * @since 1.25 */ private function getOutputs() { - $outputs = array(); + $outputs = []; foreach ( $this->params['output'] as $outputType ) { // The class may be specified as either the full class name (for // example, 'ProfilerOutputStats') or (for backward compatibility) diff --git a/includes/profiler/ProfilerSectionOnly.php b/includes/profiler/ProfilerSectionOnly.php index 1f8d33b192..0ce8087675 100644 --- a/includes/profiler/ProfilerSectionOnly.php +++ b/includes/profiler/ProfilerSectionOnly.php @@ -35,7 +35,7 @@ class ProfilerSectionOnly extends Profiler { /** @var SectionProfiler */ protected $sprofiler; - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { parent::__construct( $params ); $this->sprofiler = new SectionProfiler(); } @@ -83,7 +83,7 @@ class ProfilerSectionOnly extends Profiler { $width = 140; $nameWidth = $width - 65; $format = "%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d"; - $out = array(); + $out = []; $out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s", 'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%', 'Mem' ); diff --git a/includes/profiler/ProfilerXhprof.php b/includes/profiler/ProfilerXhprof.php index 5f7fc0028a..7c4fde40e8 100644 --- a/includes/profiler/ProfilerXhprof.php +++ b/includes/profiler/ProfilerXhprof.php @@ -66,7 +66,7 @@ class ProfilerXhprof extends Profiler { * @param array $params * @see Xhprof::__construct() */ - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { parent::__construct( $params ); $this->xhprof = new Xhprof( $params ); $this->sprofiler = new SectionProfiler(); @@ -113,7 +113,7 @@ class ProfilerXhprof extends Profiler { public function getFunctionStats() { $metrics = $this->xhprof->getCompleteMetrics(); - $profile = array(); + $profile = []; $main = null; // units in ms foreach ( $metrics as $fname => $stats ) { @@ -121,7 +121,7 @@ class ProfilerXhprof extends Profiler { continue; } // Convert elapsed times from μs to ms to match interface - $entry = array( + $entry = [ 'name' => $fname, 'calls' => $stats['ct'], 'real' => $stats['wt']['total'] / 1000, @@ -132,7 +132,7 @@ class ProfilerXhprof extends Profiler { '%memory' => isset( $stats['mu'] ) ? $stats['mu']['percent'] : 0, 'min_real' => $stats['wt']['min'] / 1000, 'max_real' => $stats['wt']['max'] / 1000 - ); + ]; $profile[] = $entry; if ( $fname === 'main()' ) { $main = $entry; @@ -192,7 +192,7 @@ class ProfilerXhprof extends Profiler { $width = 140; $nameWidth = $width - 65; $format = "%-{$nameWidth}s %6d %9d %9d %9d %9d %7.3f%% %9d"; - $out = array(); + $out = []; $out[] = sprintf( "%-{$nameWidth}s %6s %9s %9s %9s %9s %7s %9s", 'Name', 'Calls', 'Total', 'Min', 'Each', 'Max', '%', 'Mem' ); diff --git a/includes/profiler/SectionProfiler.php b/includes/profiler/SectionProfiler.php index 63940bc914..04ec841480 100644 --- a/includes/profiler/SectionProfiler.php +++ b/includes/profiler/SectionProfiler.php @@ -33,12 +33,12 @@ class SectionProfiler { /** @var array Map of (mem,real,cpu) */ protected $end; /** @var array List of resolved profile calls with start/end data */ - protected $stack = array(); + protected $stack = []; /** @var array Queue of open profile calls with start data */ - protected $workStack = array(); + protected $workStack = []; /** @var array Map of (function name => aggregate data array) */ - protected $collated = array(); + protected $collated = []; /** @var bool */ protected $collateDone = false; @@ -52,7 +52,7 @@ class SectionProfiler { /** * @param array $params */ - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { $this->errorEntry = $this->getErrorEntry(); $this->collateOnly = empty( $params['trace'] ); $this->profileOutCallback = function ( $profiler, $section ) { @@ -105,9 +105,9 @@ class SectionProfiler { $totalReal = max( $this->end['real'] - $this->start['real'], 0 ); $totalMem = max( $this->end['memory'] - $this->start['memory'], 0 ); - $profile = array(); + $profile = []; foreach ( $this->collated as $fname => $data ) { - $profile[] = array( + $profile[] = [ 'name' => $fname, 'calls' => $data['count'], 'real' => $data['real'] * 1000, @@ -118,10 +118,10 @@ class SectionProfiler { '%memory' => $totalMem ? 100 * $data['memory'] / $totalMem : 0, 'min_real' => 1000 * $data['min_real'], 'max_real' => 1000 * $data['max_real'] - ); + ]; } - $profile[] = array( + $profile[] = [ 'name' => '-total', 'calls' => 1, 'real' => 1000 * $totalReal, @@ -132,7 +132,7 @@ class SectionProfiler { '%memory' => 100, 'min_real' => 1000 * $totalReal, 'max_real' => 1000 * $totalReal - ); + ]; return $profile; } @@ -143,9 +143,9 @@ class SectionProfiler { public function reset() { $this->start = null; $this->end = null; - $this->stack = array(); - $this->workStack = array(); - $this->collated = array(); + $this->stack = []; + $this->workStack = []; + $this->collated = []; $this->collateDone = false; } @@ -153,14 +153,14 @@ class SectionProfiler { * @return array Initial collation entry */ protected function getZeroEntry() { - return array( + return [ 'cpu' => 0.0, 'real' => 0.0, 'memory' => 0, 'count' => 0, 'min_real' => 0.0, 'max_real' => 0.0 - ); + ]; } /** @@ -210,16 +210,16 @@ class SectionProfiler { $memory = memory_get_usage(); if ( $this->start === null ) { - $this->start = array( 'cpu' => $cpu, 'real' => $real, 'memory' => $memory ); + $this->start = [ 'cpu' => $cpu, 'real' => $real, 'memory' => $memory ]; } - $this->workStack[] = array( + $this->workStack[] = [ $functionname, count( $this->workStack ), $real, $cpu, $memory - ); + ]; } /** @@ -241,7 +241,7 @@ class SectionProfiler { if ( $this->collateOnly ) { $this->collated[$message] = $this->errorEntry; } else { - $this->stack[] = array( $message, 0, 0.0, 0.0, 0, 0.0, 0.0, 0 ); + $this->stack[] = [ $message, 0, 0.0, 0.0, 0, 0.0, 0.0, 0 ]; } $functionname = $ofname; } elseif ( $ofname !== $functionname ) { @@ -250,7 +250,7 @@ class SectionProfiler { if ( $this->collateOnly ) { $this->collated[$message] = $this->errorEntry; } else { - $this->stack[] = array( $message, 0, 0.0, 0.0, 0, 0.0, 0.0, 0 ); + $this->stack[] = [ $message, 0, 0.0, 0.0, 0, 0.0, 0.0, 0 ]; } } @@ -264,14 +264,14 @@ class SectionProfiler { $memchange = $memUsage - $omem; $this->updateEntry( $functionname, $elapsedcpu, $elapsedreal, $memchange ); } else { - $this->stack[] = array_merge( $item, array( $realTime, $cpuTime, $memUsage ) ); + $this->stack[] = array_merge( $item, [ $realTime, $cpuTime, $memUsage ] ); } - $this->end = array( + $this->end = [ 'cpu' => $cpuTime, 'real' => $realTime, 'memory' => $memUsage - ); + ]; } /** @@ -284,7 +284,7 @@ class SectionProfiler { throw new Exception( "Tree is only available for trace profiling." ); } return implode( '', array_map( - array( $this, 'getCallTreeLine' ), $this->remapCallTree( $this->stack ) + [ $this, 'getCallTreeLine' ], $this->remapCallTree( $this->stack ) ) ); } @@ -298,11 +298,11 @@ class SectionProfiler { if ( count( $stack ) < 2 ) { return $stack; } - $outputs = array(); + $outputs = []; for ( $max = count( $stack ) - 1; $max > 0; ) { /* Find all items under this entry */ $level = $stack[$max][1]; - $working = array(); + $working = []; for ( $i = $max -1; $i >= 0; $i-- ) { if ( $stack[$i][1] > $level ) { $working[] = $stack[$i]; @@ -311,7 +311,7 @@ class SectionProfiler { } } $working = $this->remapCallTree( array_reverse( $working ) ); - $output = array(); + $output = []; foreach ( $working as $item ) { array_push( $output, $item ); } @@ -320,7 +320,7 @@ class SectionProfiler { array_unshift( $outputs, $output ); } - $final = array(); + $final = []; foreach ( $outputs as $output ) { foreach ( $output as $item ) { $final[] = $item; @@ -362,7 +362,7 @@ class SectionProfiler { return; // already collated as methods exited } - $this->collated = array(); + $this->collated = []; # Estimate profiling overhead $oldEnd = $this->end; @@ -370,7 +370,7 @@ class SectionProfiler { $this->calculateOverhead( $profileCount ); # First, subtract the overhead! - $overheadTotal = $overheadMemory = $overheadInternal = array(); + $overheadTotal = $overheadMemory = $overheadInternal = []; foreach ( $this->stack as $entry ) { // $entry is (name,pos,rtime0,cputime0,mem0,rtime1,cputime1,mem1) $fname = $entry[0]; diff --git a/includes/profiler/TransactionProfiler.php b/includes/profiler/TransactionProfiler.php index 2c9d108c9b..1aba71c3fa 100644 --- a/includes/profiler/TransactionProfiler.php +++ b/includes/profiler/TransactionProfiler.php @@ -40,19 +40,19 @@ class TransactionProfiler implements LoggerAwareInterface { protected $eventThreshold = .25; /** @var array transaction ID => (write start time, list of DBs involved) */ - protected $dbTrxHoldingLocks = array(); + protected $dbTrxHoldingLocks = []; /** @var array transaction ID => list of (query name, start time, end time) */ - protected $dbTrxMethodTimes = array(); + protected $dbTrxMethodTimes = []; /** @var array */ - protected $hits = array( + protected $hits = [ 'writes' => 0, 'queries' => 0, 'conns' => 0, 'masterConns' => 0 - ); + ]; /** @var array */ - protected $expect = array( + protected $expect = [ 'writes' => INF, 'queries' => INF, 'conns' => INF, @@ -60,9 +60,9 @@ class TransactionProfiler implements LoggerAwareInterface { 'maxAffected' => INF, 'readQueryTime' => INF, 'writeQueryTime' => INF - ); + ]; /** @var array */ - protected $expectBy = array(); + protected $expectBy = []; /** * @var LoggerInterface @@ -125,7 +125,7 @@ class TransactionProfiler implements LoggerAwareInterface { $val = INF; } unset( $val ); - $this->expectBy = array(); + $this->expectBy = []; } /** @@ -161,11 +161,11 @@ class TransactionProfiler implements LoggerAwareInterface { if ( isset( $this->dbTrxHoldingLocks[$name] ) ) { $this->logger->info( "Nested transaction for '$name' - out of sync." ); } - $this->dbTrxHoldingLocks[$name] = array( + $this->dbTrxHoldingLocks[$name] = [ 'start' => microtime( true ), - 'conns' => array(), // all connections involved - ); - $this->dbTrxMethodTimes[$name] = array(); + 'conns' => [], // all connections involved + ]; + $this->dbTrxMethodTimes[$name] = []; foreach ( $this->dbTrxHoldingLocks as $name => &$info ) { // Track all DBs in transactions for this transaction @@ -223,14 +223,14 @@ class TransactionProfiler implements LoggerAwareInterface { if ( $sTime >= $lastEnd ) { // sanity check if ( ( $sTime - $lastEnd ) > $this->eventThreshold ) { // Add an entry representing the time spent doing non-queries - $this->dbTrxMethodTimes[$name][] = array( '...delay...', $lastEnd, $sTime ); + $this->dbTrxMethodTimes[$name][] = [ '...delay...', $lastEnd, $sTime ]; } - $this->dbTrxMethodTimes[$name][] = array( $query, $sTime, $eTime ); + $this->dbTrxMethodTimes[$name][] = [ $query, $sTime, $eTime ]; } } else { // First query in the trx... if ( $sTime >= $info['start'] ) { // sanity check - $this->dbTrxMethodTimes[$name][] = array( $query, $sTime, $eTime ); + $this->dbTrxMethodTimes[$name][] = [ $query, $sTime, $eTime ]; } } } @@ -272,7 +272,7 @@ class TransactionProfiler implements LoggerAwareInterface { $now = microtime( true ); $lastEnd = $lastQuery[2]; if ( ( $now - $lastEnd ) > $this->eventThreshold ) { - $this->dbTrxMethodTimes[$name][] = array( '...delay...', $lastEnd, $now ); + $this->dbTrxMethodTimes[$name][] = [ '...delay...', $lastEnd, $now ]; } } // Check for any slow queries or non-query periods... diff --git a/includes/profiler/output/ProfilerOutput.php b/includes/profiler/output/ProfilerOutput.php index 3473e0b20b..ddf084e81c 100644 --- a/includes/profiler/output/ProfilerOutput.php +++ b/includes/profiler/output/ProfilerOutput.php @@ -28,7 +28,7 @@ abstract class ProfilerOutput { /** @var Profiler */ protected $collector; /** @var array Configuration of $wgProfiler */ - protected $params = array(); + protected $params = []; /** * Constructor diff --git a/includes/profiler/output/ProfilerOutputDb.php b/includes/profiler/output/ProfilerOutputDb.php index 5efb3ab241..088721c0f7 100644 --- a/includes/profiler/output/ProfilerOutputDb.php +++ b/includes/profiler/output/ProfilerOutputDb.php @@ -66,19 +66,19 @@ class ProfilerOutputDb extends ProfilerOutput { $memorySum = $memorySum >= 0 ? $memorySum : 0; $dbw->upsert( 'profiling', - array( + [ 'pf_name' => $name, 'pf_count' => $eventCount, 'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost - ), - array( array( 'pf_name', 'pf_server' ) ), - array( + ], + [ [ 'pf_name', 'pf_server' ] ], + [ "pf_count=pf_count+{$eventCount}", "pf_time=pf_time+{$timeSum}", "pf_memory=pf_memory+{$memorySum}", - ), + ], __METHOD__ ); } diff --git a/includes/rcfeed/IRCColourfulRCFeedFormatter.php b/includes/rcfeed/IRCColourfulRCFeedFormatter.php index 0efcebf9a3..c800c36fd2 100644 --- a/includes/rcfeed/IRCColourfulRCFeedFormatter.php +++ b/includes/rcfeed/IRCColourfulRCFeedFormatter.php @@ -56,7 +56,7 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter { $query .= '&rcid=' . $attribs['rc_id']; } // HACK: We need this hook for WMF's secure server setup - Hooks::run( 'IRCLineURL', array( &$url, &$query, $rc ) ); + Hooks::run( 'IRCLineURL', [ &$url, &$query, $rc ] ); $url .= $query; } @@ -124,8 +124,8 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter { */ public static function cleanupForIRC( $text ) { return str_replace( - array( "\n", "\r" ), - array( " ", "" ), + [ "\n", "\r" ], + [ " ", "" ], Sanitizer::decodeCharReferences( $text ) ); } diff --git a/includes/rcfeed/MachineReadableRCFeedFormatter.php b/includes/rcfeed/MachineReadableRCFeedFormatter.php index f524361ab1..20f88bd97c 100644 --- a/includes/rcfeed/MachineReadableRCFeedFormatter.php +++ b/includes/rcfeed/MachineReadableRCFeedFormatter.php @@ -40,7 +40,7 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter { public function getLine( array $feed, RecentChange $rc, $actionComment ) { global $wgCanonicalServer, $wgServerName, $wgScriptPath; - $packet = array( + $packet = [ // Usually, RC ID is exposed only for patrolling purposes, // but there is no real reason not to expose it in other cases, // and I can see how this may be potentially useful for clients. @@ -52,7 +52,7 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter { 'timestamp' => (int)wfTimestamp( TS_UNIX, $rc->getAttribute( 'rc_timestamp' ) ), 'user' => $rc->getAttribute( 'rc_user_text' ), 'bot' => (bool)$rc->getAttribute( 'rc_bot' ), - ); + ]; if ( isset( $feed['channel'] ) ) { $packet['channel'] = $feed['channel']; @@ -70,19 +70,19 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter { switch ( $type ) { case RC_EDIT: - $packet['length'] = array( + $packet['length'] = [ 'old' => $rc->getAttribute( 'rc_old_len' ), 'new' => $rc->getAttribute( 'rc_new_len' ) - ); - $packet['revision'] = array( + ]; + $packet['revision'] = [ 'old' => $rc->getAttribute( 'rc_last_oldid' ), 'new' => $rc->getAttribute( 'rc_this_oldid' ) - ); + ]; break; case RC_NEW: - $packet['length'] = array( 'old' => null, 'new' => $rc->getAttribute( 'rc_new_len' ) ); - $packet['revision'] = array( 'old' => null, 'new' => $rc->getAttribute( 'rc_this_oldid' ) ); + $packet['length'] = [ 'old' => null, 'new' => $rc->getAttribute( 'rc_new_len' ) ]; + $packet['revision'] = [ 'old' => null, 'new' => $rc->getAttribute( 'rc_this_oldid' ) ]; break; case RC_LOG: @@ -98,7 +98,7 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter { $params !== false ) { // From ApiQueryLogEvents::addLogParams - $logParams = array(); + $logParams = []; // Keys like "4::paramname" can't be used for output so we change them to "paramname" foreach ( $params as $key => $value ) { if ( strpos( $key, ':' ) === false ) { diff --git a/includes/rcfeed/RedisPubSubFeedEngine.php b/includes/rcfeed/RedisPubSubFeedEngine.php index b9023b6b84..c10e959fa2 100644 --- a/includes/rcfeed/RedisPubSubFeedEngine.php +++ b/includes/rcfeed/RedisPubSubFeedEngine.php @@ -44,7 +44,7 @@ class RedisPubSubFeedEngine implements RCFeedEngine { public function send( array $feed, $line ) { $parsed = wfParseUrl( $feed['uri'] ); $server = $parsed['host']; - $options = array( 'serializer' => 'none' ); + $options = [ 'serializer' => 'none' ]; $channel = 'rc'; if ( isset( $parsed['port'] ) ) { diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 6ac25e8414..2318c87b03 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -7,7 +7,7 @@ class ExtensionProcessor implements Processor { * * @var array */ - protected static $globalSettings = array( + protected static $globalSettings = [ 'ResourceLoaderSources', 'ResourceLoaderLESSVars', 'ResourceLoaderLESSImportPaths', @@ -46,7 +46,7 @@ class ExtensionProcessor implements Processor { 'APIListModules', 'ValidSkinNames', 'FeedClasses', - ); + ]; /** * Mapping of global settings to their specific merge strategies. @@ -55,7 +55,7 @@ class ExtensionProcessor implements Processor { * @see getExtractedInfo * @var array */ - protected static $mergeStrategies = array( + protected static $mergeStrategies = [ 'wgGroupPermissions' => 'array_plus_2d', 'wgRevokePermissions' => 'array_plus_2d', 'wgHooks' => 'array_merge_recursive', @@ -66,14 +66,14 @@ class ExtensionProcessor implements Processor { 'wgNamespaceProtection' => 'array_plus', 'wgCapitalLinkOverrides' => 'array_plus', 'wgRateLimits' => 'array_plus_2d', - ); + ]; /** * Keys that are part of the extension credits * * @var array */ - protected static $creditsAttributes = array( + protected static $creditsAttributes = [ 'name', 'namemsg', 'author', @@ -82,7 +82,7 @@ class ExtensionProcessor implements Processor { 'description', 'descriptionmsg', 'license-name', - ); + ]; /** * Things that are not 'attributes', but are not in @@ -90,7 +90,7 @@ class ExtensionProcessor implements Processor { * * @var array */ - protected static $notAttributes = array( + protected static $notAttributes = [ 'callback', 'Hooks', 'namespaces', @@ -105,7 +105,7 @@ class ExtensionProcessor implements Processor { 'AutoloadClasses', 'manifest_version', 'load_composer_autoloader', - ); + ]; /** * Stuff that is going to be set to $GLOBALS @@ -114,29 +114,29 @@ class ExtensionProcessor implements Processor { * * @var array */ - protected $globals = array( - 'wgExtensionMessagesFiles' => array(), - 'wgMessagesDirs' => array(), - ); + protected $globals = [ + 'wgExtensionMessagesFiles' => [], + 'wgMessagesDirs' => [], + ]; /** * Things that should be define()'d * * @var array */ - protected $defines = array(); + protected $defines = []; /** * Things to be called once registration of these extensions are done * * @var callable[] */ - protected $callbacks = array(); + protected $callbacks = []; /** * @var array */ - protected $credits = array(); + protected $credits = []; /** * Any thing else in the $info that hasn't @@ -144,7 +144,7 @@ class ExtensionProcessor implements Processor { * * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * @param string $path @@ -186,17 +186,17 @@ class ExtensionProcessor implements Processor { } } - return array( + return [ 'globals' => $this->globals, 'defines' => $this->defines, 'callbacks' => $this->callbacks, 'credits' => $this->credits, 'attributes' => $this->attributes, - ); + ]; } public function getRequirements( array $info ) { - $requirements = array(); + $requirements = []; $key = ExtensionRegistry::MEDIAWIKI_CORE; if ( isset( $info['requires'][$key] ) ) { $requirements[$key] = $info['requires'][$key]; @@ -256,7 +256,7 @@ class ExtensionProcessor implements Processor { $defaultPaths['localBasePath'] = "$dir/{$defaultPaths['localBasePath']}"; } - foreach ( array( 'ResourceModules', 'ResourceModuleSkinStyles' ) as $setting ) { + foreach ( [ 'ResourceModules', 'ResourceModuleSkinStyles' ] as $setting ) { if ( isset( $info[$setting] ) ) { foreach ( $info[$setting] as $name => $data ) { if ( isset( $data['localBasePath'] ) ) { @@ -302,10 +302,10 @@ class ExtensionProcessor implements Processor { * @throws Exception */ protected function extractCredits( $path, array $info ) { - $credits = array( + $credits = [ 'path' => $path, 'type' => isset( $info['type'] ) ? $info['type'] : 'other', - ); + ]; foreach ( self::$creditsAttributes as $attr ) { if ( isset( $info[$attr] ) ) { $credits[$attr] = $info[$attr]; @@ -374,7 +374,7 @@ class ExtensionProcessor implements Processor { } public function getExtraAutoloaderPaths( $dir, array $info ) { - $paths = array(); + $paths = []; if ( isset( $info['load_composer_autoloader'] ) && $info['load_composer_autoloader'] === true ) { $path = "$dir/vendor/autoload.php"; if ( file_exists( $path ) ) { diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 86be86bba8..bc9b26d70c 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -48,14 +48,14 @@ class ExtensionRegistry { * * @var array */ - private $loaded = array(); + private $loaded = []; /** * List of paths that should be loaded * * @var array */ - protected $queued = array(); + protected $queued = []; /** * Items in the JSON file that aren't being @@ -63,7 +63,7 @@ class ExtensionRegistry { * * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * @var ExtensionRegistry @@ -120,10 +120,10 @@ class ExtensionRegistry { } // A few more things to vary the cache on - $versions = array( + $versions = [ 'registration' => self::CACHE_VERSION, 'mediawiki' => $wgVersion - ); + ]; // See if this queue is in APC $key = wfMemcKey( @@ -142,7 +142,7 @@ class ExtensionRegistry { unset( $data['autoload'] ); $this->cache->set( $key, $data, 60 * 60 * 24 ); } - $this->queued = array(); + $this->queued = []; } /** @@ -160,7 +160,7 @@ class ExtensionRegistry { * outside of the installer. */ public function clearQueue() { - $this->queued = array(); + $this->queued = []; } /** @@ -172,10 +172,10 @@ class ExtensionRegistry { */ public function readFromQueue( array $queue ) { global $wgVersion; - $autoloadClasses = array(); - $autoloaderPaths = array(); + $autoloadClasses = []; + $autoloaderPaths = []; $processor = new ExtensionProcessor(); - $incompatible = array(); + $incompatible = []; $coreVersionParser = new CoreVersionChecker( $wgVersion ); foreach ( $queue as $path => $mtime ) { $json = file_get_contents( $path ); @@ -224,7 +224,7 @@ class ExtensionRegistry { } $data = $processor->getExtractedInfo(); // Need to set this so we can += to it later - $data['globals']['wgAutoloadClasses'] = array(); + $data['globals']['wgAutoloadClasses'] = []; $data['autoload'] = $autoloadClasses; $data['autoloaderPaths'] = $autoloaderPaths; return $data; @@ -325,7 +325,7 @@ class ExtensionRegistry { if ( isset( $this->attributes[$name] ) ) { return $this->attributes[$name]; } else { - return array(); + return []; } } @@ -362,7 +362,7 @@ class ExtensionRegistry { return "$dir/$file"; }, $info['AutoloadClasses'] ); } else { - return array(); + return []; } } } diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 51a6225edf..a2ff294b08 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -47,13 +47,13 @@ class ResourceLoader implements LoggerAwareInterface { * Module name/ResourceLoaderModule object pairs * @var array */ - protected $modules = array(); + protected $modules = []; /** * Associative array mapping module name to info associative array * @var array */ - protected $moduleInfos = array(); + protected $moduleInfos = []; /** @var Config $config */ private $config; @@ -63,19 +63,19 @@ class ResourceLoader implements LoggerAwareInterface { * like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. ) * @var array */ - protected $testModuleNames = array(); + protected $testModuleNames = []; /** * E.g. array( 'source-id' => 'http://.../load.php' ) * @var array */ - protected $sources = array(); + protected $sources = []; /** * Errors accumulated during current respond() call. * @var array */ - protected $errors = array(); + protected $errors = []; /** * @var MessageBlobStore @@ -115,14 +115,14 @@ class ResourceLoader implements LoggerAwareInterface { // Batched version of ResourceLoaderModule::getFileDependencies $vary = "$skin|$lang"; - $res = $dbr->select( 'module_deps', array( 'md_module', 'md_deps' ), array( + $res = $dbr->select( 'module_deps', [ 'md_module', 'md_deps' ], [ 'md_module' => $moduleNames, 'md_skin' => $vary, - ), __METHOD__ + ], __METHOD__ ); // Prime in-object cache for file dependencies - $modulesWithDeps = array(); + $modulesWithDeps = []; foreach ( $res as $row ) { $module = $this->getModule( $row->md_module ); if ( $module ) { @@ -136,12 +136,12 @@ class ResourceLoader implements LoggerAwareInterface { foreach ( array_diff( $moduleNames, $modulesWithDeps ) as $name ) { $module = $this->getModule( $name ); if ( $module ) { - $this->getModule( $name )->setFileDependencies( $context, array() ); + $this->getModule( $name )->setFileDependencies( $context, [] ); } } // Prime in-object cache for message blobs for modules with messages - $modules = array(); + $modules = []; foreach ( $moduleNames as $name ) { $module = $this->getModule( $name ); if ( $module && $module->getMessages() ) { @@ -172,7 +172,7 @@ class ResourceLoader implements LoggerAwareInterface { * - (bool) cache: Whether to allow caching this data. Default: true. * @return string Filtered data, or a comment containing an error message */ - public static function filter( $filter, $data, Array $options = array() ) { + public static function filter( $filter, $data, Array $options = [] ) { if ( strpos( $data, ResourceLoader::FILTER_NOMIN ) !== false ) { return $data; } @@ -251,7 +251,7 @@ class ResourceLoader implements LoggerAwareInterface { $this->register( include "$IP/resources/ResourcesOOUI.php" ); // Register extension modules $this->register( $config->get( 'ResourceModules' ) ); - Hooks::run( 'ResourceLoaderRegisterModules', array( &$this ) ); + Hooks::run( 'ResourceLoaderRegisterModules', [ &$this ] ); if ( $config->get( 'EnableJavaScriptTest' ) === true ) { $this->registerTestModules(); @@ -315,7 +315,7 @@ class ResourceLoader implements LoggerAwareInterface { public function register( $name, $info = null ) { // Allow multiple modules to be registered in one call - $registrations = is_array( $name ) ? $name : array( $name => $info ); + $registrations = is_array( $name ) ? $name : [ $name => $info ]; foreach ( $registrations as $name => $info ) { // Warn on duplicate registrations if ( isset( $this->moduleInfos[$name] ) ) { @@ -334,7 +334,7 @@ class ResourceLoader implements LoggerAwareInterface { // Attach module if ( $info instanceof ResourceLoaderModule ) { - $this->moduleInfos[$name] = array( 'object' => $info ); + $this->moduleInfos[$name] = [ 'object' => $info ]; $info->setName( $name ); $this->modules[$name] = $info; } elseif ( is_array( $info ) ) { @@ -361,12 +361,12 @@ class ResourceLoader implements LoggerAwareInterface { // skinStyles, otherwise 'default' will be ignored as it normally would be. if ( isset( $skinStyles[$name] ) ) { $paths = (array)$skinStyles[$name]; - $styleFiles = array(); + $styleFiles = []; } elseif ( isset( $skinStyles['+' . $name] ) ) { $paths = (array)$skinStyles['+' . $name]; $styleFiles = isset( $this->moduleInfos[$name]['skinStyles']['default'] ) ? (array)$this->moduleInfos[$name]['skinStyles']['default'] : - array(); + []; } else { continue; } @@ -399,10 +399,10 @@ class ResourceLoader implements LoggerAwareInterface { } // Get core test suites - $testModules = array(); - $testModules['qunit'] = array(); + $testModules = []; + $testModules['qunit'] = []; // Get other test suites (e.g. from extensions) - Hooks::run( 'ResourceLoaderTestModules', array( &$testModules, &$this ) ); + Hooks::run( 'ResourceLoaderTestModules', [ &$testModules, &$this ] ); // Add the testrunner (which configures QUnit) to the dependencies. // Since it must be ready before any of the test suites are executed. @@ -496,7 +496,7 @@ class ResourceLoader implements LoggerAwareInterface { ) { return $this->testModuleNames[$framework]; } else { - return array(); + return []; } } @@ -640,8 +640,8 @@ class ResourceLoader implements LoggerAwareInterface { ob_start(); // Find out which modules are missing and instantiate the others - $modules = array(); - $missing = array(); + $modules = []; + $missing = []; foreach ( $context->getModules() as $name ) { $module = $this->getModule( $name ); if ( $module ) { @@ -663,9 +663,9 @@ class ResourceLoader implements LoggerAwareInterface { $this->preloadModuleInfo( array_keys( $modules ), $context ); } catch ( Exception $e ) { MWExceptionHandler::logException( $e ); - $this->logger->warning( 'Preloading module info failed: {exception}', array( + $this->logger->warning( 'Preloading module info failed: {exception}', [ 'exception' => $e - ) ); + ] ); $this->errors[] = self::formatExceptionNoComment( $e ); } @@ -675,9 +675,9 @@ class ResourceLoader implements LoggerAwareInterface { $versionHash = $this->getCombinedVersion( $context, array_keys( $modules ) ); } catch ( Exception $e ) { MWExceptionHandler::logException( $e ); - $this->logger->warning( 'Calculating version hash failed: {exception}', array( + $this->logger->warning( 'Calculating version hash failed: {exception}', [ 'exception' => $e - ) ); + ] ); $this->errors[] = self::formatExceptionNoComment( $e ); } @@ -735,7 +735,7 @@ class ResourceLoader implements LoggerAwareInterface { $errorResponse = self::makeComment( $errorText ); if ( $context->shouldIncludeScripts() ) { $errorResponse .= 'if (window.console && console.error) {' - . Xml::encodeJsCall( 'console.error', array( $errorText ) ) + . Xml::encodeJsCall( 'console.error', [ $errorText ] ) . "}\n"; } @@ -743,7 +743,7 @@ class ResourceLoader implements LoggerAwareInterface { $response = $errorResponse . $response; } - $this->errors = array(); + $this->errors = []; echo $response; } @@ -936,10 +936,10 @@ class ResourceLoader implements LoggerAwareInterface { * @return string Response data */ public function makeModuleResponse( ResourceLoaderContext $context, - array $modules, array $missing = array() + array $modules, array $missing = [] ) { $out = ''; - $states = array(); + $states = []; if ( !count( $modules ) && !count( $missing ) ) { return <<logger->warning( 'Generating module package failed: {exception}', array( + $this->logger->warning( 'Generating module package failed: {exception}', [ 'exception' => $e - ) ); + ] ); $this->errors[] = self::formatExceptionNoComment( $e ); // Respond to client with error-state instead of module implementation @@ -1058,7 +1058,7 @@ MESSAGE; * @return array List of module names */ public function getModulesByMessage( $messageKey ) { - $moduleNames = array(); + $moduleNames = []; foreach ( $this->getModuleNames() as $moduleName ) { $module = $this->getModule( $moduleName ); if ( in_array( $messageKey, $module->getMessages() ) ) { @@ -1106,13 +1106,13 @@ MESSAGE; // mw.loader.implement requires 'styles', 'messages' and 'templates' to be objects (not // arrays). json_encode considers empty arrays to be numerical and outputs "[]" instead // of "{}". Force them to objects. - $module = array( + $module = [ $name, $scripts, (object)$styles, (object)$messages, (object)$templates, - ); + ]; self::trimArray( $module ); return Xml::encodeJsCall( 'mw.loader.implement', $module, ResourceLoader::inDebugMode() ); @@ -1128,7 +1128,7 @@ MESSAGE; public static function makeMessageSetScript( $messages ) { return Xml::encodeJsCall( 'mw.messages.set', - array( (object)$messages ), + [ (object)$messages ], ResourceLoader::inDebugMode() ); } @@ -1141,7 +1141,7 @@ MESSAGE; * @return array */ public static function makeCombinedStyles( array $stylePairs ) { - $out = array(); + $out = []; foreach ( $stylePairs as $media => $styles ) { // ResourceLoaderFileModule::getStyle can return the styles // as a string or an array of strings. This is to allow separation in @@ -1185,13 +1185,13 @@ MESSAGE; if ( is_array( $name ) ) { return Xml::encodeJsCall( 'mw.loader.state', - array( $name ), + [ $name ], ResourceLoader::inDebugMode() ); } else { return Xml::encodeJsCall( 'mw.loader.state', - array( $name, $state ), + [ $name, $state ], ResourceLoader::inDebugMode() ); } @@ -1217,7 +1217,7 @@ MESSAGE; $script = str_replace( "\n", "\n\t", trim( $script ) ); return Xml::encodeJsCall( "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )", - array( $name, $version, $dependencies, $group, $source ), + [ $name, $version, $dependencies, $group, $source ], ResourceLoader::inDebugMode() ); } @@ -1245,7 +1245,7 @@ MESSAGE; $i = count( $array ); while ( $i-- ) { if ( $array[$i] === null - || $array[$i] === array() + || $array[$i] === [] || ( $array[$i] instanceof XmlJsCode && $array[$i]->value === '{}' ) || ( $array[$i] instanceof stdClass && self::isEmptyObject( $array[$i] ) ) ) { @@ -1288,7 +1288,7 @@ MESSAGE; ) { if ( is_array( $name ) ) { // Build module name index - $index = array(); + $index = []; foreach ( $name as $i => &$module ) { $index[$module[0]] = $i; } @@ -1305,15 +1305,15 @@ MESSAGE; } } - array_walk( $name, array( 'self', 'trimArray' ) ); + array_walk( $name, [ 'self', 'trimArray' ] ); return Xml::encodeJsCall( 'mw.loader.register', - array( $name ), + [ $name ], ResourceLoader::inDebugMode() ); } else { - $registration = array( $name, $version, $dependencies, $group, $source, $skip ); + $registration = [ $name, $version, $dependencies, $group, $source, $skip ]; self::trimArray( $registration ); return Xml::encodeJsCall( 'mw.loader.register', @@ -1341,13 +1341,13 @@ MESSAGE; if ( is_array( $id ) ) { return Xml::encodeJsCall( 'mw.loader.addSource', - array( $id ), + [ $id ], ResourceLoader::inDebugMode() ); } else { return Xml::encodeJsCall( 'mw.loader.addSource', - array( $id, $properties ), + [ $id, $properties ], ResourceLoader::inDebugMode() ); } @@ -1394,7 +1394,7 @@ MESSAGE; public static function makeConfigSetScript( array $configuration ) { return Xml::encodeJsCall( 'mw.config.set', - array( $configuration ), + [ $configuration ], ResourceLoader::inDebugMode() ) . ResourceLoader::FILTER_NOMIN; } @@ -1408,7 +1408,7 @@ MESSAGE; * @return string Packed query string */ public static function makePackedModulesString( $modules ) { - $groups = array(); // array( prefix => array( suffixes ) ) + $groups = []; // array( prefix => array( suffixes ) ) foreach ( $modules as $module ) { $pos = strrpos( $module, '.' ); $prefix = $pos === false ? '' : substr( $module, 0, $pos ); @@ -1416,7 +1416,7 @@ MESSAGE; $groups[$prefix][] = $suffix; } - $arr = array(); + $arr = []; foreach ( $groups as $prefix => $suffixes ) { $p = $prefix === '' ? '' : $prefix . '.'; $arr[] = $p . implode( ',', $suffixes ); @@ -1461,7 +1461,7 @@ MESSAGE; * @return string URL to load.php. May be protocol-relative if $wgLoadScript is, too. */ public function createLoaderURL( $source, ResourceLoaderContext $context, - $extraQuery = array() + $extraQuery = [] ) { $query = self::createLoaderQuery( $context, $extraQuery ); $script = $this->getLoadScript( $source ); @@ -1486,7 +1486,7 @@ MESSAGE; */ public static function makeLoaderURL( $modules, $lang, $skin, $user = null, $version = null, $debug = false, $only = null, $printable = false, - $handheld = false, $extraQuery = array() + $handheld = false, $extraQuery = [] ) { global $wgLoadScript; @@ -1506,7 +1506,7 @@ MESSAGE; * @param array $extraQuery * @return array */ - public static function createLoaderQuery( ResourceLoaderContext $context, $extraQuery = array() ) { + public static function createLoaderQuery( ResourceLoaderContext $context, $extraQuery = [] ) { return self::makeLoaderQuery( $context->getModules(), $context->getLanguage(), @@ -1540,14 +1540,14 @@ MESSAGE; */ public static function makeLoaderQuery( $modules, $lang, $skin, $user = null, $version = null, $debug = false, $only = null, $printable = false, - $handheld = false, $extraQuery = array() + $handheld = false, $extraQuery = [] ) { - $query = array( + $query = [ 'modules' => self::makePackedModulesString( $modules ), 'lang' => $lang, 'skin' => $skin, 'debug' => $debug ? 'true' : 'false', - ); + ]; if ( $user !== null ) { $query['user'] = $user; } @@ -1592,7 +1592,7 @@ MESSAGE; * @throws MWException * @return Less_Parser */ - public function getLessCompiler( $extraVars = array() ) { + public function getLessCompiler( $extraVars = [] ) { // When called from the installer, it is possible that a required PHP extension // is missing (at least for now; see bug 47564). If this is the case, throw an // exception (caught by the installer) to prevent a fatal error later on. @@ -1620,7 +1620,7 @@ MESSAGE; public function getLessVars() { if ( !$this->lessVars ) { $lessVars = $this->config->get( 'ResourceLoaderLESSVars' ); - Hooks::run( 'ResourceLoaderGetLessVars', array( &$lessVars ) ); + Hooks::run( 'ResourceLoaderGetLessVars', [ &$lessVars ] ); $this->lessVars = $lessVars; } return $this->lessVars; diff --git a/includes/resourceloader/ResourceLoaderContext.php b/includes/resourceloader/ResourceLoaderContext.php index 78bf69de98..bf5ae4b647 100644 --- a/includes/resourceloader/ResourceLoaderContext.php +++ b/includes/resourceloader/ResourceLoaderContext.php @@ -64,7 +64,7 @@ class ResourceLoaderContext { // List of modules $modules = $request->getVal( 'modules' ); - $this->modules = $modules ? self::expandModuleNames( $modules ) : array(); + $this->modules = $modules ? self::expandModuleNames( $modules ) : []; // Various parameters $this->user = $request->getVal( 'user' ); @@ -97,7 +97,7 @@ class ResourceLoaderContext { * @return array Array of module names */ public static function expandModuleNames( $modules ) { - $retval = array(); + $retval = []; $exploded = explode( '|', $modules ); foreach ( $exploded as $group ) { if ( strpos( $group, ',' ) === false ) { @@ -132,7 +132,7 @@ class ResourceLoaderContext { return new self( new ResourceLoader( ConfigFactory::getDefaultInstance()->makeConfig( 'main' ), LoggerFactory::getInstance( 'resourceloader' ) - ), new FauxRequest( array() ) ); + ), new FauxRequest( [] ) ); } /** @@ -356,7 +356,7 @@ class ResourceLoaderContext { */ public function getHash() { if ( !isset( $this->hash ) ) { - $this->hash = implode( '|', array( + $this->hash = implode( '|', [ // Module content vary $this->getLanguage(), $this->getSkin(), @@ -369,7 +369,7 @@ class ResourceLoaderContext { $this->getImage(), $this->getVariant(), $this->getFormat(), - ) ); + ] ); } return $this->hash; } diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 98269aeda0..b31e8dcc98 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -35,7 +35,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { protected $remoteBasePath = ''; /** @var array Saves a list of the templates named by the modules. */ - protected $templates = array(); + protected $templates = []; /** * @var array List of paths to JavaScript files to always include @@ -44,7 +44,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [file-path], [file-path], ... ) * @endcode */ - protected $scripts = array(); + protected $scripts = []; /** * @var array List of JavaScript files to include when using a specific language @@ -53,7 +53,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [language-code] => array( [file-path], [file-path], ... ), ... ) * @endcode */ - protected $languageScripts = array(); + protected $languageScripts = []; /** * @var array List of JavaScript files to include when using a specific skin @@ -62,7 +62,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [skin-name] => array( [file-path], [file-path], ... ), ... ) * @endcode */ - protected $skinScripts = array(); + protected $skinScripts = []; /** * @var array List of paths to JavaScript files to include in debug mode @@ -71,7 +71,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [skin-name] => array( [file-path], [file-path], ... ), ... ) * @endcode */ - protected $debugScripts = array(); + protected $debugScripts = []; /** * @var array List of paths to CSS files to always include @@ -80,7 +80,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [file-path], [file-path], ... ) * @endcode */ - protected $styles = array(); + protected $styles = []; /** * @var array List of paths to CSS files to include when using specific skins @@ -89,7 +89,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [file-path], [file-path], ... ) * @endcode */ - protected $skinStyles = array(); + protected $skinStyles = []; /** * @var array List of modules this module depends on @@ -98,7 +98,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [file-path], [file-path], ... ) * @endcode */ - protected $dependencies = array(); + protected $dependencies = []; /** * @var string File name containing the body of the skip function @@ -112,7 +112,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [message-key], [message-key], ... ) * @endcode */ - protected $messages = array(); + protected $messages = []; /** @var string Name of group to load this module in */ protected $group; @@ -126,7 +126,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { /** @var bool Whether mw.loader.state() call should be omitted */ protected $raw = false; - protected $targets = array( 'desktop' ); + protected $targets = [ 'desktop' ]; /** * @var bool Whether getStyleURLsForDebug should return raw file paths, @@ -141,13 +141,13 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * array( [file-path], [file-path], ... ) * @endcode */ - protected $localFileRefs = array(); + protected $localFileRefs = []; /** * @var array Place where readStyleFile() tracks file dependencies for non-existent files. * Used in tests to detect missing dependencies. */ - protected $missingLocalFileRefs = array(); + protected $missingLocalFileRefs = []; /* Methods */ @@ -211,7 +211,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ public function __construct( - $options = array(), + $options = [], $localBasePath = null, $remoteBasePath = null ) { @@ -307,7 +307,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return array Array( localBasePath, remoteBasePath ) */ public static function extractBasePaths( - $options = array(), + $options = [], $localBasePath = null, $remoteBasePath = null ) { @@ -345,7 +345,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { // but possibly protocol-relative to avoid cache pollution $remoteBasePath = wfExpandUrl( $remoteBasePath, PROTO_RELATIVE ); - return array( $localBasePath, $remoteBasePath ); + return [ $localBasePath, $remoteBasePath ]; } /** @@ -364,7 +364,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return array */ public function getScriptURLsForDebug( ResourceLoaderContext $context ) { - $urls = array(); + $urls = []; foreach ( $this->getScriptFiles( $context ) as $file ) { $urls[] = $this->getRemotePath( $file ); } @@ -408,9 +408,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } // Our module consists entirely of real css files, // in debug mode we can load those directly. - $urls = array(); + $urls = []; foreach ( $this->getStyleFiles( $context ) as $mediaType => $list ) { - $urls[$mediaType] = array(); + $urls[$mediaType] = []; foreach ( $list as $file ) { $urls[$mediaType][] = $this->getRemotePath( $file ); } @@ -503,7 +503,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return array */ protected function getFileHashes( ResourceLoaderContext $context ) { - $files = array(); + $files = []; // Flatten style files into $files $styles = self::collateFilePathListByOption( $this->styles, 'media', 'all' ); @@ -525,14 +525,14 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $files, $this->scripts, $this->templates, - $context->getDebug() ? $this->debugScripts : array(), + $context->getDebug() ? $this->debugScripts : [], $this->getLanguageScripts( $context->getLanguage() ), self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ) ); if ( $this->skipFunction ) { $files[] = $this->skipFunction; } - $files = array_map( array( $this, 'getLocalPath' ), $files ); + $files = array_map( [ $this, 'getLocalPath' ], $files ); // File deps need to be treated separately because they're already prefixed $files = array_merge( $files, $this->getFileDependencies( $context ) ); // Filter out any duplicates from getFileDependencies() and others. @@ -543,7 +543,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { // Don't include keys or file paths here, only the hashes. Including that would needlessly // cause global cache invalidation when files move or if e.g. the MediaWiki path changes. // Any significant ordering is already detected by the definition summary. - return array_map( array( __CLASS__, 'safeFileHash' ), $files ); + return array_map( [ __CLASS__, 'safeFileHash' ], $files ); } /** @@ -555,8 +555,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { public function getDefinitionSummary( ResourceLoaderContext $context ) { $summary = parent::getDefinitionSummary( $context ); - $options = array(); - foreach ( array( + $options = []; + foreach ( [ // The following properties are omitted because they don't affect the module reponse: // - localBasePath (Per T104950; Changes when absolute directory name changes. If // this affects 'scripts' and other file paths, getFileHashes accounts for that.) @@ -576,15 +576,15 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { 'skipFunction', 'debugRaw', 'raw', - ) as $member ) { + ] as $member ) { $options[$member] = $this->{$member}; }; - $summary[] = array( + $summary[] = [ 'options' => $options, 'fileHashes' => $this->getFileHashes( $context ), 'messageBlob' => $this->getMessageBlob( $context ), - ); + ]; return $summary; } @@ -633,19 +633,19 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return array List of file paths, collated by $option */ protected static function collateFilePathListByOption( array $list, $option, $default ) { - $collatedFiles = array(); + $collatedFiles = []; foreach ( (array)$list as $key => $value ) { if ( is_int( $key ) ) { // File name as the value if ( !isset( $collatedFiles[$default] ) ) { - $collatedFiles[$default] = array(); + $collatedFiles[$default] = []; } $collatedFiles[$default][] = $value; } elseif ( is_array( $value ) ) { // File name as the key, options array as the value $optionValue = isset( $value[$option] ) ? $value[$option] : $default; if ( !isset( $collatedFiles[$optionValue] ) ) { - $collatedFiles[$optionValue] = array(); + $collatedFiles[$optionValue] = []; } $collatedFiles[$optionValue][] = $key; } @@ -671,7 +671,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { ) { return $list[$fallback]; } - return array(); + return []; } /** @@ -713,7 +713,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } } - return array(); + return []; } /** @@ -755,7 +755,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return array A list of file paths collated by media type */ protected function getAllSkinStyleFiles() { - $styleFiles = array(); + $styleFiles = []; $internalSkinNames = array_keys( Skin::getSkinNames() ); $internalSkinNames[] = 'default'; @@ -780,7 +780,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $this->getAllSkinStyleFiles() ); - $result = array(); + $result = []; foreach ( $collatedStyleFiles as $media => $styleFiles ) { foreach ( $styleFiles as $styleFile ) { @@ -842,11 +842,11 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } if ( empty( $styles ) ) { - return array(); + return []; } foreach ( $styles as $media => $files ) { $uniqueFiles = array_unique( $files, SORT_REGULAR ); - $styleFiles = array(); + $styleFiles = []; foreach ( $uniqueFiles as $file ) { $styleFiles[] = $this->readStyleFile( $file, $flip, $context ); } @@ -898,7 +898,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } } return MemoizedCallable::call( 'CSSMin::remap', - array( $style, $localDir, $remoteDir, true ) ); + [ $style, $localDir, $remoteDir, true ] ); } /** @@ -962,11 +962,11 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $files = $compiler->AllParsedFiles(); $this->localFileRefs = array_merge( $this->localFileRefs, $files ); - $cache->set( $cacheKey, array( + $cache->set( $cacheKey, [ 'css' => $css, 'files' => $files, 'hash' => FileContentsHasher::getFileContentsHash( $files ), - ), 60 * 60 * 24 ); // 86400 seconds, or 24 hours. + ], 60 * 60 * 24 ); // 86400 seconds, or 24 hours. return $css; } @@ -977,7 +977,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @throws MWException */ public function getTemplates() { - $templates = array(); + $templates = []; foreach ( $this->templates as $alias => $templatePath ) { // Alias is optional diff --git a/includes/resourceloader/ResourceLoaderForeignApiModule.php b/includes/resourceloader/ResourceLoaderForeignApiModule.php index 7ed08317eb..4d215d6ffe 100644 --- a/includes/resourceloader/ResourceLoaderForeignApiModule.php +++ b/includes/resourceloader/ResourceLoaderForeignApiModule.php @@ -27,7 +27,7 @@ class ResourceLoaderForeignApiModule extends ResourceLoaderFileModule { public function getDependencies( ResourceLoaderContext $context = null ) { $dependencies = $this->dependencies; - Hooks::run( 'ResourceLoaderForeignApiModules', array( &$dependencies, $context ) ); + Hooks::run( 'ResourceLoaderForeignApiModules', [ &$dependencies, $context ] ); return $dependencies; } } diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 1f35e1fa89..43fd2dbb9c 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -31,12 +31,12 @@ class ResourceLoaderImage { * Map of allowed file extensions to their MIME types. * @var array */ - protected static $fileTypes = array( + protected static $fileTypes = [ 'svg' => 'image/svg+xml', 'png' => 'image/png', 'gif' => 'image/gif', 'jpg' => 'image/jpg', - ); + ]; /** * @param string $name Image name @@ -69,7 +69,7 @@ class ResourceLoaderImage { } // Ensure that all files have common extension. - $extensions = array(); + $extensions = []; $descriptor = (array)$descriptor; array_walk_recursive( $descriptor, function ( $path ) use ( &$extensions ) { $extensions[] = pathinfo( $path, PATHINFO_EXTENSION ); @@ -170,14 +170,14 @@ class ResourceLoaderImage { * @return string */ public function getUrl( ResourceLoaderContext $context, $script, $variant, $format ) { - $query = array( + $query = [ 'modules' => $this->getModule(), 'image' => $this->getName(), 'variant' => $variant, 'format' => $format, 'lang' => $context->getLanguage(), 'version' => $context->getVersion(), - ); + ]; return wfExpandUrl( wfAppendQuery( $script, $query ), PROTO_RELATIVE ); } @@ -346,7 +346,7 @@ class ResourceLoaderImage { $process = proc_open( $command, - array( 0 => array( 'pipe', 'r' ), 1 => array( 'pipe', 'w' ) ), + [ 0 => [ 'pipe', 'r' ], 1 => [ 'pipe', 'w' ] ], $pipes ); diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index 27e12015f0..3b3bdf7e11 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -38,12 +38,12 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { protected $origin = self::ORIGIN_CORE_SITEWIDE; - protected $images = array(); - protected $variants = array(); + protected $images = []; + protected $variants = []; protected $prefix = null; protected $selectorWithoutVariant = '.{prefix}-{name}'; protected $selectorWithVariant = '.{prefix}-{name}-{variant}'; - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** @var string Position on the page to load this module at */ protected $position = 'bottom'; @@ -102,7 +102,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { * @endcode * @throws InvalidArgumentException */ - public function __construct( $options = array(), $localBasePath = null ) { + public function __construct( $options = [], $localBasePath = null ) { $this->localBasePath = self::extractLocalBasePath( $options, $localBasePath ); $this->definition = $options; @@ -171,7 +171,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { } if ( !isset( $option['default'] ) ) { // Backwards compatibility - $option = array( 'default' => $option ); + $option = [ 'default' => $option ]; } foreach ( $option as $skin => $data ) { if ( !is_array( $option ) ) { @@ -211,10 +211,10 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { */ public function getSelectors() { $this->loadFromDefinition(); - return array( + return [ 'selectorWithoutVariant' => $this->selectorWithoutVariant, 'selectorWithVariant' => $this->selectorWithVariant, - ); + ]; } /** @@ -238,20 +238,20 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $skin = $context->getSkin(); if ( !isset( $this->imageObjects ) ) { $this->loadFromDefinition(); - $this->imageObjects = array(); + $this->imageObjects = []; } if ( !isset( $this->imageObjects[$skin] ) ) { - $this->imageObjects[$skin] = array(); + $this->imageObjects[$skin] = []; if ( !isset( $this->images[$skin] ) ) { $this->images[$skin] = isset( $this->images['default'] ) ? $this->images['default'] : - array(); + []; } foreach ( $this->images[$skin] as $name => $options ) { $fileDescriptor = is_string( $options ) ? $options : $options['file']; $allowedVariants = array_merge( - is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : array(), + is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : [], $this->getGlobalVariants( $context ) ); if ( isset( $this->variants[$skin] ) ) { @@ -260,7 +260,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { array_fill_keys( $allowedVariants, true ) ); } else { - $variantConfig = array(); + $variantConfig = []; } $image = new ResourceLoaderImage( @@ -287,14 +287,14 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $skin = $context->getSkin(); if ( !isset( $this->globalVariants ) ) { $this->loadFromDefinition(); - $this->globalVariants = array(); + $this->globalVariants = []; } if ( !isset( $this->globalVariants[$skin] ) ) { - $this->globalVariants[$skin] = array(); + $this->globalVariants[$skin] = []; if ( !isset( $this->variants[$skin] ) ) { $this->variants[$skin] = isset( $this->variants['default'] ) ? $this->variants['default'] : - array(); + []; } foreach ( $this->variants[$skin] as $name => $config ) { if ( isset( $config['global'] ) && $config['global'] ) { @@ -314,7 +314,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $this->loadFromDefinition(); // Build CSS rules - $rules = array(); + $rules = []; $script = $context->getResourceLoader()->getLoadScript( $this->getSource() ); $selectors = $this->getSelectors(); @@ -326,11 +326,11 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $declarations = implode( "\n\t", $declarations ); $selector = strtr( $selectors['selectorWithoutVariant'], - array( + [ '{prefix}' => $this->getPrefix(), '{name}' => $name, '{variant}' => '', - ) + ] ); $rules[] = "$selector {\n\t$declarations\n}"; @@ -342,18 +342,18 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { $declarations = implode( "\n\t", $declarations ); $selector = strtr( $selectors['selectorWithVariant'], - array( + [ '{prefix}' => $this->getPrefix(), '{name}' => $name, '{variant}' => $variant, - ) + ] ); $rules[] = "$selector {\n\t$declarations\n}"; } } $style = implode( "\n", $rules ); - return array( 'all' => $style ); + return [ 'all' => $style ]; } /** @@ -369,12 +369,12 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { * @return string[] CSS declarations to use given URIs as background-image */ protected function getCssDeclarations( $primary, $fallback ) { - return array( + return [ "background-image: url($fallback);", "background-image: linear-gradient(transparent, transparent), url($primary);", // Do not serve SVG to Opera 12, bad rendering with border-radius or background-size (T87504) "background-image: -o-linear-gradient(transparent, transparent), url($fallback);", - ); + ]; } /** @@ -393,14 +393,14 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { public function getDefinitionSummary( ResourceLoaderContext $context ) { $this->loadFromDefinition(); $summary = parent::getDefinitionSummary( $context ); - foreach ( array( + foreach ( [ 'localBasePath', 'images', 'variants', 'prefix', 'selectorWithoutVariant', 'selectorWithVariant', - ) as $member ) { + ] as $member ) { $summary[$member] = $this->{$member}; }; return $summary; @@ -415,13 +415,13 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { */ public function getModifiedTime( ResourceLoaderContext $context ) { $this->loadFromDefinition(); - $files = array(); + $files = []; foreach ( $this->getImages( $context ) as $name => $image ) { $files[] = $image->getPath( $context ); } $files = array_values( array_unique( $files ) ); - $filesMtime = max( array_map( array( __CLASS__, 'safeFilemtime' ), $files ) ); + $filesMtime = max( array_map( [ __CLASS__, 'safeFilemtime' ], $files ) ); return $filesMtime; } diff --git a/includes/resourceloader/ResourceLoaderJqueryMsgModule.php b/includes/resourceloader/ResourceLoaderJqueryMsgModule.php index f9dfbdc2d4..a3b059b7bf 100644 --- a/includes/resourceloader/ResourceLoaderJqueryMsgModule.php +++ b/includes/resourceloader/ResourceLoaderJqueryMsgModule.php @@ -34,7 +34,7 @@ class ResourceLoaderJqueryMsgModule extends ResourceLoaderFileModule { $fileScript = parent::getScript( $context ); $tagData = Sanitizer::getRecognizedTagData(); - $parserDefaults = array(); + $parserDefaults = []; $parserDefaults['allowedHtmlElements'] = array_merge( array_keys( $tagData['htmlpairs'] ), array_diff( @@ -43,7 +43,7 @@ class ResourceLoaderJqueryMsgModule extends ResourceLoaderFileModule { ) ); - $dataScript = Xml::encodeJsCall( 'mw.jqueryMsg.setParserDefaults', array( $parserDefaults ) ); + $dataScript = Xml::encodeJsCall( 'mw.jqueryMsg.setParserDefaults', [ $parserDefaults ] ); return $fileScript . $dataScript; } diff --git a/includes/resourceloader/ResourceLoaderLanguageDataModule.php b/includes/resourceloader/ResourceLoaderLanguageDataModule.php index 83db56724d..1630269101 100644 --- a/includes/resourceloader/ResourceLoaderLanguageDataModule.php +++ b/includes/resourceloader/ResourceLoaderLanguageDataModule.php @@ -27,7 +27,7 @@ */ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** * Get all the dynamic data for the content language to an array. @@ -37,14 +37,14 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { */ protected function getData( ResourceLoaderContext $context ) { $language = Language::factory( $context->getLanguage() ); - return array( + return [ 'digitTransformTable' => $language->digitTransformTable(), 'separatorTransformTable' => $language->separatorTransformTable(), 'grammarForms' => $language->getGrammarForms(), 'pluralRules' => $language->getPluralRules(), 'digitGroupingPattern' => $language->digitGroupingPattern(), 'fallbackLanguages' => $language->getFallbackLanguages(), - ); + ]; } /** @@ -54,10 +54,10 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { public function getScript( ResourceLoaderContext $context ) { return Xml::encodeJsCall( 'mw.language.setData', - array( + [ $context->getLanguage(), $this->getData( $context ) - ), + ], ResourceLoader::inDebugMode() ); } @@ -74,6 +74,6 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { * @return array */ public function getDependencies( ResourceLoaderContext $context = null ) { - return array( 'mediawiki.language.init' ); + return [ 'mediawiki.language.init' ]; } } diff --git a/includes/resourceloader/ResourceLoaderLanguageNamesModule.php b/includes/resourceloader/ResourceLoaderLanguageNamesModule.php index 3c6e1fac75..57260ba5fd 100644 --- a/includes/resourceloader/ResourceLoaderLanguageNamesModule.php +++ b/includes/resourceloader/ResourceLoaderLanguageNamesModule.php @@ -30,7 +30,7 @@ */ class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule { - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** * @param ResourceLoaderContext $context @@ -50,11 +50,11 @@ class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule { public function getScript( ResourceLoaderContext $context ) { return Xml::encodeJsCall( 'mw.language.setData', - array( + [ $context->getLanguage(), 'languageNames', $this->getData( $context ) - ), + ], ResourceLoader::inDebugMode() ); } @@ -64,7 +64,7 @@ class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule { * @return array */ public function getDependencies( ResourceLoaderContext $context = null ) { - return array( 'mediawiki.language.init' ); + return [ 'mediawiki.language.init' ]; } /** diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 14132d6b6e..8da1e2139b 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -60,16 +60,16 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { /* Protected Members */ protected $name = null; - protected $targets = array( 'desktop' ); + protected $targets = [ 'desktop' ]; // In-object cache for file dependencies - protected $fileDeps = array(); + protected $fileDeps = []; // In-object cache for message blob (keyed by language) - protected $msgBlobs = array(); + protected $msgBlobs = []; // In-object cache for version hash - protected $versionHash = array(); + protected $versionHash = []; // In-object cache for module content - protected $contents = array(); + protected $contents = []; /** * @var Config @@ -153,7 +153,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { */ public function getTemplates() { // Stub, override expected. - return array(); + return []; } /** @@ -214,7 +214,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { public function getScriptURLsForDebug( ResourceLoaderContext $context ) { $resourceLoader = $context->getResourceLoader(); $derivative = new DerivativeResourceLoaderContext( $context ); - $derivative->setModules( array( $this->getName() ) ); + $derivative->setModules( [ $this->getName() ] ); $derivative->setOnly( 'scripts' ); $derivative->setDebug( true ); @@ -223,7 +223,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { $derivative ); - return array( $url ); + return [ $url ]; } /** @@ -246,7 +246,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { */ public function getStyles( ResourceLoaderContext $context ) { // Stub, override expected - return array(); + return []; } /** @@ -261,7 +261,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { public function getStyleURLsForDebug( ResourceLoaderContext $context ) { $resourceLoader = $context->getResourceLoader(); $derivative = new DerivativeResourceLoaderContext( $context ); - $derivative->setModules( array( $this->getName() ) ); + $derivative->setModules( [ $this->getName() ] ); $derivative->setOnly( 'styles' ); $derivative->setDebug( true ); @@ -270,7 +270,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { $derivative ); - return array( 'all' => array( $url ) ); + return [ 'all' => [ $url ] ]; } /** @@ -282,7 +282,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { */ public function getMessages() { // Stub, override expected - return array(); + return []; } /** @@ -341,7 +341,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { */ public function getDependencies( ResourceLoaderContext $context = null ) { // Stub, override expected - return array(); + return []; } /** @@ -387,10 +387,10 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { $dbr = wfGetDB( DB_SLAVE ); $deps = $dbr->selectField( 'module_deps', 'md_deps', - array( + [ 'md_module' => $this->getName(), 'md_skin' => $vary, - ), + ], __METHOD__ ); @@ -399,7 +399,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { (array)FormatJson::decode( $deps, true ) ); } else { - $this->fileDeps[$vary] = array(); + $this->fileDeps[$vary] = []; } } return $this->fileDeps[$vary]; @@ -444,13 +444,13 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { $vary = $context->getSkin() . '|' . $context->getLanguage(); $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'module_deps', - array( array( 'md_module', 'md_skin' ) ), - array( + [ [ 'md_module', 'md_skin' ] ], + [ 'md_module' => $this->getName(), 'md_skin' => $vary, // Use relative paths to avoid ghost entries when $IP changes (T111481) 'md_deps' => FormatJson::encode( self::getRelativePaths( $localFileRefs ) ), - ) + ] ); $dbw->onTransactionIdle( function () use ( &$scopeLock ) { @@ -508,9 +508,9 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { // Message blobs may only vary language, not by context keys $lang = $context->getLanguage(); if ( !isset( $this->msgBlobs[$lang] ) ) { - $this->getLogger()->warning( 'Message blob for {module} should have been preloaded', array( + $this->getLogger()->warning( 'Message blob for {module} should have been preloaded', [ 'module' => $this->getName(), - ) ); + ] ); $store = $context->getResourceLoader()->getMessageBlobStore(); $this->msgBlobs[$lang] = $store->getBlob( $this, $lang ); } @@ -538,7 +538,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { * @return array Module-specific LESS variables. */ protected function getLessVars( ResourceLoaderContext $context ) { - return array(); + return []; } /** @@ -574,7 +574,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { // and that are non-empty (e.g. don't include "templates" for modules without // templates). This helps prevent invalidating cache for all modules when new // optional properties are introduced. - $content = array(); + $content = []; // Scripts if ( $context->shouldIncludeScripts() ) { @@ -603,7 +603,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { // Styles if ( $context->shouldIncludeStyles() ) { - $styles = array(); + $styles = []; // Don't create empty stylesheets like array( '' => '' ) for modules // that don't *have* any stylesheets (bug 38024). $stylePairs = $this->getStyles( $context ); @@ -611,9 +611,9 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { // If we are in debug mode without &only= set, we'll want to return an array of URLs // See comment near shouldIncludeScripts() for more details if ( $context->getDebug() && !$context->getOnly() && $this->supportsURLLoading() ) { - $styles = array( + $styles = [ 'url' => $this->getStyleURLsForDebug( $context ) - ); + ]; } else { // Minify CSS before embedding in mw.loader.implement call // (unless in debug mode) @@ -621,7 +621,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { foreach ( $stylePairs as $media => $style ) { // Can be either a string or an array of strings. if ( is_array( $style ) ) { - $stylePairs[$media] = array(); + $stylePairs[$media] = []; foreach ( $style as $cssText ) { if ( is_string( $cssText ) ) { $stylePairs[$media][] = @@ -634,9 +634,9 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { } } // Wrap styles into @media groups as needed and flatten into a numerical array - $styles = array( + $styles = [ 'css' => $rl->makeCombinedStyles( $stylePairs ) - ); + ]; } } $content['styles'] = $styles; @@ -688,7 +688,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { // Typically, the request for the startup module itself has only=scripts. That must apply // only to the startup module content, and not to the module version computed here. $context = new DerivativeResourceLoaderContext( $context ); - $context->setModules( array() ); + $context->setModules( [] ); // Version hash must cover all resources, regardless of startup request itself. $context->setOnly( null ); // Compute version hash based on content, not debug urls. @@ -785,10 +785,10 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { * @return array|null */ public function getDefinitionSummary( ResourceLoaderContext $context ) { - return array( + return [ '_class' => get_class( $this ), '_cacheEpoch' => $this->getConfig()->get( 'CacheEpoch' ), - ); + ]; } /** diff --git a/includes/resourceloader/ResourceLoaderOOUIImageModule.php b/includes/resourceloader/ResourceLoaderOOUIImageModule.php index 8493f9fdc3..52aa39250d 100644 --- a/includes/resourceloader/ResourceLoaderOOUIImageModule.php +++ b/includes/resourceloader/ResourceLoaderOOUIImageModule.php @@ -30,13 +30,13 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { } // Core default themes - $themes = array( 'default' => 'mediawiki' ); + $themes = [ 'default' => 'mediawiki' ]; $themes += ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' ); $name = $this->definition['name']; $rootPath = $this->definition['rootPath']; - $definition = array(); + $definition = []; foreach ( $themes as $skin => $theme ) { // TODO Allow extensions to specify this path somehow $dataPath = $this->localBasePath . '/' . $rootPath . '/' . $theme . '/' . $name . '.json'; @@ -55,7 +55,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { } } ); } else { - $data = array(); + $data = []; } foreach ( $data as $key => $value ) { diff --git a/includes/resourceloader/ResourceLoaderSiteModule.php b/includes/resourceloader/ResourceLoaderSiteModule.php index eba6815cc5..e01d0a138e 100644 --- a/includes/resourceloader/ResourceLoaderSiteModule.php +++ b/includes/resourceloader/ResourceLoaderSiteModule.php @@ -34,15 +34,15 @@ class ResourceLoaderSiteModule extends ResourceLoaderWikiModule { * @return array List of pages */ protected function getPages( ResourceLoaderContext $context ) { - $pages = array(); + $pages = []; if ( $this->getConfig()->get( 'UseSiteJs' ) ) { - $pages['MediaWiki:Common.js'] = array( 'type' => 'script' ); - $pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.js'] = array( 'type' => 'script' ); + $pages['MediaWiki:Common.js'] = [ 'type' => 'script' ]; + $pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.js'] = [ 'type' => 'script' ]; } if ( $this->getConfig()->get( 'UseSiteCss' ) ) { - $pages['MediaWiki:Common.css'] = array( 'type' => 'style' ); - $pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.css'] = array( 'type' => 'style' ); - $pages['MediaWiki:Print.css'] = array( 'type' => 'style', 'media' => 'print' ); + $pages['MediaWiki:Common.css'] = [ 'type' => 'style' ]; + $pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.css'] = [ 'type' => 'style' ]; + $pages['MediaWiki:Print.css'] = [ 'type' => 'style', 'media' => 'print' ]; } return $pages; diff --git a/includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php b/includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php index 862f629709..222135cbfc 100644 --- a/includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php +++ b/includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php @@ -27,7 +27,7 @@ */ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule { private $path = "resources/src/mediawiki.language/specialcharacters.json"; - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** * Get all the dynamic data. @@ -46,9 +46,9 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule { public function getScript( ResourceLoaderContext $context ) { return Xml::encodeJsCall( 'mw.language.setSpecialCharacters', - array( + [ $this->getData() - ), + ], ResourceLoader::inDebugMode() ); } @@ -65,14 +65,14 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule { * @return array */ public function getDependencies( ResourceLoaderContext $context = null ) { - return array( 'mediawiki.language' ); + return [ 'mediawiki.language' ]; } /** * @return array */ public function getMessages() { - return array( + return [ 'special-characters-group-latin', 'special-characters-group-latinextended', 'special-characters-group-ipa', @@ -95,6 +95,6 @@ class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule { 'special-characters-title-endash', 'special-characters-title-emdash', 'special-characters-title-minus' - ); + ]; } } diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index c9f515e432..6a40e27b44 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -25,8 +25,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { // Cache for getConfigSettings() as it's called by multiple methods - protected $configVars = array(); - protected $targets = array( 'desktop', 'mobile' ); + protected $configVars = []; + protected $targets = [ 'desktop', 'mobile' ]; /** * @param ResourceLoaderContext $context @@ -49,7 +49,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive. */ $namespaceIds = $wgContLang->getNamespaceIds(); - $caseSensitiveNamespaces = array(); + $caseSensitiveNamespaces = []; foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) { $namespaceIds[$wgContLang->lc( $name )] = $index; if ( !MWNamespace::isCapitalized( $index ) ) { @@ -59,7 +59,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $conf = $this->getConfig(); // Build list of variables - $vars = array( + $vars = [ 'wgLoadScript' => wfScript( 'load' ), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), @@ -104,9 +104,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ), 'wgEnableUploads' => $conf->get( 'EnableUploads' ), - ); + ]; - Hooks::run( 'ResourceLoaderGetConfigVars', array( &$vars ) ); + Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars ] ); $this->configVars[$hash] = $vars; return $this->configVars[$hash]; @@ -120,7 +120,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { * @return array */ protected static function getImplicitDependencies( array $registryData, $moduleName ) { - static $dependencyCache = array(); + static $dependencyCache = []; // The list of implicit dependencies won't be altered, so we can // cache them without having to worry. @@ -128,7 +128,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { if ( !isset( $registryData[$moduleName] ) ) { // Dependencies may not exist - $dependencyCache[$moduleName] = array(); + $dependencyCache[$moduleName] = []; } else { $data = $registryData[$moduleName]; $dependencyCache[$moduleName] = $data['dependencies']; @@ -191,7 +191,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $byPassTargetFilter = $this->getConfig()->get( 'EnableJavaScriptTest' ) && $target === 'test'; $out = ''; - $registryData = array(); + $registryData = []; // Get registry data foreach ( $resourceLoader->getModuleNames() as $name ) { @@ -212,10 +212,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { if ( strlen( $versionHash ) !== 8 ) { $context->getLogger()->warning( "Module '{module}' produced an invalid version hash: '{version}'.", - array( + [ 'module' => $name, 'version' => $versionHash, - ) + ] ); // Module implementation either broken or deviated from ResourceLoader::makeHash // Asserted by tests/phpunit/structure/ResourcesTest. @@ -227,13 +227,13 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $skipFunction = ResourceLoader::filter( 'minify-js', $skipFunction ); } - $registryData[$name] = array( + $registryData[$name] = [ 'version' => $versionHash, 'dependencies' => $module->getDependencies( $context ), 'group' => $module->getGroup(), 'source' => $module->getSource(), 'skip' => $skipFunction, - ); + ]; } self::compileUnresolvedDependencies( $registryData ); @@ -242,10 +242,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $out .= ResourceLoader::makeLoaderSourcesScript( $resourceLoader->getSources() ); // Figure out the different call signatures for mw.loader.register - $registrations = array(); + $registrations = []; foreach ( $registryData as $name => $data ) { // Call mw.loader.register(name, version, dependencies, group, source, skip) - $registrations[] = array( + $registrations[] = [ $name, $data['version'], $data['dependencies'], @@ -253,7 +253,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { // Swap default (local) for null $data['source'] === 'local' ? null : $data['source'], $data['skip'] - ); + ]; } // Register modules @@ -275,13 +275,13 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { * @return array */ public static function getStartupModules() { - return array( 'jquery', 'mediawiki' ); + return [ 'jquery', 'mediawiki' ]; } public static function getLegacyModules() { global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil; - $legacyModules = array(); + $legacyModules = []; if ( $wgIncludeLegacyJavaScript ) { $legacyModules[] = 'mediawiki.legacy.wikibits'; } @@ -305,14 +305,14 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $rl = $context->getResourceLoader(); $moduleNames = self::getStartupModules(); - $query = array( + $query = [ 'modules' => ResourceLoader::makePackedModulesString( $moduleNames ), 'only' => 'scripts', 'lang' => $context->getLanguage(), 'skin' => $context->getSkin(), 'debug' => $context->getDebug() ? 'true' : 'false', 'version' => $rl->getCombinedVersion( $context, $moduleNames ), - ); + ]; // Ensure uniform query order ksort( $query ); return wfAppendQuery( wfScript( 'load' ), $query ); @@ -335,11 +335,11 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { // Fix indentation $value = str_replace( "\n", "\n\t", $value ); return $value; - }, array( + }, [ '$VARS.wgLegacyJavaScriptGlobals' => $this->getConfig()->get( 'LegacyJavaScriptGlobals' ), '$VARS.configuration' => $this->getConfigSettings( $context ), '$VARS.baseModulesUri' => self::getStartupModulesUrl( $context ), - ) ); + ] ); $pairs['$CODE.registrations()'] = str_replace( "\n", "\n\t", @@ -365,7 +365,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { public function getDefinitionSummary( ResourceLoaderContext $context ) { global $IP; $summary = parent::getDefinitionSummary( $context ); - $summary[] = array( + $summary[] = [ // Detect changes to variables exposed in mw.config (T30899). 'vars' => $this->getConfigSettings( $context ), // Changes how getScript() creates mw.Map for mw.config @@ -373,10 +373,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { // Detect changes to the module registrations 'moduleHashes' => $this->getAllModuleHashes( $context ), - 'fileMtimes' => array( + 'fileMtimes' => [ filemtime( "$IP/resources/src/startup.js" ), - ), - ); + ], + ]; return $summary; } diff --git a/includes/resourceloader/ResourceLoaderUserCSSPrefsModule.php b/includes/resourceloader/ResourceLoaderUserCSSPrefsModule.php index 04b04349c8..9c198d14a9 100644 --- a/includes/resourceloader/ResourceLoaderUserCSSPrefsModule.php +++ b/includes/resourceloader/ResourceLoaderUserCSSPrefsModule.php @@ -42,13 +42,13 @@ class ResourceLoaderUserCSSPrefsModule extends ResourceLoaderModule { */ public function getStyles( ResourceLoaderContext $context ) { if ( !$this->getConfig()->get( 'AllowUserCssPrefs' ) ) { - return array(); + return []; } $options = $context->getUserObj()->getOptions(); // Build CSS rules - $rules = array(); + $rules = []; // Underline: 2 = skin default, 1 = always, 0 = never if ( $options['underline'] < 2 ) { @@ -65,7 +65,7 @@ class ResourceLoaderUserCSSPrefsModule extends ResourceLoaderModule { if ( $this->getFlip( $context ) ) { $style = CSSJanus::transform( $style, true, false ); } - return array( 'all' => $style ); + return [ 'all' => $style ]; } /** diff --git a/includes/resourceloader/ResourceLoaderUserDefaultsModule.php b/includes/resourceloader/ResourceLoaderUserDefaultsModule.php index abcf9c6a34..66320457a5 100644 --- a/includes/resourceloader/ResourceLoaderUserDefaultsModule.php +++ b/includes/resourceloader/ResourceLoaderUserDefaultsModule.php @@ -26,7 +26,7 @@ */ class ResourceLoaderUserDefaultsModule extends ResourceLoaderModule { - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** * @return bool @@ -42,7 +42,7 @@ class ResourceLoaderUserDefaultsModule extends ResourceLoaderModule { public function getScript( ResourceLoaderContext $context ) { return Xml::encodeJsCall( 'mw.user.options.set', - array( User::getDefaultOptions() ), + [ User::getDefaultOptions() ], ResourceLoader::inDebugMode() ); } diff --git a/includes/resourceloader/ResourceLoaderUserGroupsModule.php b/includes/resourceloader/ResourceLoaderUserGroupsModule.php index dd4dd5c054..e2a8e410c0 100644 --- a/includes/resourceloader/ResourceLoaderUserGroupsModule.php +++ b/includes/resourceloader/ResourceLoaderUserGroupsModule.php @@ -26,7 +26,7 @@ class ResourceLoaderUserGroupsModule extends ResourceLoaderWikiModule { protected $origin = self::ORIGIN_USER_SITEWIDE; - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** * @param ResourceLoaderContext $context @@ -36,24 +36,24 @@ class ResourceLoaderUserGroupsModule extends ResourceLoaderWikiModule { $useSiteJs = $this->getConfig()->get( 'UseSiteJs' ); $useSiteCss = $this->getConfig()->get( 'UseSiteCss' ); if ( !$useSiteJs && !$useSiteCss ) { - return array(); + return []; } $user = $context->getUserObj(); if ( !$user || $user->isAnon() ) { - return array(); + return []; } - $pages = array(); + $pages = []; foreach ( $user->getEffectiveGroups() as $group ) { if ( $group == '*' ) { continue; } if ( $useSiteJs ) { - $pages["MediaWiki:Group-$group.js"] = array( 'type' => 'script' ); + $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ]; } if ( $useSiteCss ) { - $pages["MediaWiki:Group-$group.css"] = array( 'type' => 'style' ); + $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ]; } } return $pages; diff --git a/includes/resourceloader/ResourceLoaderUserModule.php b/includes/resourceloader/ResourceLoaderUserModule.php index d45e281822..d584165a97 100644 --- a/includes/resourceloader/ResourceLoaderUserModule.php +++ b/includes/resourceloader/ResourceLoaderUserModule.php @@ -39,25 +39,25 @@ class ResourceLoaderUserModule extends ResourceLoaderWikiModule { $allowUserJs = $this->getConfig()->get( 'AllowUserJs' ); $allowUserCss = $this->getConfig()->get( 'AllowUserCss' ); if ( !$allowUserJs && !$allowUserCss ) { - return array(); + return []; } $user = $context->getUserObj(); if ( !$user || $user->isAnon() ) { - return array(); + return []; } // Needed so $excludepages works $userPage = $user->getUserPage()->getPrefixedDBkey(); - $pages = array(); + $pages = []; if ( $allowUserJs ) { - $pages["$userPage/common.js"] = array( 'type' => 'script' ); - $pages["$userPage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' ); + $pages["$userPage/common.js"] = [ 'type' => 'script' ]; + $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ]; } if ( $allowUserCss ) { - $pages["$userPage/common.css"] = array( 'type' => 'style' ); - $pages["$userPage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' ); + $pages["$userPage/common.css"] = [ 'type' => 'style' ]; + $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ]; } // Hack for bug 26283: if we're on a preview page for a CSS/JS page, diff --git a/includes/resourceloader/ResourceLoaderUserOptionsModule.php b/includes/resourceloader/ResourceLoaderUserOptionsModule.php index 94f1e680b5..b3b3f16832 100644 --- a/includes/resourceloader/ResourceLoaderUserOptionsModule.php +++ b/includes/resourceloader/ResourceLoaderUserOptionsModule.php @@ -29,14 +29,14 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { protected $origin = self::ORIGIN_CORE_INDIVIDUAL; - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /** * @param ResourceLoaderContext $context * @return array List of module names as strings */ public function getDependencies( ResourceLoaderContext $context = null ) { - return array( 'user.defaults' ); + return [ 'user.defaults' ]; } /** @@ -52,7 +52,7 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { */ public function getScript( ResourceLoaderContext $context ) { return Xml::encodeJsCall( 'mw.user.options.set', - array( $context->getUserObj()->getOptions( User::GETOPTIONS_EXCLUDE_DEFAULTS ) ), + [ $context->getUserObj()->getOptions( User::GETOPTIONS_EXCLUDE_DEFAULTS ) ], ResourceLoader::inDebugMode() ); } diff --git a/includes/resourceloader/ResourceLoaderUserTokensModule.php b/includes/resourceloader/ResourceLoaderUserTokensModule.php index 78fec5094a..bf4e8a7e21 100644 --- a/includes/resourceloader/ResourceLoaderUserTokensModule.php +++ b/includes/resourceloader/ResourceLoaderUserTokensModule.php @@ -30,7 +30,7 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule { protected $origin = self::ORIGIN_CORE_INDIVIDUAL; - protected $targets = array( 'desktop', 'mobile' ); + protected $targets = [ 'desktop', 'mobile' ]; /* Methods */ @@ -43,12 +43,12 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule { protected function contextUserTokens( ResourceLoaderContext $context ) { $user = $context->getUserObj(); - return array( + return [ 'editToken' => $user->getEditToken(), 'patrolToken' => $user->getEditToken( 'patrol' ), 'watchToken' => $user->getEditToken( 'watch' ), 'csrfToken' => $user->getEditToken(), - ); + ]; } /** @@ -63,7 +63,7 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule { public function getScript( ResourceLoaderContext $context ) { return Xml::encodeJsCall( 'mw.user.tokens.set', - array( $this->contextUserTokens( $context ) ), + [ $this->contextUserTokens( $context ) ], ResourceLoader::inDebugMode() ) . ResourceLoader::FILTER_NOMIN; } diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index 52eb2d81be..7b0d93a6c5 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -50,13 +50,13 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { protected $origin = self::ORIGIN_USER_SITEWIDE; // In-process cache for title info - protected $titleInfo = array(); + protected $titleInfo = []; // List of page names that contain CSS - protected $styles = array(); + protected $styles = []; // List of page names that contain JavaScript - protected $scripts = array(); + protected $scripts = []; // Group of module protected $group; @@ -99,18 +99,18 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { */ protected function getPages( ResourceLoaderContext $context ) { $config = $this->getConfig(); - $pages = array(); + $pages = []; // Filter out pages from origins not allowed by the current wiki configuration. if ( $config->get( 'UseSiteJs' ) ) { foreach ( $this->scripts as $script ) { - $pages[$script] = array( 'type' => 'script' ); + $pages[$script] = [ 'type' => 'script' ]; } } if ( $config->get( 'UseSiteCss' ) ) { foreach ( $this->styles as $style ) { - $pages[$style] = array( 'type' => 'style' ); + $pages[$style] = [ 'type' => 'style' ]; } } @@ -199,7 +199,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { * @return array */ public function getStyles( ResourceLoaderContext $context ) { - $styles = array(); + $styles = []; foreach ( $this->getPages( $context ) as $titleText => $options ) { if ( $options['type'] !== 'style' ) { continue; @@ -213,9 +213,9 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { $style = CSSJanus::transform( $style, true, false ); } $style = MemoizedCallable::call( 'CSSMin::remap', - array( $style, false, $this->getConfig()->get( 'ScriptPath' ), true ) ); + [ $style, false, $this->getConfig()->get( 'ScriptPath' ), true ] ); if ( !isset( $styles[$media] ) ) { - $styles[$media] = array(); + $styles[$media] = []; } $style = ResourceLoader::makeComment( $titleText ) . $style; $styles[$media][] = $style; @@ -243,11 +243,11 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { */ public function getDefinitionSummary( ResourceLoaderContext $context ) { $summary = parent::getDefinitionSummary( $context ); - $summary[] = array( + $summary[] = [ 'pages' => $this->getPages( $context ), // Includes SHA1 of content 'titleInfo' => $this->getTitleInfo( $context ), - ); + ]; return $summary; } @@ -284,34 +284,34 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { $dbr = $this->getDB(); if ( !$dbr ) { // We're dealing with a subclass that doesn't have a DB - return array(); + return []; } $pages = $this->getPages( $context ); $key = implode( '|', array_keys( $pages ) ); if ( !isset( $this->titleInfo[$key] ) ) { - $this->titleInfo[$key] = array(); + $this->titleInfo[$key] = []; $batch = new LinkBatch; foreach ( $pages as $titleText => $options ) { $batch->addObj( Title::newFromText( $titleText ) ); } if ( !$batch->isEmpty() ) { - $res = $dbr->select( array( 'page', 'revision' ), - array( 'page_namespace', 'page_title', 'rev_len', 'rev_sha1' ), + $res = $dbr->select( [ 'page', 'revision' ], + [ 'page_namespace', 'page_title', 'rev_len', 'rev_sha1' ], $batch->constructSet( 'page', $dbr ), __METHOD__, - array(), - array( 'revision' => array( 'INNER JOIN', array( 'page_latest=rev_id' ) ) ) + [], + [ 'revision' => [ 'INNER JOIN', [ 'page_latest=rev_id' ] ] ] ); foreach ( $res as $row ) { // Avoid including ids or timestamps of revision/page tables so // that versions are not wasted $title = Title::makeTitle( $row->page_namespace, $row->page_title ); - $this->titleInfo[$key][$title->getPrefixedText()] = array( + $this->titleInfo[$key][$title->getPrefixedText()] = [ 'rev_len' => $row->rev_len, 'rev_sha1' => $row->rev_sha1, - ); + ]; } } } diff --git a/includes/revisiondelete/RevDelArchiveItem.php b/includes/revisiondelete/RevDelArchiveItem.php index 0f1c7f0c9a..2d0d6906b9 100644 --- a/includes/revisiondelete/RevDelArchiveItem.php +++ b/includes/revisiondelete/RevDelArchiveItem.php @@ -26,7 +26,7 @@ class RevDelArchiveItem extends RevDelRevisionItem { public function __construct( $list, $row ) { RevDelItem::__construct( $list, $row ); $this->revision = Revision::newFromArchiveRow( $row, - array( 'page' => $this->list->title->getArticleID() ) ); + [ 'page' => $this->list->title->getArticleID() ] ); } public function getIdField() { @@ -53,15 +53,15 @@ class RevDelArchiveItem extends RevDelRevisionItem { public function setBits( $bits ) { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'archive', - array( 'ar_deleted' => $bits ), - array( + [ 'ar_deleted' => $bits ], + [ 'ar_namespace' => $this->list->title->getNamespace(), 'ar_title' => $this->list->title->getDBkey(), // use timestamp for index 'ar_timestamp' => $this->row->ar_timestamp, 'ar_rev_id' => $this->row->ar_rev_id, 'ar_deleted' => $this->getBits() - ), + ], __METHOD__ ); return (bool)$dbw->affectedRows(); @@ -78,11 +78,11 @@ class RevDelArchiveItem extends RevDelRevisionItem { return Linker::link( SpecialPage::getTitleFor( 'Undelete' ), $date, - array(), - array( + [], + [ 'target' => $this->list->title->getPrefixedText(), 'timestamp' => $this->revision->getTimestamp() - ) + ] ); } @@ -94,12 +94,12 @@ class RevDelArchiveItem extends RevDelRevisionItem { return Linker::link( SpecialPage::getTitleFor( 'Undelete' ), $this->list->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'target' => $this->list->title->getPrefixedText(), 'diff' => 'prev', 'timestamp' => $this->revision->getTimestamp() - ) + ] ); } } diff --git a/includes/revisiondelete/RevDelArchiveList.php b/includes/revisiondelete/RevDelArchiveList.php index 6ae0afcef8..9bb1dc5011 100644 --- a/includes/revisiondelete/RevDelArchiveList.php +++ b/includes/revisiondelete/RevDelArchiveList.php @@ -36,19 +36,19 @@ class RevDelArchiveList extends RevDelRevisionList { * @return mixed */ public function doQuery( $db ) { - $timestamps = array(); + $timestamps = []; foreach ( $this->ids as $id ) { $timestamps[] = $db->timestamp( $id ); } return $db->select( 'archive', Revision::selectArchiveFields(), - array( + [ 'ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps - ), + ], __METHOD__, - array( 'ORDER BY' => 'ar_timestamp DESC' ) + [ 'ORDER BY' => 'ar_timestamp DESC' ] ); } diff --git a/includes/revisiondelete/RevDelArchivedFileItem.php b/includes/revisiondelete/RevDelArchivedFileItem.php index 7c41c180b7..e2bb51664f 100644 --- a/includes/revisiondelete/RevDelArchivedFileItem.php +++ b/includes/revisiondelete/RevDelArchivedFileItem.php @@ -51,11 +51,11 @@ class RevDelArchivedFileItem extends RevDelFileItem { public function setBits( $bits ) { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'filearchive', - array( 'fa_deleted' => $bits ), - array( + [ 'fa_deleted' => $bits ], + [ 'fa_id' => $this->row->fa_id, 'fa_deleted' => $this->getBits(), - ), + ], __METHOD__ ); @@ -72,12 +72,12 @@ class RevDelArchivedFileItem extends RevDelFileItem { } else { $undelete = SpecialPage::getTitleFor( 'Undelete' ); $key = $this->file->getKey(); - $link = Linker::link( $undelete, $date, array(), - array( + $link = Linker::link( $undelete, $date, [], + [ 'target' => $this->list->title->getPrefixedText(), 'file' => $key, 'token' => $this->list->getUser()->getEditToken( $key ) - ) + ] ); } if ( $this->isDeleted() ) { @@ -90,38 +90,38 @@ class RevDelArchivedFileItem extends RevDelFileItem { public function getApiData( ApiResult $result ) { $file = $this->file; $user = $this->list->getUser(); - $ret = array( + $ret = [ 'title' => $this->list->title->getPrefixedText(), 'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ), 'width' => $file->getWidth(), 'height' => $file->getHeight(), 'size' => $file->getSize(), - ); - $ret += $file->isDeleted( Revision::DELETED_USER ) ? array( 'userhidden' => '' ) : array(); - $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? array( 'commenthidden' => '' ) : array(); - $ret += $this->isDeleted() ? array( 'contenthidden' => '' ) : array(); + ]; + $ret += $file->isDeleted( Revision::DELETED_USER ) ? [ 'userhidden' => '' ] : []; + $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? [ 'commenthidden' => '' ] : []; + $ret += $this->isDeleted() ? [ 'contenthidden' => '' ] : []; if ( $this->canViewContent() ) { - $ret += array( + $ret += [ 'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL( - array( + [ 'target' => $this->list->title->getPrefixedText(), 'file' => $file->getKey(), 'token' => $user->getEditToken( $file->getKey() ) - ), + ], false, PROTO_RELATIVE ), - ); + ]; } if ( $file->userCan( Revision::DELETED_USER, $user ) ) { - $ret += array( + $ret += [ 'userid' => $file->getUser( 'id' ), 'user' => $file->getUser( 'text' ), - ); + ]; } if ( $file->userCan( Revision::DELETED_COMMENT, $user ) ) { - $ret += array( + $ret += [ 'comment' => $file->getRawDescription(), - ); + ]; } return $ret; diff --git a/includes/revisiondelete/RevDelArchivedFileList.php b/includes/revisiondelete/RevDelArchivedFileList.php index f2b99aed4f..afee6374c9 100644 --- a/includes/revisiondelete/RevDelArchivedFileList.php +++ b/includes/revisiondelete/RevDelArchivedFileList.php @@ -41,12 +41,12 @@ class RevDelArchivedFileList extends RevDelFileList { return $db->select( 'filearchive', ArchivedFile::selectFields(), - array( + [ 'fa_name' => $this->title->getDBkey(), 'fa_id' => $ids - ), + ], __METHOD__, - array( 'ORDER BY' => 'fa_id DESC' ) + [ 'ORDER BY' => 'fa_id DESC' ] ); } diff --git a/includes/revisiondelete/RevDelArchivedRevisionItem.php b/includes/revisiondelete/RevDelArchivedRevisionItem.php index 9ec548fb2f..d839fcfc5b 100644 --- a/includes/revisiondelete/RevDelArchivedRevisionItem.php +++ b/includes/revisiondelete/RevDelArchivedRevisionItem.php @@ -28,7 +28,7 @@ class RevDelArchivedRevisionItem extends RevDelArchiveItem { RevDelItem::__construct( $list, $row ); $this->revision = Revision::newFromArchiveRow( $row, - array( 'page' => $this->list->title->getArticleID() ) ); + [ 'page' => $this->list->title->getArticleID() ] ); } public function getIdField() { @@ -42,10 +42,10 @@ class RevDelArchivedRevisionItem extends RevDelArchiveItem { public function setBits( $bits ) { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'archive', - array( 'ar_deleted' => $bits ), - array( 'ar_rev_id' => $this->row->ar_rev_id, + [ 'ar_deleted' => $bits ], + [ 'ar_rev_id' => $this->row->ar_rev_id, 'ar_deleted' => $this->getBits() - ), + ], __METHOD__ ); return (bool)$dbw->affectedRows(); diff --git a/includes/revisiondelete/RevDelFileItem.php b/includes/revisiondelete/RevDelFileItem.php index a6517fe9c7..921fe5a635 100644 --- a/includes/revisiondelete/RevDelFileItem.php +++ b/includes/revisiondelete/RevDelFileItem.php @@ -75,29 +75,29 @@ class RevDelFileItem extends RevDelItem { # Newly undeleted $key = $this->file->getStorageKey(); $srcRel = $this->file->repo->getDeletedHashPath( $key ) . $key; - $this->list->storeBatch[] = array( + $this->list->storeBatch[] = [ $this->file->repo->getVirtualUrl( 'deleted' ) . '/' . $srcRel, 'public', $this->file->getRel() - ); + ]; $this->list->cleanupBatch[] = $key; } } elseif ( $bits & File::DELETED_FILE ) { # Newly deleted $key = $this->file->getStorageKey(); $dstRel = $this->file->repo->getDeletedHashPath( $key ) . $key; - $this->list->deleteBatch[] = array( $this->file->getRel(), $dstRel ); + $this->list->deleteBatch[] = [ $this->file->getRel(), $dstRel ]; } # Do the database operations $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'oldimage', - array( 'oi_deleted' => $bits ), - array( + [ 'oi_deleted' => $bits ], + [ 'oi_name' => $this->row->oi_name, 'oi_timestamp' => $this->row->oi_timestamp, 'oi_deleted' => $this->getBits() - ), + ], __METHOD__ ); @@ -119,7 +119,7 @@ class RevDelFileItem extends RevDelItem { if ( !$this->isDeleted() ) { # Regular files... - return Html::rawElement( 'a', array( 'href' => $this->file->getUrl() ), $date ); + return Html::rawElement( 'a', [ 'href' => $this->file->getUrl() ], $date ); } # Hidden files... @@ -129,13 +129,13 @@ class RevDelFileItem extends RevDelItem { $link = Linker::link( SpecialPage::getTitleFor( 'Revisiondelete' ), $date, - array(), - array( + [], + [ 'target' => $this->list->title->getPrefixedText(), 'file' => $this->file->getArchiveName(), 'token' => $this->list->getUser()->getEditToken( $this->file->getArchiveName() ) - ) + ] ); } @@ -193,43 +193,43 @@ class RevDelFileItem extends RevDelItem { public function getApiData( ApiResult $result ) { $file = $this->file; $user = $this->list->getUser(); - $ret = array( + $ret = [ 'title' => $this->list->title->getPrefixedText(), 'archivename' => $file->getArchiveName(), 'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ), 'width' => $file->getWidth(), 'height' => $file->getHeight(), 'size' => $file->getSize(), - ); - $ret += $file->isDeleted( Revision::DELETED_USER ) ? array( 'userhidden' => '' ) : array(); - $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? array( 'commenthidden' => '' ) : array(); - $ret += $this->isDeleted() ? array( 'contenthidden' => '' ) : array(); + ]; + $ret += $file->isDeleted( Revision::DELETED_USER ) ? [ 'userhidden' => '' ] : []; + $ret += $file->isDeleted( Revision::DELETED_COMMENT ) ? [ 'commenthidden' => '' ] : []; + $ret += $this->isDeleted() ? [ 'contenthidden' => '' ] : []; if ( !$this->isDeleted() ) { - $ret += array( + $ret += [ 'url' => $file->getUrl(), - ); + ]; } elseif ( $this->canViewContent() ) { - $ret += array( + $ret += [ 'url' => SpecialPage::getTitleFor( 'Revisiondelete' )->getLinkURL( - array( + [ 'target' => $this->list->title->getPrefixedText(), 'file' => $file->getArchiveName(), 'token' => $user->getEditToken( $file->getArchiveName() ) - ), + ], false, PROTO_RELATIVE ), - ); + ]; } if ( $file->userCan( Revision::DELETED_USER, $user ) ) { - $ret += array( + $ret += [ 'userid' => $file->user, 'user' => $file->user_text, - ); + ]; } if ( $file->userCan( Revision::DELETED_COMMENT, $user ) ) { - $ret += array( + $ret += [ 'comment' => $file->description, - ); + ]; } return $ret; diff --git a/includes/revisiondelete/RevDelFileList.php b/includes/revisiondelete/RevDelFileList.php index c8276fca74..75e1885b0c 100644 --- a/includes/revisiondelete/RevDelFileList.php +++ b/includes/revisiondelete/RevDelFileList.php @@ -53,7 +53,7 @@ class RevDelFileList extends RevDelList { * @return mixed */ public function doQuery( $db ) { - $archiveNames = array(); + $archiveNames = []; foreach ( $this->ids as $timestamp ) { $archiveNames[] = $timestamp . '!' . $this->title->getDBkey(); } @@ -61,12 +61,12 @@ class RevDelFileList extends RevDelList { return $db->select( 'oldimage', OldLocalFile::selectFields(), - array( + [ 'oi_name' => $this->title->getDBkey(), 'oi_archive_name' => $archiveNames - ), + ], __METHOD__, - array( 'ORDER BY' => 'oi_timestamp DESC' ) + [ 'ORDER BY' => 'oi_timestamp DESC' ] ); } @@ -75,9 +75,9 @@ class RevDelFileList extends RevDelList { } public function clearFileOps() { - $this->deleteBatch = array(); - $this->storeBatch = array(); - $this->cleanupBatch = array(); + $this->deleteBatch = []; + $this->storeBatch = []; + $this->cleanupBatch = []; } public function doPreCommitUpdates() { @@ -110,7 +110,7 @@ class RevDelFileList extends RevDelList { $file->purgeDescription(); // Purge full images from cache - $purgeUrls = array(); + $purgeUrls = []; foreach ( $this->ids as $timestamp ) { $archiveName = $timestamp . '!' . $this->title->getDBkey(); $file->purgeOldThumbnails( $archiveName ); diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index 7ffb42793e..26e4b17e8a 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -118,11 +118,11 @@ abstract class RevDelList extends RevisionListBase { $status = Status::newGood(); $missing = array_flip( $this->ids ); $this->clearFileOps(); - $idsForLog = array(); - $authorIds = $authorIPs = array(); + $idsForLog = []; + $authorIds = $authorIPs = []; if ( $perItemStatus ) { - $status->itemStatuses = array(); + $status->itemStatuses = []; } // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed @@ -221,7 +221,7 @@ abstract class RevDelList extends RevisionListBase { // Log it // @FIXME: $newBits/$oldBits set in for loop, makes IDE warnings too - $this->updateLog( array( + $this->updateLog( [ 'title' => $this->title, 'count' => $successCount, 'newBits' => $newBits, @@ -230,7 +230,7 @@ abstract class RevDelList extends RevisionListBase { 'ids' => $idsForLog, 'authorIds' => $authorIds, 'authorIPs' => $authorIPs - ) ); + ] ); // Clear caches $that = $this; @@ -285,11 +285,11 @@ abstract class RevDelList extends RevisionListBase { $logEntry->setParameters( $logParams ); $logEntry->setPerformer( $this->getUser() ); // Allow for easy searching of deletion log items for revision/log items - $logEntry->setRelations( array( + $logEntry->setRelations( [ $field => $params['ids'], 'target_author_id' => $params['authorIds'], 'target_author_ip' => $params['authorIPs'], - ) ); + ] ); $logId = $logEntry->insert(); $logEntry->publish( $logId ); } @@ -308,12 +308,12 @@ abstract class RevDelList extends RevisionListBase { * @return array */ public function getLogParams( $params ) { - return array( + return [ '4::type' => $this->getType(), '5::ids' => $params['ids'], '6::ofield' => $params['oldBits'], '7::nfield' => $params['newBits'], - ); + ]; } /** diff --git a/includes/revisiondelete/RevDelLogList.php b/includes/revisiondelete/RevDelLogList.php index d8bd2f7e45..07fe4a14f9 100644 --- a/includes/revisiondelete/RevDelLogList.php +++ b/includes/revisiondelete/RevDelLogList.php @@ -42,9 +42,9 @@ class RevDelLogList extends RevDelList { public static function suggestTarget( $target, array $ids ) { $result = wfGetDB( DB_SLAVE )->select( 'logging', 'log_type', - array( 'log_id' => $ids ), + [ 'log_id' => $ids ], __METHOD__, - array( 'DISTINCT' ) + [ 'DISTINCT' ] ); if ( $result->numRows() == 1 ) { // If there's only one type, the target can be set to include it. @@ -61,7 +61,7 @@ class RevDelLogList extends RevDelList { public function doQuery( $db ) { $ids = array_map( 'intval', $this->ids ); - return $db->select( 'logging', array( + return $db->select( 'logging', [ 'log_id', 'log_type', 'log_action', @@ -74,10 +74,10 @@ class RevDelLogList extends RevDelList { 'log_comment', 'log_params', 'log_deleted' - ), - array( 'log_id' => $ids ), + ], + [ 'log_id' => $ids ], __METHOD__, - array( 'ORDER BY' => 'log_id DESC' ) + [ 'ORDER BY' => 'log_id DESC' ] ); } @@ -94,10 +94,10 @@ class RevDelLogList extends RevDelList { } public function getLogParams( $params ) { - return array( + return [ '4::ids' => $params['ids'], '5::ofield' => $params['oldBits'], '6::nfield' => $params['newBits'], - ); + ]; } } diff --git a/includes/revisiondelete/RevDelRevisionItem.php b/includes/revisiondelete/RevDelRevisionItem.php index 754e68f2fc..d7991135ec 100644 --- a/includes/revisiondelete/RevDelRevisionItem.php +++ b/includes/revisiondelete/RevDelRevisionItem.php @@ -63,12 +63,12 @@ class RevDelRevisionItem extends RevDelItem { $dbw = wfGetDB( DB_MASTER ); // Update revision table $dbw->update( 'revision', - array( 'rev_deleted' => $bits ), - array( + [ 'rev_deleted' => $bits ], + [ 'rev_id' => $this->revision->getId(), 'rev_page' => $this->revision->getPage(), 'rev_deleted' => $this->getBits() // cas - ), + ], __METHOD__ ); if ( !$dbw->affectedRows() ) { @@ -77,15 +77,15 @@ class RevDelRevisionItem extends RevDelItem { } // Update recentchanges table $dbw->update( 'recentchanges', - array( + [ 'rc_deleted' => $bits, 'rc_patrolled' => 1 - ), - array( + ], + [ 'rc_this_oldid' => $this->revision->getId(), // condition // non-unique timestamp index 'rc_timestamp' => $dbw->timestamp( $this->revision->getTimestamp() ), - ), + ], __METHOD__ ); @@ -117,11 +117,11 @@ class RevDelRevisionItem extends RevDelItem { return Linker::linkKnown( $this->list->title, $date, - array(), - array( + [], + [ 'oldid' => $this->revision->getId(), 'unhide' => 1 - ) + ] ); } @@ -137,12 +137,12 @@ class RevDelRevisionItem extends RevDelItem { return Linker::linkKnown( $this->list->title, $this->list->msg( 'diff' )->escaped(), - array(), - array( + [], + [ 'diff' => $this->revision->getId(), 'oldid' => 'prev', 'unhide' => 1 - ) + ] ); } } @@ -161,7 +161,7 @@ class RevDelRevisionItem extends RevDelItem { $revlink = "$revlink"; } $content = "$difflink $revlink $userlink $comment"; - $attribs = array(); + $attribs = []; $tags = $this->getTags(); if ( $tags ) { list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow( @@ -185,23 +185,23 @@ class RevDelRevisionItem extends RevDelItem { public function getApiData( ApiResult $result ) { $rev = $this->revision; $user = $this->list->getUser(); - $ret = array( + $ret = [ 'id' => $rev->getId(), 'timestamp' => wfTimestamp( TS_ISO_8601, $rev->getTimestamp() ), - ); - $ret += $rev->isDeleted( Revision::DELETED_USER ) ? array( 'userhidden' => '' ) : array(); - $ret += $rev->isDeleted( Revision::DELETED_COMMENT ) ? array( 'commenthidden' => '' ) : array(); - $ret += $rev->isDeleted( Revision::DELETED_TEXT ) ? array( 'texthidden' => '' ) : array(); + ]; + $ret += $rev->isDeleted( Revision::DELETED_USER ) ? [ 'userhidden' => '' ] : []; + $ret += $rev->isDeleted( Revision::DELETED_COMMENT ) ? [ 'commenthidden' => '' ] : []; + $ret += $rev->isDeleted( Revision::DELETED_TEXT ) ? [ 'texthidden' => '' ] : []; if ( $rev->userCan( Revision::DELETED_USER, $user ) ) { - $ret += array( + $ret += [ 'userid' => $rev->getUser( Revision::FOR_THIS_USER ), 'user' => $rev->getUserText( Revision::FOR_THIS_USER ), - ); + ]; } if ( $rev->userCan( Revision::DELETED_COMMENT, $user ) ) { - $ret += array( + $ret += [ 'comment' => $rev->getComment( Revision::FOR_THIS_USER ), - ); + ]; } return $ret; diff --git a/includes/revisiondelete/RevDelRevisionList.php b/includes/revisiondelete/RevDelRevisionList.php index ebce50411a..bc2b2e9022 100644 --- a/includes/revisiondelete/RevDelRevisionList.php +++ b/includes/revisiondelete/RevDelRevisionList.php @@ -59,19 +59,19 @@ class RevDelRevisionList extends RevDelList { */ public function doQuery( $db ) { $ids = array_map( 'intval', $this->ids ); - $queryInfo = array( - 'tables' => array( 'revision', 'user' ), + $queryInfo = [ + 'tables' => [ 'revision', 'user' ], 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ), - 'conds' => array( + 'conds' => [ 'rev_page' => $this->title->getArticleID(), 'rev_id' => $ids, - ), - 'options' => array( 'ORDER BY' => 'rev_id DESC' ), - 'join_conds' => array( + ], + 'options' => [ 'ORDER BY' => 'rev_id DESC' ], + 'join_conds' => [ 'page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond(), - ), - ); + ], + ]; ChangeTags::modifyDisplayQuery( $queryInfo['tables'], $queryInfo['fields'], @@ -95,12 +95,12 @@ class RevDelRevisionList extends RevDelList { } // Check if any requested revisions are available fully deleted. - $archived = $db->select( array( 'archive' ), Revision::selectArchiveFields(), - array( + $archived = $db->select( [ 'archive' ], Revision::selectArchiveFields(), + [ 'ar_rev_id' => $ids - ), + ], __METHOD__, - array( 'ORDER BY' => 'ar_rev_id DESC' ) + [ 'ORDER BY' => 'ar_rev_id DESC' ] ); if ( $archived->numRows() == 0 ) { @@ -109,7 +109,7 @@ class RevDelRevisionList extends RevDelList { return $archived; } else { // Combine the two! Whee - $rows = array(); + $rows = []; foreach ( $live as $row ) { $rows[$row->rev_id] = $row; } @@ -153,7 +153,7 @@ class RevDelRevisionList extends RevDelList { public function doPostCommitUpdates() { $this->title->purgeSquid(); // Extensions that require referencing previous revisions may need this - Hooks::run( 'ArticleRevisionVisibilitySet', array( $this->title, $this->ids ) ); + Hooks::run( 'ArticleRevisionVisibilitySet', [ $this->title, $this->ids ] ); return Status::newGood(); } } diff --git a/includes/revisiondelete/RevisionDeleteUser.php b/includes/revisiondelete/RevisionDeleteUser.php index 79802d66e4..7f41eb2a1a 100644 --- a/includes/revisiondelete/RevisionDeleteUser.php +++ b/includes/revisiondelete/RevisionDeleteUser.php @@ -66,60 +66,60 @@ class RevisionDeleteUser { # Hide name from live edits $dbw->update( 'revision', - array( self::buildSetBitDeletedField( 'rev_deleted', $op, $delUser, $dbw ) ), - array( 'rev_user' => $userId ), + [ self::buildSetBitDeletedField( 'rev_deleted', $op, $delUser, $dbw ) ], + [ 'rev_user' => $userId ], __METHOD__ ); # Hide name from deleted edits $dbw->update( 'archive', - array( self::buildSetBitDeletedField( 'ar_deleted', $op, $delUser, $dbw ) ), - array( 'ar_user_text' => $name ), + [ self::buildSetBitDeletedField( 'ar_deleted', $op, $delUser, $dbw ) ], + [ 'ar_user_text' => $name ], __METHOD__ ); # Hide name from logs $dbw->update( 'logging', - array( self::buildSetBitDeletedField( 'log_deleted', $op, $delUser, $dbw ) ), - array( 'log_user' => $userId, 'log_type != ' . $dbw->addQuotes( 'suppress' ) ), + [ self::buildSetBitDeletedField( 'log_deleted', $op, $delUser, $dbw ) ], + [ 'log_user' => $userId, 'log_type != ' . $dbw->addQuotes( 'suppress' ) ], __METHOD__ ); $dbw->update( 'logging', - array( self::buildSetBitDeletedField( 'log_deleted', $op, $delAction, $dbw ) ), - array( 'log_namespace' => NS_USER, 'log_title' => $userDbKey, - 'log_type != ' . $dbw->addQuotes( 'suppress' ) ), + [ self::buildSetBitDeletedField( 'log_deleted', $op, $delAction, $dbw ) ], + [ 'log_namespace' => NS_USER, 'log_title' => $userDbKey, + 'log_type != ' . $dbw->addQuotes( 'suppress' ) ], __METHOD__ ); # Hide name from RC $dbw->update( 'recentchanges', - array( self::buildSetBitDeletedField( 'rc_deleted', $op, $delUser, $dbw ) ), - array( 'rc_user_text' => $name ), + [ self::buildSetBitDeletedField( 'rc_deleted', $op, $delUser, $dbw ) ], + [ 'rc_user_text' => $name ], __METHOD__ ); $dbw->update( 'recentchanges', - array( self::buildSetBitDeletedField( 'rc_deleted', $op, $delAction, $dbw ) ), - array( 'rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0' ), + [ self::buildSetBitDeletedField( 'rc_deleted', $op, $delAction, $dbw ) ], + [ 'rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0' ], __METHOD__ ); # Hide name from live images $dbw->update( 'oldimage', - array( self::buildSetBitDeletedField( 'oi_deleted', $op, $delUser, $dbw ) ), - array( 'oi_user_text' => $name ), + [ self::buildSetBitDeletedField( 'oi_deleted', $op, $delUser, $dbw ) ], + [ 'oi_user_text' => $name ], __METHOD__ ); # Hide name from deleted images $dbw->update( 'filearchive', - array( self::buildSetBitDeletedField( 'fa_deleted', $op, $delUser, $dbw ) ), - array( 'fa_user_text' => $name ), + [ self::buildSetBitDeletedField( 'fa_deleted', $op, $delUser, $dbw ) ], + [ 'fa_user_text' => $name ], __METHOD__ ); # Done! diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index d68ef45834..eea0c28b66 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -28,22 +28,22 @@ */ class RevisionDeleter { /** List of known revdel types, with their corresponding list classes */ - private static $allowedTypes = array( + private static $allowedTypes = [ 'revision' => 'RevDelRevisionList', 'archive' => 'RevDelArchiveList', 'oldimage' => 'RevDelFileList', 'filearchive' => 'RevDelArchivedFileList', 'logging' => 'RevDelLogList', - ); + ]; /** Type map to support old log entries */ - private static $deprecatedTypeMap = array( + private static $deprecatedTypeMap = [ 'oldid' => 'revision', 'artimestamp' => 'archive', 'oldimage' => 'oldimage', 'fileid' => 'filearchive', 'logid' => 'logging', - ); + ]; /** * Lists the valid possible types for revision deletion. @@ -126,7 +126,7 @@ class RevisionDeleter { */ public static function getChanges( $n, $o ) { $diff = $n ^ $o; - $ret = array( 0 => array(), 1 => array(), 2 => array() ); + $ret = [ 0 => [], 1 => [], 2 => [] ]; // Build bitfield changes in language self::checkItem( 'revdelete-content', Revision::DELETED_TEXT, $diff, $n, $ret ); @@ -156,7 +156,7 @@ class RevisionDeleter { if ( !$typeName ) { return null; } - return call_user_func( array( self::$allowedTypes[$typeName], 'getRelationType' ) ); + return call_user_func( [ self::$allowedTypes[$typeName], 'getRelationType' ] ); } /** @@ -170,7 +170,7 @@ class RevisionDeleter { if ( !$typeName ) { return null; } - return call_user_func( array( self::$allowedTypes[$typeName], 'getRestriction' ) ); + return call_user_func( [ self::$allowedTypes[$typeName], 'getRestriction' ] ); } /** @@ -184,7 +184,7 @@ class RevisionDeleter { if ( !$typeName ) { return null; } - return call_user_func( array( self::$allowedTypes[$typeName], 'getRevdelConstant' ) ); + return call_user_func( [ self::$allowedTypes[$typeName], 'getRevdelConstant' ] ); } /** @@ -200,7 +200,7 @@ class RevisionDeleter { if ( !$typeName ) { return $target; } - return call_user_func( array( self::$allowedTypes[$typeName], 'suggestTarget' ), $target, $ids ); + return call_user_func( [ self::$allowedTypes[$typeName], 'suggestTarget' ], $target, $ids ); } /** @@ -215,16 +215,16 @@ class RevisionDeleter { public static function checkRevisionExistence( $title, $revid ) { $dbr = wfGetDB( DB_SLAVE ); $exists = $dbr->selectField( 'revision', '1', - array( 'rev_id' => $revid ), __METHOD__ ); + [ 'rev_id' => $revid ], __METHOD__ ); if ( $exists ) { return true; } $timestamp = $dbr->selectField( 'archive', 'ar_timestamp', - array( 'ar_namespace' => $title->getNamespace(), + [ 'ar_namespace' => $title->getNamespace(), 'ar_title' => $title->getDBkey(), - 'ar_rev_id' => $revid ), __METHOD__ ); + 'ar_rev_id' => $revid ], __METHOD__ ); return $timestamp; } diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 81b850a27b..10e56bfa2f 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -34,7 +34,7 @@ class SearchEngine { public $prefix = ''; /** @var int[]|null */ - public $namespaces = array( NS_MAIN ); + public $namespaces = [ NS_MAIN ]; /** @var int */ protected $limit = 10; @@ -43,14 +43,14 @@ class SearchEngine { protected $offset = 0; /** @var array|string */ - protected $searchTerms = array(); + protected $searchTerms = []; /** @var bool */ protected $showSuggestion = true; private $sort = 'relevance'; /** @var array Feature values */ - protected $features = array(); + protected $features = []; /** * Perform a full text search query and return a result set. @@ -138,7 +138,7 @@ class SearchEngine { public static function getNearMatch( $searchterm ) { $title = self::getNearMatchInternal( $searchterm ); - Hooks::run( 'SearchGetNearMatchComplete', array( $searchterm, &$title ) ); + Hooks::run( 'SearchGetNearMatchComplete', [ $searchterm, &$title ] ); return $title; } @@ -161,7 +161,7 @@ class SearchEngine { private static function getNearMatchInternal( $searchterm ) { global $wgContLang, $wgEnableSearchContributorsByIP; - $allSearchTerms = array( $searchterm ); + $allSearchTerms = [ $searchterm ]; if ( $wgContLang->hasVariants() ) { $allSearchTerms = array_unique( array_merge( @@ -171,7 +171,7 @@ class SearchEngine { } $titleResult = null; - if ( !Hooks::run( 'SearchGetNearMatchBefore', array( $allSearchTerms, &$titleResult ) ) ) { + if ( !Hooks::run( 'SearchGetNearMatchBefore', [ $allSearchTerms, &$titleResult ] ) ) { return $titleResult; } @@ -198,7 +198,7 @@ class SearchEngine { return $title; } - if ( !Hooks::run( 'SearchAfterNoDirectMatch', array( $term, &$title ) ) ) { + if ( !Hooks::run( 'SearchAfterNoDirectMatch', [ $term, &$title ] ) ) { return $title; } @@ -228,7 +228,7 @@ class SearchEngine { // Give hooks a chance at better match variants $title = null; - if ( !Hooks::run( 'SearchGetNearMatch', array( $term, &$title ) ) ) { + if ( !Hooks::run( 'SearchGetNearMatch', [ $term, &$title ] ) ) { return $title; } } @@ -265,7 +265,7 @@ class SearchEngine { } # Quoted term? Try without the quotes... - $matches = array(); + $matches = []; if ( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) { return SearchEngine::getNearMatch( $matches[1] ); } @@ -303,7 +303,7 @@ class SearchEngine { return $ns < 0 || isset( $validNs[$ns] ); } ); } else { - $namespaces = array(); + $namespaces = []; } $this->namespaces = $namespaces; } @@ -327,7 +327,7 @@ class SearchEngine { * @return array(string) the valid sort directions for setSort */ public function getValidSorts() { - return array( 'relevance' ); + return [ 'relevance' ]; } /** @@ -379,7 +379,7 @@ class SearchEngine { $prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) ); $index = $wgContLang->getNsIndex( $prefix ); if ( $index !== false ) { - $this->namespaces = array( $index ); + $this->namespaces = [ $index ]; $parsed = substr( $query, strlen( $prefix ) + 1 ); } } @@ -396,14 +396,14 @@ class SearchEngine { */ public static function searchableNamespaces() { global $wgContLang; - $arr = array(); + $arr = []; foreach ( $wgContLang->getNamespaces() as $ns => $name ) { if ( $ns >= NS_MAIN ) { $arr[$ns] = $name; } } - Hooks::run( 'SearchableNamespaces', array( &$arr ) ); + Hooks::run( 'SearchableNamespaces', [ &$arr ] ); return $arr; } @@ -415,7 +415,7 @@ class SearchEngine { * @return array */ public static function userNamespaces( $user ) { - $arr = array(); + $arr = []; foreach ( SearchEngine::searchableNamespaces() as $ns => $name ) { if ( $user->getOption( 'searchNs' . $ns ) ) { $arr[] = $ns; @@ -433,7 +433,7 @@ class SearchEngine { public static function userHighlightPrefs() { $contextlines = 2; // Hardcode this. Old defaults sucked. :) $contextchars = 75; // same as above.... :P - return array( $contextlines, $contextchars ); + return [ $contextlines, $contextchars ]; } /** @@ -457,7 +457,7 @@ class SearchEngine { public static function namespacesAsText( $namespaces ) { global $wgContLang; - $formatted = array_map( array( $wgContLang, 'getFormattedNsText' ), $namespaces ); + $formatted = array_map( [ $wgContLang, 'getFormattedNsText' ], $namespaces ); foreach ( $formatted as $key => $ns ) { if ( empty( $ns ) ) { $formatted[$key] = wfMessage( 'blanknamespace' )->text(); @@ -501,7 +501,7 @@ class SearchEngine { public static function getSearchTypes() { global $wgSearchType, $wgSearchTypeAlternatives; - $alternatives = $wgSearchTypeAlternatives ?: array(); + $alternatives = $wgSearchTypeAlternatives ?: []; array_unshift( $alternatives, $wgSearchType ); return $alternatives; @@ -591,11 +591,11 @@ class SearchEngine { $title = Title::newFromText( $search ); $ns = $this->namespaces; if ( $title && !$title->isExternal() ) { - $ns = array( $title->getNamespace() ); + $ns = [ $title->getNamespace() ]; $search = $title->getText(); if ( $ns[0] == NS_MAIN ) { $ns = $this->namespaces; // no explicit prefix, use default namespaces - Hooks::run( 'PrefixSearchExtractNamespace', array( &$ns, &$search ) ); + Hooks::run( 'PrefixSearchExtractNamespace', [ &$ns, &$search ] ); } } else { $title = Title::newFromText( $search . 'Dummy' ); @@ -603,10 +603,10 @@ class SearchEngine { && $title->getNamespace() != NS_MAIN && !$title->isExternal() ) { - $ns = array( $title->getNamespace() ); + $ns = [ $title->getNamespace() ]; $search = ''; } else { - Hooks::run( 'PrefixSearchExtractNamespace', array( &$ns, &$search ) ); + Hooks::run( 'PrefixSearchExtractNamespace', [ &$ns, &$search ] ); } } @@ -626,13 +626,13 @@ class SearchEngine { * @return SearchSuggestionSet */ protected function completionSearchBackend( $search ) { - $results = array(); + $results = []; $search = trim( $search ); if ( !in_array( NS_SPECIAL, $this->namespaces ) && // We do not run hook on Special: search !Hooks::run( 'PrefixSearchBackend', - array( $this->namespaces, $search, $this->limit, &$results, $this->offset ) + [ $this->namespaces, $search, $this->limit, &$results, $this->offset ] ) ) { // False means hook worked. // FIXME: Yes, the API is weird. That's why it is going to be deprecated. @@ -675,7 +675,7 @@ class SearchEngine { global $wgContLang; $fallbackSearches = $wgContLang->autoConvertToAllVariants( $search ); - $fallbackSearches = array_diff( array_unique( $fallbackSearches ), array( $search ) ); + $fallbackSearches = array_diff( array_unique( $fallbackSearches ), [ $search ] ); foreach ( $fallbackSearches as $fbs ) { $this->setLimitOffset( $fallbackLimit ); @@ -755,7 +755,7 @@ class SearchEngine { */ public function defaultPrefixSearch( $search ) { if ( trim( $search ) === '' ) { - return array(); + return []; } $search = $this->normalizeNamespaces( $search ); diff --git a/includes/search/SearchExactMatchRescorer.php b/includes/search/SearchExactMatchRescorer.php index 0ff628def0..d3b9d5cb0f 100644 --- a/includes/search/SearchExactMatchRescorer.php +++ b/includes/search/SearchExactMatchRescorer.php @@ -101,7 +101,7 @@ class SearchExactMatchRescorer { * that is a redirect to it. */ private function redirectTargetsToRedirect( $titles ) { - $result = array(); + $result = []; foreach ( $titles as $key => $titleText ) { $title = Title::newFromText( $titleText ); if ( !$title || !$title->isRedirect() ) { diff --git a/includes/search/SearchHighlighter.php b/includes/search/SearchHighlighter.php index 98c05b5695..2bd19558a2 100644 --- a/includes/search/SearchHighlighter.php +++ b/includes/search/SearchHighlighter.php @@ -52,10 +52,10 @@ class SearchHighlighter { // spli text into text + templates/links/tables $spat = "/(\\{\\{)|(\\[\\[[^\\]:]+:)|(\n\\{\\|)"; // first capture group is for detecting nested templates/links/tables/references - $endPatterns = array( + $endPatterns = [ 1 => '/(\{\{)|(\}\})/', // template 2 => '/(\[\[)|(\]\])/', // image - 3 => "/(\n\\{\\|)|(\n\\|\\})/" ); // table + 3 => "/(\n\\{\\|)|(\n\\|\\})/" ]; // table // @todo FIXME: This should prolly be a hook or something // instead of hardcoding a class name from the Cite extension @@ -64,8 +64,8 @@ class SearchHighlighter { $endPatterns[4] = '/()|(<\/ref>)/'; } $spat .= '/'; - $textExt = array(); // text extracts - $otherExt = array(); // other extracts + $textExt = []; // text extracts + $otherExt = []; // other extracts $start = 0; $textLen = strlen( $text ); $count = 0; // sequence number to maintain ordering @@ -136,7 +136,7 @@ class SearchHighlighter { if ( preg_match( '/[\x80-\xff]/', $term ) ) { $terms[$index] = preg_replace_callback( '/./us', - array( $this, 'caseCallback' ), + [ $this, 'caseCallback' ], $terms[$index] ); } else { @@ -161,8 +161,8 @@ class SearchHighlighter { $left = $contextlines; - $snippets = array(); - $offsets = array(); + $snippets = []; + $offsets = []; // show beginning only if it contains all words $first = 0; @@ -202,7 +202,7 @@ class SearchHighlighter { } // add extra chars to each snippet to make snippets constant size - $extended = array(); + $extended = []; if ( count( $snippets ) == 0 ) { // couldn't find the target words, just show beginning of article if ( array_key_exists( $first, $all ) ) { @@ -214,7 +214,7 @@ class SearchHighlighter { // if begin of the article contains the whole phrase, show only that !! if ( array_key_exists( $first, $snippets ) && preg_match( $pat1, $snippets[$first] ) && $offsets[$first] < $contextchars * 2 ) { - $snippets = array( $first => $snippets[$first] ); + $snippets = [ $first => $snippets[$first] ]; } // calc by how much to extend existing snippets @@ -271,7 +271,7 @@ class SearchHighlighter { $extract .= ' ... '; } - $processed = array(); + $processed = []; foreach ( $terms as $term ) { if ( !isset( $processed[$term] ) ) { $pat3 = "/$patPre(" . $term . ")$patPost/ui"; // highlight word @@ -362,7 +362,7 @@ class SearchHighlighter { $tolerance = 10; $s = max( 0, $point - $tolerance ); $l = min( strlen( $text ), $point + $tolerance ) - $s; - $m = array(); + $m = []; if ( preg_match( '/[ ,.!?~!@#$%^&*\(\)+=\-\\\|\[\]"\'<>]/', @@ -408,7 +408,7 @@ class SearchHighlighter { continue; // this line already highlighted } - $m = array(); + $m = []; if ( !preg_match( $pattern, $line, $m, PREG_OFFSET_CAPTURE ) ) { continue; } @@ -448,7 +448,7 @@ class SearchHighlighter { $text = preg_replace( "/\\[\\[([^|]+?)\\]\\]/", "\\1", $text ); $text = preg_replace_callback( "/\\[\\[([^|]+\\|)(.*?)\\]\\]/", - array( $this, 'linkReplace' ), + [ $this, 'linkReplace' ], $text ); $text = preg_replace( "/<\/?[^>]+>/", "", $text ); @@ -508,7 +508,7 @@ class SearchHighlighter { break; } ++$lineno; - $m = array(); + $m = []; if ( !preg_match( $pat1, $line, $m ) ) { continue; } @@ -543,7 +543,7 @@ class SearchHighlighter { * @return string */ public function highlightNone( $text, $contextlines, $contextchars ) { - $match = array(); + $match = []; $text = ltrim( $text ) . "\n"; // make sure the preg_match may find the last line $text = str_replace( "\n\n", "\n", $text ); // remove empty lines preg_match( "/^(.*\n){0,$contextlines}/", $text, $match ); diff --git a/includes/search/SearchMssql.php b/includes/search/SearchMssql.php index 0d7970de38..598702d1ed 100644 --- a/includes/search/SearchMssql.php +++ b/includes/search/SearchMssql.php @@ -137,11 +137,11 @@ class SearchMssql extends SearchDatabase { function parseQuery( $filteredText, $fulltext ) { global $wgContLang; $lc = $this->legalSearchChars(); - $this->searchTerms = array(); + $this->searchTerms = []; # @todo FIXME: This doesn't handle parenthetical expressions. - $m = array(); - $q = array(); + $m = []; + $q = []; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index 14426713f0..7e823786c2 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -47,10 +47,10 @@ class SearchMySQL extends SearchDatabase { $lc = $this->legalSearchChars(); // Minus format chars $searchon = ''; - $this->searchTerms = array(); + $this->searchTerms = []; # @todo FIXME: This doesn't handle parenthetical expressions. - $m = array(); + $m = []; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach ( $m as $bits ) { @@ -80,7 +80,7 @@ class SearchMySQL extends SearchDatabase { if ( is_array( $convertedVariants ) ) { $variants = array_unique( array_values( $convertedVariants ) ); } else { - $variants = array( $term ); + $variants = [ $term ]; } // The low-level search index does some processing on input to work @@ -88,7 +88,7 @@ class SearchMySQL extends SearchDatabase { // fulltext engine. // For Chinese this also inserts spaces between adjacent Han characters. $strippedVariants = array_map( - array( $wgContLang, 'normalizeForSearch' ), + [ $wgContLang, 'normalizeForSearch' ], $variants ); // Some languages such as Chinese force all variants to a canonical @@ -257,13 +257,13 @@ class SearchMySQL extends SearchDatabase { * @since 1.18 (changed) */ function getQuery( $filteredTerm, $fulltext ) { - $query = array( - 'tables' => array(), - 'fields' => array(), - 'conds' => array(), - 'options' => array(), - 'joins' => array(), - ); + $query = [ + 'tables' => [], + 'fields' => [], + 'conds' => [], + 'options' => [], + 'joins' => [], + ]; $this->queryMain( $query, $filteredTerm, $fulltext ); $this->queryFeatures( $query ); @@ -310,13 +310,13 @@ class SearchMySQL extends SearchDatabase { function getCountQuery( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); - $query = array( - 'tables' => array( 'page', 'searchindex' ), - 'fields' => array( 'COUNT(*) as c' ), - 'conds' => array( 'page_id=si_page', $match ), - 'options' => array(), - 'joins' => array(), - ); + $query = [ + 'tables' => [ 'page', 'searchindex' ], + 'fields' => [ 'COUNT(*) as c' ], + 'conds' => [ 'page_id=si_page', $match ], + 'options' => [], + 'joins' => [], + ]; $this->queryFeatures( $query ); $this->queryNamespaces( $query ); @@ -335,12 +335,12 @@ class SearchMySQL extends SearchDatabase { function update( $id, $title, $text ) { $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'searchindex', - array( 'si_page' ), - array( + [ 'si_page' ], + [ 'si_page' => $id, 'si_title' => $this->normalizeText( $title ), 'si_text' => $this->normalizeText( $text ) - ), __METHOD__ ); + ], __METHOD__ ); } /** @@ -354,10 +354,10 @@ class SearchMySQL extends SearchDatabase { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'searchindex', - array( 'si_title' => $this->normalizeText( $title ) ), - array( 'si_page' => $id ), + [ 'si_title' => $this->normalizeText( $title ) ], + [ 'si_page' => $id ], __METHOD__, - array( $dbw->lowPriorityOption() ) ); + [ $dbw->lowPriorityOption() ] ); } /** @@ -370,7 +370,7 @@ class SearchMySQL extends SearchDatabase { function delete( $id, $title ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'searchindex', array( 'si_page' => $id ), __METHOD__ ); + $dbw->delete( 'searchindex', [ 'si_page' => $id ], __METHOD__ ); } /** @@ -388,7 +388,7 @@ class SearchMySQL extends SearchDatabase { // need to fold cases and convert to hex $out = preg_replace_callback( "/([\\xc0-\\xff][\\x80-\\xbf]*)/", - array( $this, 'stripForSearchCallback' ), + [ $this, 'stripForSearchCallback' ], $wgContLang->lc( $out ) ); // And to add insult to injury, the default indexing diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 6dad3424b1..c5a5ef11a7 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -29,7 +29,7 @@ * @ingroup Search */ class SearchOracle extends SearchDatabase { - private $reservedWords = array( + private $reservedWords = [ 'ABOUT' => 1, 'ACCUM' => 1, 'AND' => 1, @@ -56,7 +56,7 @@ class SearchOracle extends SearchDatabase { 'TRSYN' => 1, 'TT' => 1, 'WITHIN' => 1, - ); + ]; /** * Perform a full text search query and return a result set. @@ -175,10 +175,10 @@ class SearchOracle extends SearchDatabase { function parseQuery( $filteredText, $fulltext ) { global $wgContLang; $lc = $this->legalSearchChars(); - $this->searchTerms = array(); + $this->searchTerms = []; # @todo FIXME: This doesn't handle parenthetical expressions. - $m = array(); + $m = []; $searchon = ''; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { @@ -231,12 +231,12 @@ class SearchOracle extends SearchDatabase { function update( $id, $title, $text ) { $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'searchindex', - array( 'si_page' ), - array( + [ 'si_page' ], + [ 'si_page' => $id, 'si_title' => $title, 'si_text' => $text - ), 'SearchOracle::update' ); + ], 'SearchOracle::update' ); // Sync the index // We need to specify the DB name (i.e. user/schema) here so that @@ -260,10 +260,10 @@ class SearchOracle extends SearchDatabase { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'searchindex', - array( 'si_title' => $title ), - array( 'si_page' => $id ), + [ 'si_title' => $title ], + [ 'si_page' => $id ], 'SearchOracle::updateTitle', - array() ); + [] ); } public static function legalSearchChars() { diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 649ef4f70f..8da39dbd1b 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -76,7 +76,7 @@ class SearchPostgres extends SearchDatabase { $term = preg_replace( '/:/', ' ', $term ); $searchstring = ''; - $m = array(); + $m = []; if ( preg_match_all( '/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) { foreach ( $m as $terms ) { if ( strlen( $terms[1] ) ) { @@ -139,13 +139,13 @@ class SearchPostgres extends SearchDatabase { $top = $res->fetchRow(); $top = $top[0]; - $this->searchTerms = array(); + $this->searchTerms = []; if ( $top === "" ) { # # e.g. if only stopwords are used XXX return something better $query = "SELECT page_id, page_namespace, page_title, 0 AS score " . "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " . "AND r.rev_text_id = c.old_id AND 1=0"; } else { - $m = array(); + $m = []; if ( preg_match_all( "/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) { foreach ( $m as $terms ) { $this->searchTerms[$terms[1]] = $terms[1]; diff --git a/includes/search/SearchResult.php b/includes/search/SearchResult.php index 765cfc1938..6c406e7e16 100644 --- a/includes/search/SearchResult.php +++ b/includes/search/SearchResult.php @@ -71,7 +71,7 @@ class SearchResult { $this->mTitle = $title; if ( !is_null( $this->mTitle ) ) { $id = false; - Hooks::run( 'SearchResultInitFromTitle', array( $title, &$id ) ); + Hooks::run( 'SearchResultInitFromTitle', [ $title, &$id ] ); $this->mRevision = Revision::newFromTitle( $this->mTitle, $id, Revision::READ_NORMAL ); if ( $this->mTitle->getNamespace() === NS_FILE ) { diff --git a/includes/search/SearchResultSet.php b/includes/search/SearchResultSet.php index eccd36e8eb..bfee698f12 100644 --- a/includes/search/SearchResultSet.php +++ b/includes/search/SearchResultSet.php @@ -54,7 +54,7 @@ class SearchResultSet { * @return array */ function termMatches() { - return array(); + return []; } function numRows() { diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index 3a5ee0efe4..b40e1aaf38 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -46,9 +46,9 @@ class SearchSqlite extends SearchDatabase { global $wgContLang; $lc = $this->legalSearchChars(); // Minus format chars $searchon = ''; - $this->searchTerms = array(); + $this->searchTerms = []; - $m = array(); + $m = []; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach ( $m as $bits ) { @@ -74,7 +74,7 @@ class SearchSqlite extends SearchDatabase { if ( is_array( $convertedVariants ) ) { $variants = array_unique( array_values( $convertedVariants ) ); } else { - $variants = array( $term ); + $variants = [ $term ]; } // The low-level search index does some processing on input to work @@ -82,7 +82,7 @@ class SearchSqlite extends SearchDatabase { // fulltext engine. // For Chinese this also inserts spaces between adjacent Han characters. $strippedVariants = array_map( - array( $wgContLang, 'normalizeForSearch' ), + [ $wgContLang, 'normalizeForSearch' ], $variants ); // Some languages such as Chinese force all variants to a canonical @@ -276,14 +276,14 @@ class SearchSqlite extends SearchDatabase { // couldn't do it so far due to typelessness of FTS3 tables. $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'searchindex', array( 'rowid' => $id ), __METHOD__ ); + $dbw->delete( 'searchindex', [ 'rowid' => $id ], __METHOD__ ); $dbw->insert( 'searchindex', - array( + [ 'rowid' => $id, 'si_title' => $title, 'si_text' => $text - ), __METHOD__ ); + ], __METHOD__ ); } /** @@ -300,8 +300,8 @@ class SearchSqlite extends SearchDatabase { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'searchindex', - array( 'si_title' => $title ), - array( 'rowid' => $id ), + [ 'si_title' => $title ], + [ 'rowid' => $id ], __METHOD__ ); } } diff --git a/includes/search/SearchSuggestionSet.php b/includes/search/SearchSuggestionSet.php index a1f9a04c9e..4750181285 100644 --- a/includes/search/SearchSuggestionSet.php +++ b/includes/search/SearchSuggestionSet.php @@ -28,13 +28,13 @@ class SearchSuggestionSet { /** * @var SearchSuggestion[] */ - private $suggestions = array(); + private $suggestions = []; /** * * @var array */ - private $pageMap = array(); + private $pageMap = []; /** * Builds a new set of suggestions. @@ -208,6 +208,6 @@ class SearchSuggestionSet { * @return SearchSuggestionSet an empty suggestion set */ public static function emptySuggestionSet() { - return new SearchSuggestionSet( array() ); + return new SearchSuggestionSet( [] ); } } diff --git a/includes/session/BotPasswordSessionProvider.php b/includes/session/BotPasswordSessionProvider.php index 81c7ebfb81..44199bdec4 100644 --- a/includes/session/BotPasswordSessionProvider.php +++ b/includes/session/BotPasswordSessionProvider.php @@ -39,7 +39,7 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { * - sessionCookieName: Session cookie name. Default is '_BPsession'. * - sessionCookieOptions: Options to pass to WebResponse::setCookie(). */ - public function __construct( array $params = array() ) { + public function __construct( array $params = [] ) { if ( !isset( $params['sessionCookieName'] ) ) { $params['sessionCookieName'] = '_BPsession'; } @@ -74,11 +74,11 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { return null; } - return new SessionInfo( $this->priority, array( + return new SessionInfo( $this->priority, [ 'provider' => $this, 'id' => $id, 'persisted' => true - ) ); + ] ); } public function newSessionInfo( $id = null ) { @@ -95,18 +95,18 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { */ public function newSessionForRequest( User $user, BotPassword $bp, WebRequest $request ) { $id = $this->getSessionIdFromCookie( $request ); - $info = new SessionInfo( SessionInfo::MAX_PRIORITY, array( + $info = new SessionInfo( SessionInfo::MAX_PRIORITY, [ 'provider' => $this, 'id' => $id, 'userInfo' => UserInfo::newFromUser( $user, true ), 'persisted' => $id !== null, - 'metadata' => array( + 'metadata' => [ 'centralId' => $bp->getUserCentralId(), 'appId' => $bp->getAppId(), 'token' => $bp->getToken(), 'rights' => \MWGrants::getGrantRights( $bp->getGrants() ), - ), - ) ); + ], + ] ); $session = $this->getManager()->getSessionFromInfo( $info, $request ); $session->persist(); return $session; @@ -114,14 +114,14 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { public function refreshSessionInfo( SessionInfo $info, WebRequest $request, &$metadata ) { $missingKeys = array_diff( - array( 'centralId', 'appId', 'token' ), + [ 'centralId', 'appId', 'token' ], array_keys( $metadata ) ); if ( $missingKeys ) { - $this->logger->info( 'Session "{session}": Missing metadata: {missing}', array( + $this->logger->info( 'Session "{session}": Missing metadata: {missing}', [ 'session' => $info, 'missing' => join( ', ', $missingKeys ), - ) ); + ] ); return false; } @@ -129,20 +129,20 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { if ( !$bp ) { $this->logger->info( 'Session "{session}": No BotPassword for {centralId} {appId}', - array( + [ 'session' => $info, 'centralId' => $metadata['centralId'], 'appId' => $metadata['appId'], - ) ); + ] ); return false; } if ( !hash_equals( $metadata['token'], $bp->getToken() ) ) { - $this->logger->info( 'Session "{session}": BotPassword token check failed', array( + $this->logger->info( 'Session "{session}": BotPassword token check failed', [ 'session' => $info, 'centralId' => $metadata['centralId'], 'appId' => $metadata['appId'], - ) ); + ] ); return false; } @@ -150,12 +150,12 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { if ( !$status->isOk() ) { $this->logger->info( 'Session "{session}": Restrictions check failed', - array( + [ 'session' => $info, 'restrictions' => $status->getValue(), 'centralId' => $metadata['centralId'], 'appId' => $metadata['appId'], - ) ); + ] ); return false; } @@ -180,6 +180,6 @@ class BotPasswordSessionProvider extends ImmutableSessionProviderWithCookie { // Should never happen $this->logger->debug( __METHOD__ . ': No provider metadata, returning no rights allowed' ); - return array(); + return []; } } diff --git a/includes/session/CookieSessionProvider.php b/includes/session/CookieSessionProvider.php index 8d7830b077..8ce3174dc0 100644 --- a/includes/session/CookieSessionProvider.php +++ b/includes/session/CookieSessionProvider.php @@ -35,8 +35,8 @@ use WebRequest; */ class CookieSessionProvider extends SessionProvider { - protected $params = array(); - protected $cookieOptions = array(); + protected $params = []; + protected $cookieOptions = []; /** * @param array $params Keys include: @@ -51,13 +51,13 @@ class CookieSessionProvider extends SessionProvider { * - secure: Cookie secure flag, defaults to $wgCookieSecure * - httpOnly: Cookie httpOnly flag, defaults to $wgCookieHttpOnly */ - public function __construct( $params = array() ) { + public function __construct( $params = [] ) { parent::__construct(); - $params += array( - 'cookieOptions' => array(), + $params += [ + 'cookieOptions' => [], // @codeCoverageIgnoreStart - ); + ]; // @codeCoverageIgnoreEnd if ( !isset( $params['priority'] ) ) { @@ -84,30 +84,30 @@ class CookieSessionProvider extends SessionProvider { parent::setConfig( $config ); // @codeCoverageIgnoreStart - $this->params += array( + $this->params += [ // @codeCoverageIgnoreEnd 'callUserSetCookiesHook' => false, 'sessionName' => $config->get( 'SessionName' ) ?: $config->get( 'CookiePrefix' ) . '_session', - ); + ]; // @codeCoverageIgnoreStart - $this->cookieOptions += array( + $this->cookieOptions += [ // @codeCoverageIgnoreEnd 'prefix' => $config->get( 'CookiePrefix' ), 'path' => $config->get( 'CookiePath' ), 'domain' => $config->get( 'CookieDomain' ), 'secure' => $config->get( 'CookieSecure' ), 'httpOnly' => $config->get( 'CookieHttpOnly' ), - ); + ]; } public function provideSessionInfo( WebRequest $request ) { $sessionId = $this->getCookie( $request, $this->params['sessionName'], '' ); - $info = array( + $info = [ 'provider' => $this, 'forceHTTPS' => $this->getCookie( $request, 'forceHTTPS', '', false ) - ); + ]; if ( SessionManager::validateSessionId( $sessionId ) ) { $info['id'] = $sessionId; $info['persisted'] = true; @@ -125,14 +125,14 @@ class CookieSessionProvider extends SessionProvider { if ( $userName !== null && $userInfo->getName() !== $userName ) { $this->logger->warning( 'Session "{session}" requested with mismatched UserID and UserName cookies.', - array( + [ 'session' => $sessionId, - 'mismatch' => array( + 'mismatch' => [ 'userid' => $userId, 'cookie_username' => $userName, 'username' => $userInfo->getName(), - ), - ) ); + ], + ] ); return null; } @@ -140,11 +140,11 @@ class CookieSessionProvider extends SessionProvider { if ( !hash_equals( $userInfo->getToken(), $token ) ) { $this->logger->warning( 'Session "{session}" requested with invalid Token cookie.', - array( + [ 'session' => $sessionId, 'userid' => $userId, 'username' => $userInfo->getName(), - ) ); + ] ); return null; } $info['userInfo'] = $userInfo->verified(); @@ -164,9 +164,9 @@ class CookieSessionProvider extends SessionProvider { // * anon browsing after edit or preview $this->logger->debug( 'Session "{session}" requested without UserID cookie', - array( + [ 'session' => $info['id'], - ) ); + ] ); $info['userInfo'] = UserInfo::newAnonymous(); } else { // No session ID and no user is the same as an empty session, so @@ -200,7 +200,7 @@ class CookieSessionProvider extends SessionProvider { // Legacy hook if ( $this->params['callUserSetCookiesHook'] && !$user->isAnon() ) { - \Hooks::run( 'UserSetCookies', array( $user, &$sessionData, &$cookies ) ); + \Hooks::run( 'UserSetCookies', [ $user, &$sessionData, &$cookies ] ); } $options = $this->cookieOptions; @@ -214,7 +214,7 @@ class CookieSessionProvider extends SessionProvider { } $response->setCookie( $this->params['sessionName'], $session->getId(), null, - array( 'prefix' => '' ) + $options + [ 'prefix' => '' ] + $options ); $extendedCookies = $this->config->get( 'ExtendedLoginCookies' ); @@ -249,13 +249,13 @@ class CookieSessionProvider extends SessionProvider { return; } - $cookies = array( + $cookies = [ 'UserID' => false, 'Token' => false, - ); + ]; $response->clearCookie( - $this->params['sessionName'], array( 'prefix' => '' ) + $this->cookieOptions + $this->params['sessionName'], [ 'prefix' => '' ] + $this->cookieOptions ); foreach ( $cookies as $key => $value ) { @@ -277,10 +277,10 @@ class CookieSessionProvider extends SessionProvider { $response = $request->response(); if ( $set ) { $response->setCookie( 'forceHTTPS', 'true', $backend->shouldRememberUser() ? 0 : null, - array( 'prefix' => '', 'secure' => false ) + $this->cookieOptions ); + [ 'prefix' => '', 'secure' => false ] + $this->cookieOptions ); } else { $response->clearCookie( 'forceHTTPS', - array( 'prefix' => '', 'secure' => false ) + $this->cookieOptions ); + [ 'prefix' => '', 'secure' => false ] + $this->cookieOptions ); } } @@ -299,14 +299,14 @@ class CookieSessionProvider extends SessionProvider { } public function getVaryCookies() { - return array( + return [ // Vary on token and session because those are the real authn // determiners. UserID and UserName don't matter without those. $this->cookieOptions['prefix'] . 'Token', $this->cookieOptions['prefix'] . 'LoggedOut', $this->params['sessionName'], 'forceHTTPS', - ); + ]; } public function suggestLoginUsername( WebRequest $request ) { @@ -324,11 +324,11 @@ class CookieSessionProvider extends SessionProvider { */ protected function getUserInfoFromCookies( $request ) { $prefix = $this->cookieOptions['prefix']; - return array( + return [ $this->getCookie( $request, 'UserID', $prefix ), $this->getCookie( $request, 'UserName', $prefix ), $this->getCookie( $request, 'Token', $prefix ), - ); + ]; } /** @@ -360,16 +360,16 @@ class CookieSessionProvider extends SessionProvider { */ protected function cookieDataToExport( $user, $remember ) { if ( $user->isAnon() ) { - return array( + return [ 'UserID' => false, 'Token' => false, - ); + ]; } else { - return array( + return [ 'UserID' => $user->getId(), 'UserName' => $user->getName(), 'Token' => $remember ? (string)$user->getToken() : false, - ); + ]; } } @@ -382,14 +382,14 @@ class CookieSessionProvider extends SessionProvider { // If we're calling the legacy hook, we should populate $session // like User::setCookies() did. if ( !$user->isAnon() && $this->params['callUserSetCookiesHook'] ) { - return array( + return [ 'wsUserID' => $user->getId(), 'wsToken' => $user->getToken(), 'wsUserName' => $user->getName(), - ); + ]; } - return array(); + return []; } public function whyNoSession() { diff --git a/includes/session/ImmutableSessionProviderWithCookie.php b/includes/session/ImmutableSessionProviderWithCookie.php index 98f7e5c079..2f6e1330a2 100644 --- a/includes/session/ImmutableSessionProviderWithCookie.php +++ b/includes/session/ImmutableSessionProviderWithCookie.php @@ -41,7 +41,7 @@ abstract class ImmutableSessionProviderWithCookie extends SessionProvider { /** @var string|null */ protected $sessionCookieName = null; - protected $sessionCookieOptions = array(); + protected $sessionCookieOptions = []; /** * @param array $params Keys include: @@ -49,7 +49,7 @@ abstract class ImmutableSessionProviderWithCookie extends SessionProvider { * client are to be supported. * - sessionCookieOptions: Options to pass to WebResponse::setCookie(). */ - public function __construct( $params = array() ) { + public function __construct( $params = [] ) { parent::__construct(); if ( isset( $params['sessionCookieName'] ) ) { @@ -114,7 +114,7 @@ abstract class ImmutableSessionProviderWithCookie extends SessionProvider { $options = $this->sessionCookieOptions; if ( $session->shouldForceHTTPS() || $session->getUser()->requiresHTTPS() ) { $response->setCookie( 'forceHTTPS', 'true', $session->shouldRememberUser() ? 0 : null, - array( 'prefix' => '', 'secure' => false ) + $options ); + [ 'prefix' => '', 'secure' => false ] + $options ); $options['secure'] = true; } @@ -138,13 +138,13 @@ abstract class ImmutableSessionProviderWithCookie extends SessionProvider { public function getVaryCookies() { if ( $this->sessionCookieName === null ) { - return array(); + return []; } $prefix = isset( $this->sessionCookieOptions['prefix'] ) ? $this->sessionCookieOptions['prefix'] : $this->config->get( 'CookiePrefix' ); - return array( $prefix . $this->sessionCookieName ); + return [ $prefix . $this->sessionCookieName ]; } public function whyNoSession() { diff --git a/includes/session/PHPSessionHandler.php b/includes/session/PHPSessionHandler.php index 7d7e1cb77e..93b0b36c07 100644 --- a/includes/session/PHPSessionHandler.php +++ b/includes/session/PHPSessionHandler.php @@ -49,7 +49,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { protected $logger; /** @var array Track original session fields for later modification check */ - protected $sessionFieldCache = array(); + protected $sessionFieldCache = []; protected function __construct( SessionManager $manager ) { $this->setEnableFlags( @@ -182,7 +182,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { if ( self::$instance !== $this ) { throw new \UnexpectedValueException( __METHOD__ . ': Wrong instance called!' ); } - $this->sessionFieldCache = array(); + $this->sessionFieldCache = []; return true; } @@ -234,9 +234,9 @@ class PHPSessionHandler implements \SessionHandlerInterface { // invalid. Let's emit a log warning instead of a PHP warning. $this->logger->warning( __METHOD__ . ': Session "{session}" cannot be loaded, skipping write.', - array( + [ 'session' => $id, - ) ); + ] ); return true; } @@ -250,7 +250,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { // Now merge the data into the Session object. $changed = false; - $cache = isset( $this->sessionFieldCache[$id] ) ? $this->sessionFieldCache[$id] : array(); + $cache = isset( $this->sessionFieldCache[$id] ) ? $this->sessionFieldCache[$id] : []; foreach ( $data as $key => $value ) { if ( !array_key_exists( $key, $cache ) ) { if ( $session->exists( $key ) ) { @@ -288,7 +288,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { \Wikimedia\PhpSessionSerializer::setLogger( new \Psr\Log\NullLogger() ); foreach ( $cache as $key => $value ) { if ( !array_key_exists( $key, $data ) && $session->exists( $key ) && - \Wikimedia\PhpSessionSerializer::encode( array( $key => true ) ) + \Wikimedia\PhpSessionSerializer::encode( [ $key => true ] ) ) { if ( $cache[$key] === $session->get( $key ) ) { // Unchanged in Session, delete it diff --git a/includes/session/Session.php b/includes/session/Session.php index d654ff1449..96e8d50445 100644 --- a/includes/session/Session.php +++ b/includes/session/Session.php @@ -240,7 +240,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess { public function clear() { $data = &$this->backend->getData(); if ( $data ) { - $data = array(); + $data = []; $this->backend->dirty(); } if ( $this->backend->canSetUser() ) { @@ -334,7 +334,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess { $new = false; $secrets = $this->get( 'wsTokenSecrets' ); if ( !is_array( $secrets ) ) { - $secrets = array(); + $secrets = []; } if ( isset( $secrets[$key] ) && is_string( $secrets[$key] ) ) { $secret = $secrets[$key]; @@ -445,7 +445,7 @@ final class Session implements \Countable, \Iterator, \ArrayAccess { $data = &$this->backend->getData(); if ( !array_key_exists( $offset, $data ) ) { $ex = new \Exception( "Undefined index (auto-adds to session with a null value): $offset" ); - $this->logger->debug( $ex->getMessage(), array( 'exception' => $ex ) ); + $this->logger->debug( $ex->getMessage(), [ 'exception' => $ex ] ); } return $data[$offset]; } diff --git a/includes/session/SessionBackend.php b/includes/session/SessionBackend.php index 5cf7869f41..0a9191b123 100644 --- a/includes/session/SessionBackend.php +++ b/includes/session/SessionBackend.php @@ -79,7 +79,7 @@ final class SessionBackend { private $curIndex = 0; /** @var WebRequest[] Session requests */ - private $requests = array(); + private $requests = []; /** @var SessionProvider provider */ private $provider; @@ -135,14 +135,14 @@ final class SessionBackend { !isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) || !isset( $blob['data'] ) || !is_array( $blob['data'] ) ) { - $this->data = array(); + $this->data = []; $this->dataDirty = true; $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" is unsaved, marking dirty in constructor', - array( + [ 'session' => $this->id, - ) ); + ] ); } else { $this->data = $blob['data']; if ( isset( $blob['metadata']['loggedOut'] ) ) { @@ -154,9 +154,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to missing expiration timestamp', - array( + [ 'session' => $this->id, - ) ); + ] ); } } $this->dataHash = md5( serialize( $this->data ) ); @@ -225,10 +225,10 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to ID reset (formerly "{oldId}")', - array( + [ 'session' => $this->id, 'oldId' => $oldId, - ) ); + ] ); if ( $restart ) { session_id( (string)$this->id ); @@ -274,9 +274,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" force-persist due to persist()', - array( + [ 'session' => $this->id, - ) ); + ] ); $this->autosave(); } else { $this->renew(); @@ -303,9 +303,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to remember-user change', - array( + [ 'session' => $this->id, - ) ); + ] ); $this->autosave(); } } @@ -364,9 +364,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to user change', - array( + [ 'session' => $this->id, - ) ); + ] ); $this->autosave(); } @@ -400,9 +400,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to force-HTTPS change', - array( + [ 'session' => $this->id, - ) ); + ] ); $this->autosave(); } } @@ -426,9 +426,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to logged-out-timestamp change', - array( + [ 'session' => $this->id, - ) ); + ] ); $this->autosave(); } } @@ -456,9 +456,9 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{session}" metadata dirty due to provider metadata change', - array( + [ 'session' => $this->id, - ) ); + ] ); $this->autosave(); } } @@ -491,10 +491,10 @@ final class SessionBackend { $this->dataDirty = true; $this->logger->debug( 'SessionBackend "{session}" data dirty due to addData(): {callers}', - array( + [ 'session' => $this->id, 'callers' => wfGetAllCallers( 5 ), - ) ); + ] ); } } } @@ -507,10 +507,10 @@ final class SessionBackend { $this->dataDirty = true; $this->logger->debug( 'SessionBackend "{session}" data dirty due to dirty(): {callers}', - array( + [ 'session' => $this->id, 'callers' => wfGetAllCallers( 5 ), - ) ); + ] ); } /** @@ -524,18 +524,18 @@ final class SessionBackend { $this->metaDirty = true; $this->logger->debug( 'SessionBackend "{callers}" metadata dirty for renew(): {callers}', - array( + [ 'session' => $this->id, 'callers' => wfGetAllCallers( 5 ), - ) ); + ] ); if ( $this->persist ) { $this->forcePersist = true; $this->logger->debug( 'SessionBackend "{session}" force-persist for renew(): {callers}', - array( + [ 'session' => $this->id, 'callers' => wfGetAllCallers( 5 ), - ) ); + ] ); } } $this->autosave(); @@ -576,10 +576,10 @@ final class SessionBackend { $this->logger->debug( 'SessionBackend "{session}" not saving, user {user} was ' . 'passed to SessionManager::preventSessionsForUser', - array( + [ 'session' => $this->id, 'user' => $this->user, - ) ); + ] ); return; } @@ -589,10 +589,10 @@ final class SessionBackend { if ( !$anon && !$this->user->getToken( false ) ) { $this->logger->debug( 'SessionBackend "{session}" creating token for user {user} on save', - array( + [ 'session' => $this->id, 'user' => $this->user, - ) ); + ] ); $this->user->setToken(); if ( !wfReadOnly() ) { $this->user->saveSettings(); @@ -606,11 +606,11 @@ final class SessionBackend { ) { $this->logger->debug( 'SessionBackend "{session}" data dirty due to hash mismatch, {expected} !== {got}', - array( + [ 'session' => $this->id, 'expected' => $this->dataHash, 'got' => md5( serialize( $this->data ) ), - ) ); + ] ); $this->dataDirty = true; } @@ -621,12 +621,12 @@ final class SessionBackend { $this->logger->debug( 'SessionBackend "{session}" save: dataDirty={dataDirty} ' . 'metaDirty={metaDirty} forcePersist={forcePersist}', - array( + [ 'session' => $this->id, 'dataDirty' => (int)$this->dataDirty, 'metaDirty' => (int)$this->metaDirty, 'forcePersist' => (int)$this->forcePersist, - ) ); + ] ); // Persist to the provider, if flagged if ( $this->persist && ( $this->metaDirty || $this->forcePersist ) ) { @@ -646,7 +646,7 @@ final class SessionBackend { } // Save session data to store, if necessary - $metadata = $origMetadata = array( + $metadata = $origMetadata = [ 'provider' => (string)$this->provider, 'providerMetadata' => $this->providerMetadata, 'userId' => $anon ? 0 : $this->user->getId(), @@ -657,9 +657,9 @@ final class SessionBackend { 'expires' => time() + $this->lifetime, 'loggedOut' => $this->loggedOut, 'persisted' => $this->persist, - ); + ]; - \Hooks::run( 'SessionMetadata', array( $this, &$metadata, $this->requests ) ); + \Hooks::run( 'SessionMetadata', [ $this, &$metadata, $this->requests ] ); foreach ( $origMetadata as $k => $v ) { if ( $metadata[$k] !== $v ) { @@ -669,10 +669,10 @@ final class SessionBackend { $this->store->set( wfMemcKey( 'MWSession', (string)$this->id ), - array( + [ 'data' => $this->data, 'metadata' => $metadata, - ), + ], $metadata['expires'], $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY ); @@ -699,9 +699,9 @@ final class SessionBackend { ) { $this->logger->debug( 'SessionBackend "{session}" Taking over PHP session', - array( + [ 'session' => $this->id, - ) ); + ] ); session_id( (string)$this->id ); \MediaWiki\quietCall( 'session_start' ); } diff --git a/includes/session/SessionInfo.php b/includes/session/SessionInfo.php index 9c4a2bd47f..1b5a834c94 100644 --- a/includes/session/SessionInfo.php +++ b/includes/session/SessionInfo.php @@ -88,7 +88,7 @@ class SessionInfo { if ( !$from instanceof SessionInfo ) { throw new \InvalidArgumentException( 'Invalid copyFrom' ); } - $data += array( + $data += [ 'provider' => $from->provider, 'id' => $from->id, 'userInfo' => $from->userInfo, @@ -98,10 +98,10 @@ class SessionInfo { 'metadata' => $from->providerMetadata, 'idIsSafe' => $from->idIsSafe, // @codeCoverageIgnoreStart - ); + ]; // @codeCoverageIgnoreEnd } else { - $data += array( + $data += [ 'provider' => null, 'id' => null, 'userInfo' => null, @@ -111,7 +111,7 @@ class SessionInfo { 'metadata' => null, 'idIsSafe' => false, // @codeCoverageIgnoreStart - ); + ]; // @codeCoverageIgnoreEnd } diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index d3b7a2dae9..5573ec7af3 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -67,13 +67,13 @@ final class SessionManager implements SessionManagerInterface { private $varyHeaders = null; /** @var SessionBackend[] */ - private $allSessionBackends = array(); + private $allSessionBackends = []; /** @var SessionId[] */ - private $allSessionIds = array(); + private $allSessionIds = []; /** @var string[] */ - private $preventUsers = array(); + private $preventUsers = []; /** * Get the global SessionManager @@ -136,7 +136,7 @@ final class SessionManager implements SessionManagerInterface { * - logger: LoggerInterface to use for logging. Defaults to the 'session' channel. * - store: BagOStuff to store session data in. */ - public function __construct( $options = array() ) { + public function __construct( $options = [] ) { if ( isset( $options['config'] ) ) { $this->config = $options['config']; if ( !$this->config instanceof Config ) { @@ -172,7 +172,7 @@ final class SessionManager implements SessionManagerInterface { } $this->store = $store instanceof CachedBagOStuff ? $store : new CachedBagOStuff( $store ); - register_shutdown_function( array( $this, 'shutdown' ) ); + register_shutdown_function( [ $this, 'shutdown' ] ); } public function setLogger( LoggerInterface $logger ) { @@ -204,7 +204,7 @@ final class SessionManager implements SessionManagerInterface { // of "no such ID" $key = wfMemcKey( 'MWSession', $id ); if ( is_array( $this->store->get( $key ) ) ) { - $info = new SessionInfo( SessionInfo::MIN_PRIORITY, array( 'id' => $id, 'idIsSafe' => true ) ); + $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [ 'id' => $id, 'idIsSafe' => true ] ); if ( $this->loadSessionInfoFromStore( $info, $request ) ) { $session = $this->getSessionFromInfo( $info, $request ); } @@ -216,10 +216,10 @@ final class SessionManager implements SessionManagerInterface { $session = $this->getEmptySessionInternal( $request, $id ); } catch ( \Exception $ex ) { $this->logger->error( 'Failed to create empty session: {exception}', - array( + [ 'method' => __METHOD__, 'exception' => $ex, - ) ); + ] ); $session = null; } } @@ -252,7 +252,7 @@ final class SessionManager implements SessionManagerInterface { $request = new FauxRequest; } - $infos = array(); + $infos = []; foreach ( $this->getProviders() as $provider ) { $info = $provider->newSessionInfo( $id ); if ( !$info ) { @@ -281,7 +281,7 @@ final class SessionManager implements SessionManagerInterface { if ( $compare === 0 ) { $infos[] = $info; } else { - $infos = array( $info ); + $infos = [ $info ]; } } @@ -299,11 +299,11 @@ final class SessionManager implements SessionManagerInterface { public function getVaryHeaders() { if ( $this->varyHeaders === null ) { - $headers = array(); + $headers = []; foreach ( $this->getProviders() as $provider ) { foreach ( $provider->getVaryHeaders() as $header => $options ) { if ( !isset( $headers[$header] ) ) { - $headers[$header] = array(); + $headers[$header] = []; } if ( is_array( $options ) ) { $headers[$header] = array_unique( array_merge( $headers[$header], $options ) ); @@ -317,7 +317,7 @@ final class SessionManager implements SessionManagerInterface { public function getVaryCookies() { if ( $this->varyCookies === null ) { - $cookies = array(); + $cookies = []; foreach ( $this->getProviders() as $provider ) { $cookies = array_merge( $cookies, $provider->getVaryCookies() ); } @@ -430,7 +430,7 @@ final class SessionManager implements SessionManagerInterface { // Give other extensions a chance to stop auto creation. $user->loadDefaults( $userName ); $abortMessage = ''; - if ( !\Hooks::run( 'AbortAutoAccount', array( $user, &$abortMessage ) ) ) { + if ( !\Hooks::run( 'AbortAutoAccount', [ $user, &$abortMessage ] ) ) { // In this case we have no way to return the message to the user, // but we can log it. $logger->debug( __METHOD__ . ": denied by hook: $abortMessage" ); @@ -465,10 +465,10 @@ final class SessionManager implements SessionManagerInterface { // Checks passed, create the user... $from = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : 'CLI'; $logger->info( __METHOD__ . ': creating new user ({username}) - from: {url}', - array( + [ 'username' => $userName, 'url' => $from, - ) ); + ] ); try { // Insert the user into the local DB master @@ -476,9 +476,9 @@ final class SessionManager implements SessionManagerInterface { if ( !$status->isOK() ) { // @codeCoverageIgnoreStart $logger->error( __METHOD__ . ': failed with message ' . $status->getWikiText(), - array( + [ 'username' => $userName, - ) ); + ] ); $user->setId( 0 ); $user->loadFromId(); return false; @@ -486,10 +486,10 @@ final class SessionManager implements SessionManagerInterface { } } catch ( \Exception $ex ) { // @codeCoverageIgnoreStart - $logger->error( __METHOD__ . ': failed with exception {exception}', array( + $logger->error( __METHOD__ . ': failed with exception {exception}', [ 'exception' => $ex, 'username' => $userName, - ) ); + ] ); // Do not keep throwing errors for a while $cache->set( $backoffKey, 1, 600 ); // Bubble up error; which should normally trigger DB rollbacks @@ -506,8 +506,8 @@ final class SessionManager implements SessionManagerInterface { } # Notify hooks (e.g. Newuserlog) - \Hooks::run( 'AuthPluginAutoCreate', array( $user ) ); - \Hooks::run( 'LocalUserCreated', array( $user, true ) ); + \Hooks::run( 'AuthPluginAutoCreate', [ $user ] ); + \Hooks::run( 'LocalUserCreated', [ $user, true ] ); $user->saveSettings(); @@ -554,7 +554,7 @@ final class SessionManager implements SessionManagerInterface { */ protected function getProviders() { if ( $this->sessionProviders === null ) { - $this->sessionProviders = array(); + $this->sessionProviders = []; foreach ( $this->config->get( 'SessionProviders' ) as $spec ) { $provider = \ObjectFactory::getObjectFromSpec( $spec ); $provider->setLogger( $this->logger ); @@ -609,7 +609,7 @@ final class SessionManager implements SessionManagerInterface { */ private function getSessionInfoForRequest( WebRequest $request ) { // Call all providers to fetch "the" session - $infos = array(); + $infos = []; foreach ( $this->getProviders() as $provider ) { $info = $provider->provideSessionInfo( $request ); if ( !$info ) { @@ -627,7 +627,7 @@ final class SessionManager implements SessionManagerInterface { // successfully loaded, and then all the ones after it with the same // priority. usort( $infos, 'MediaWiki\\Session\\SessionInfo::compare' ); - $retInfos = array(); + $retInfos = []; while ( $infos ) { $info = array_pop( $infos ); if ( $this->loadSessionInfoFromStore( $info, $request ) ) { @@ -669,14 +669,14 @@ final class SessionManager implements SessionManagerInterface { $key = wfMemcKey( 'MWSession', $info->getId() ); $blob = $this->store->get( $key ); - $newParams = array(); + $newParams = []; if ( $blob !== false ) { // Sanity check: blob must be an array, if it's saved at all if ( !is_array( $blob ) ) { - $this->logger->warning( 'Session "{session}": Bad data', array( + $this->logger->warning( 'Session "{session}": Bad data', [ 'session' => $info, - ) ); + ] ); $this->store->delete( $key ); return false; } @@ -685,9 +685,9 @@ final class SessionManager implements SessionManagerInterface { if ( !isset( $blob['data'] ) || !is_array( $blob['data'] ) || !isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) ) { - $this->logger->warning( 'Session "{session}": Bad data structure', array( + $this->logger->warning( 'Session "{session}": Bad data structure', [ 'session' => $info, - ) ); + ] ); $this->store->delete( $key ); return false; } @@ -702,9 +702,9 @@ final class SessionManager implements SessionManagerInterface { !array_key_exists( 'userToken', $metadata ) || !array_key_exists( 'provider', $metadata ) ) { - $this->logger->warning( 'Session "{session}": Bad metadata', array( + $this->logger->warning( 'Session "{session}": Bad metadata', [ 'session' => $info, - ) ); + ] ); $this->store->delete( $key ); return false; } @@ -716,9 +716,9 @@ final class SessionManager implements SessionManagerInterface { if ( !$provider ) { $this->logger->warning( 'Session "{session}": Unknown provider ' . $metadata['provider'], - array( + [ 'session' => $info, - ) + ] ); $this->store->delete( $key ); return false; @@ -726,9 +726,9 @@ final class SessionManager implements SessionManagerInterface { } elseif ( $metadata['provider'] !== (string)$provider ) { $this->logger->warning( 'Session "{session}": Wrong provider ' . $metadata['provider'] . ' !== ' . $provider, - array( + [ 'session' => $info, - ) ); + ] ); return false; } @@ -748,10 +748,10 @@ final class SessionManager implements SessionManagerInterface { } catch ( MetadataMergeException $ex ) { $this->logger->warning( 'Session "{session}": Metadata merge failed: {exception}', - array( + [ 'session' => $info, 'exception' => $ex, - ) + $ex->getContext() + ] + $ex->getContext() ); return false; } @@ -771,10 +771,10 @@ final class SessionManager implements SessionManagerInterface { $userInfo = UserInfo::newAnonymous(); } } catch ( \InvalidArgumentException $ex ) { - $this->logger->error( 'Session "{session}": {exception}', array( + $this->logger->error( 'Session "{session}": {exception}', [ 'session' => $info, 'exception' => $ex, - ) ); + ] ); return false; } $newParams['userInfo'] = $userInfo; @@ -785,11 +785,11 @@ final class SessionManager implements SessionManagerInterface { if ( $metadata['userId'] !== $userInfo->getId() ) { $this->logger->warning( 'Session "{session}": User ID mismatch, {uid_a} !== {uid_b}', - array( + [ 'session' => $info, 'uid_a' => $metadata['userId'], 'uid_b' => $userInfo->getId(), - ) ); + ] ); return false; } @@ -799,11 +799,11 @@ final class SessionManager implements SessionManagerInterface { ) { $this->logger->warning( 'Session "{session}": User ID matched but name didn\'t (rename?), {uname_a} !== {uname_b}', - array( + [ 'session' => $info, 'uname_a' => $metadata['userName'], 'uname_b' => $userInfo->getName(), - ) ); + ] ); return false; } @@ -811,11 +811,11 @@ final class SessionManager implements SessionManagerInterface { if ( $metadata['userName'] !== $userInfo->getName() ) { $this->logger->warning( 'Session "{session}": User name mismatch, {uname_a} !== {uname_b}', - array( + [ 'session' => $info, 'uname_a' => $metadata['userName'], 'uname_b' => $userInfo->getName(), - ) ); + ] ); return false; } } elseif ( !$userInfo->isAnon() ) { @@ -823,9 +823,9 @@ final class SessionManager implements SessionManagerInterface { // user isn't anonymous. $this->logger->warning( 'Session "{session}": Metadata has an anonymous user, but a non-anon user was provided', - array( + [ 'session' => $info, - ) ); + ] ); return false; } } @@ -834,9 +834,9 @@ final class SessionManager implements SessionManagerInterface { if ( $metadata['userToken'] !== null && $userInfo->getToken() !== $metadata['userToken'] ) { - $this->logger->warning( 'Session "{session}": User token mismatch', array( + $this->logger->warning( 'Session "{session}": User token mismatch', [ 'session' => $info, - ) ); + ] ); return false; } if ( !$userInfo->isVerified() ) { @@ -861,9 +861,9 @@ final class SessionManager implements SessionManagerInterface { if ( $info->getProvider() === null ) { $this->logger->warning( 'Session "{session}": Null provider and no metadata', - array( + [ 'session' => $info, - ) ); + ] ); return false; } @@ -874,17 +874,17 @@ final class SessionManager implements SessionManagerInterface { } else { $this->logger->info( 'Session "{session}": No user provided and provider cannot set user', - array( + [ 'session' => $info, - ) ); + ] ); return false; } } elseif ( !$info->getUserInfo()->isVerified() ) { $this->logger->warning( 'Session "{session}": Unverified user provided and no metadata to auth it', - array( + [ 'session' => $info, - ) ); + ] ); return false; } @@ -910,10 +910,10 @@ final class SessionManager implements SessionManagerInterface { return false; } if ( $providerMetadata !== $info->getProviderMetadata() ) { - $info = new SessionInfo( $info->getPriority(), array( + $info = new SessionInfo( $info->getPriority(), [ 'metadata' => $providerMetadata, 'copyFrom' => $info, - ) ); + ] ); } // Give hooks a chance to abort. Combined with the SessionMetadata @@ -922,11 +922,11 @@ final class SessionManager implements SessionManagerInterface { $reason = 'Hook aborted'; if ( !\Hooks::run( 'SessionCheckInfo', - array( &$reason, $info, $request, $metadata, $data ) + [ &$reason, $info, $request, $metadata, $data ] ) ) { - $this->logger->warning( 'Session "{session}": ' . $reason, array( + $this->logger->warning( 'Session "{session}": ' . $reason, [ 'session' => $info, - ) ); + ] ); return false; } @@ -1080,7 +1080,7 @@ final class SessionManager implements SessionManagerInterface { // This is slightly inaccurate (when an existing IP is seen again, the expiry is not // extended) but that shouldn't make much difference and limits the session write frequency // to # of IPs / $wgSuspiciousIpExpiry. - $data = $session->get( 'SessionManager-ip', array() ); + $data = $session->get( 'SessionManager-ip', [] ); if ( !isset( $data[$ip] ) || $data[$ip] < $now @@ -1099,13 +1099,13 @@ final class SessionManager implements SessionManagerInterface { $logger->log( $logLevel, 'Same session used from {count} IPs', - array( + [ 'count' => count( $data ), 'ips' => $data, 'session' => $session->getId(), 'user' => $session->getUser()->getName(), 'persistent' => $session->isPersistent(), - ) + ] ); } @@ -1115,7 +1115,7 @@ final class SessionManager implements SessionManagerInterface { // that or a central ID lookup which would mean an extra SQL query on every request.) if ( $session->getUser()->isLoggedIn() ) { $userKey = 'SessionManager-ip:' . md5( $session->getUser()->getName() ); - $data = $this->store->get( $userKey ) ?: array(); + $data = $this->store->get( $userKey ) ?: []; if ( !isset( $data[$ip] ) || $data[$ip] < $now @@ -1133,13 +1133,13 @@ final class SessionManager implements SessionManagerInterface { $logger->log( $logLevel, 'Same user had sessions from {count} IPs', - array( + [ 'count' => count( $data ), 'ips' => $data, 'session' => $session->getId(), 'user' => $session->getUser()->getName(), 'persistent' => $session->isPersistent(), - ) + ] ); } } diff --git a/includes/session/SessionProvider.php b/includes/session/SessionProvider.php index db6294ddd0..1975ee8344 100644 --- a/includes/session/SessionProvider.php +++ b/includes/session/SessionProvider.php @@ -166,12 +166,12 @@ abstract class SessionProvider implements SessionProviderInterface, LoggerAwareI */ public function newSessionInfo( $id = null ) { if ( $this->canChangeUser() && $this->persistsSessionId() ) { - return new SessionInfo( $this->priority, array( + return new SessionInfo( $this->priority, [ 'id' => $id, 'provider' => $this, 'persisted' => false, 'idIsSafe' => true, - ) ); + ] ); } return null; } @@ -372,7 +372,7 @@ abstract class SessionProvider implements SessionProviderInterface, LoggerAwareI * @return array */ public function getVaryHeaders() { - return array(); + return []; } /** @@ -381,7 +381,7 @@ abstract class SessionProvider implements SessionProviderInterface, LoggerAwareI * @return string[] */ public function getVaryCookies() { - return array(); + return []; } /** diff --git a/includes/site/CachingSiteStore.php b/includes/site/CachingSiteStore.php index 077dbc0efd..a2f43f307b 100644 --- a/includes/site/CachingSiteStore.php +++ b/includes/site/CachingSiteStore.php @@ -142,7 +142,7 @@ class CachingSiteStore implements SiteStore { * @return bool Success indicator */ public function saveSite( Site $site ) { - return $this->saveSites( array( $site ) ); + return $this->saveSites( [ $site ] ); } /** diff --git a/includes/site/DBSiteStore.php b/includes/site/DBSiteStore.php index 17764a1985..756bb5140b 100644 --- a/includes/site/DBSiteStore.php +++ b/includes/site/DBSiteStore.php @@ -71,7 +71,7 @@ class DBSiteStore implements SiteStore { $res = $dbr->select( 'sites', - array( + [ 'site_id', 'site_global_key', 'site_type', @@ -83,10 +83,10 @@ class DBSiteStore implements SiteStore { 'site_data', 'site_forward', 'site_config', - ), + ], '', __METHOD__, - array( 'ORDER BY' => 'site_global_key' ) + [ 'ORDER BY' => 'site_global_key' ] ); foreach ( $res as $row ) { @@ -108,12 +108,12 @@ class DBSiteStore implements SiteStore { // Batch load the local site identifiers. $ids = $dbr->select( 'site_identifiers', - array( + [ 'si_site', 'si_type', 'si_key', - ), - array(), + ], + [], __METHOD__ ); @@ -153,7 +153,7 @@ class DBSiteStore implements SiteStore { * @return bool Success indicator */ public function saveSite( Site $site ) { - return $this->saveSites( array( $site ) ); + return $this->saveSites( [ $site ] ); } /** @@ -176,15 +176,15 @@ class DBSiteStore implements SiteStore { $success = true; - $internalIds = array(); - $localIds = array(); + $internalIds = []; + $localIds = []; foreach ( $sites as $site ) { if ( $site->getInternalId() !== null ) { $internalIds[] = $site->getInternalId(); } - $fields = array( + $fields = [ // Site data 'site_global_key' => $site->getGlobalId(), // TODO: check not null 'site_type' => $site->getType(), @@ -198,12 +198,12 @@ class DBSiteStore implements SiteStore { // Site config 'site_forward' => $site->shouldForward() ? 1 : 0, 'site_config' => serialize( $site->getExtraConfig() ), - ); + ]; $rowId = $site->getInternalId(); if ( $rowId !== null ) { $success = $dbw->update( - 'sites', $fields, array( 'site_id' => $rowId ), __METHOD__ + 'sites', $fields, [ 'site_id' => $rowId ], __METHOD__ ) && $success; } else { $rowId = $dbw->nextSequenceValue( 'sites_site_id_seq' ); @@ -214,15 +214,15 @@ class DBSiteStore implements SiteStore { foreach ( $site->getLocalIds() as $idType => $ids ) { foreach ( $ids as $id ) { - $localIds[] = array( $rowId, $idType, $id ); + $localIds[] = [ $rowId, $idType, $id ]; } } } - if ( $internalIds !== array() ) { + if ( $internalIds !== [] ) { $dbw->delete( 'site_identifiers', - array( 'si_site' => $internalIds ), + [ 'si_site' => $internalIds ], __METHOD__ ); } @@ -230,11 +230,11 @@ class DBSiteStore implements SiteStore { foreach ( $localIds as $localId ) { $dbw->insert( 'site_identifiers', - array( + [ 'si_site' => $localId[0], 'si_type' => $localId[1], 'si_key' => $localId[2], - ), + ], __METHOD__ ); } diff --git a/includes/site/HashSiteStore.php b/includes/site/HashSiteStore.php index 2c2547210a..0d0e448fd1 100644 --- a/includes/site/HashSiteStore.php +++ b/includes/site/HashSiteStore.php @@ -34,12 +34,12 @@ class HashSiteStore implements SiteStore { /** * @var Site[] */ - private $sites = array(); + private $sites = []; /** * @param array $sites */ - public function __construct( $sites = array() ) { + public function __construct( $sites = [] ) { $this->saveSites( $sites ); } @@ -115,7 +115,7 @@ class HashSiteStore implements SiteStore { * list and getSite() will return null until saveSite() or saveSites() is called. */ public function clear() { - $this->sites = array(); + $this->sites = []; return true; } diff --git a/includes/site/MediaWikiPageNameNormalizer.php b/includes/site/MediaWikiPageNameNormalizer.php index f358bd4e69..2f71736779 100644 --- a/includes/site/MediaWikiPageNameNormalizer.php +++ b/includes/site/MediaWikiPageNameNormalizer.php @@ -67,7 +67,7 @@ class MediaWikiPageNameNormalizer { $pageName = Validator::cleanUp( $pageName ); // Build the args for the specific call - $args = array( + $args = [ 'action' => 'query', 'prop' => 'info', 'redirects' => true, @@ -79,13 +79,13 @@ class MediaWikiPageNameNormalizer { // but that maxage can avoid the extreme delay. On the other hand // maxage could be nice to use anyhow as it stops unnecessary requests. // Also consider smaxage if maxage is used. - ); + ]; $url = wfAppendQuery( $apiUrl, $args ); // Go on call the external site // @todo we need a good way to specify a timeout here. - $ret = Http::get( $url, array(), __METHOD__ ); + $ret = Http::get( $url, [], __METHOD__ ); if ( $ret === false ) { wfDebugLog( "MediaWikiSite", "call to external site failed: $url" ); @@ -146,12 +146,12 @@ class MediaWikiPageNameNormalizer { return false; } // Loop over the tree different named structures, that otherwise are similar - $structs = array( + $structs = [ 'normalized' => 'from', 'converted' => 'from', 'redirects' => 'from', 'pages' => 'title' - ); + ]; foreach ( $structs as $listId => $fieldId ) { // Check if the substructure exist at all. if ( !isset( $externalData['query'][$listId] ) ) { diff --git a/includes/site/Site.php b/includes/site/Site.php index c0246bcca6..6a97a50209 100644 --- a/includes/site/Site.php +++ b/includes/site/Site.php @@ -91,21 +91,21 @@ class Site implements Serializable { * * @var array[] */ - protected $localIds = array(); + protected $localIds = []; /** * @since 1.21 * * @var array */ - protected $extraData = array(); + protected $extraData = []; /** * @since 1.21 * * @var array */ - protected $extraConfig = array(); + protected $extraConfig = []; /** * @since 1.21 @@ -499,11 +499,11 @@ class Site implements Serializable { */ public function addLocalId( $type, $identifier ) { if ( $this->localIds === false ) { - $this->localIds = array(); + $this->localIds = []; } if ( !array_key_exists( $type, $this->localIds ) ) { - $this->localIds[$type] = array(); + $this->localIds[$type] = []; } if ( !in_array( $identifier, $this->localIds[$type] ) ) { @@ -543,7 +543,7 @@ class Site implements Serializable { public function getInterwikiIds() { return array_key_exists( self::ID_INTERWIKI, $this->localIds ) ? $this->localIds[self::ID_INTERWIKI] - : array(); + : []; } /** @@ -557,7 +557,7 @@ class Site implements Serializable { public function getNavigationIds() { return array_key_exists( self::ID_EQUIVALENT, $this->localIds ) ? $this->localIds[self::ID_EQUIVALENT] : - array(); + []; } /** @@ -588,7 +588,7 @@ class Site implements Serializable { } if ( !array_key_exists( 'paths', $this->extraData ) ) { - $this->extraData['paths'] = array(); + $this->extraData['paths'] = []; } $this->extraData['paths'][$pathType] = $fullUrl; @@ -617,7 +617,7 @@ class Site implements Serializable { * @return string[] */ public function getAllPaths() { - return array_key_exists( 'paths', $this->extraData ) ? $this->extraData['paths'] : array(); + return array_key_exists( 'paths', $this->extraData ) ? $this->extraData['paths'] : []; } /** @@ -658,7 +658,7 @@ class Site implements Serializable { * @return string */ public function serialize() { - $fields = array( + $fields = [ 'globalid' => $this->globalId, 'type' => $this->type, 'group' => $this->group, @@ -670,7 +670,7 @@ class Site implements Serializable { 'forward' => $this->forward, 'internalid' => $this->internalId, - ); + ]; return serialize( $fields ); } diff --git a/includes/site/SiteExporter.php b/includes/site/SiteExporter.php index 294f1dba82..01b838ef14 100644 --- a/includes/site/SiteExporter.php +++ b/includes/site/SiteExporter.php @@ -52,10 +52,10 @@ class SiteExporter { * @param Site[]|SiteList $sites */ public function exportSites( $sites ) { - $attributes = array( + $attributes = [ 'version' => '1.0', 'xmlns' => 'http://www.mediawiki.org/xml/sitelist-1.0/', - ); + ]; fwrite( $this->sink, Xml::openElement( 'sites', $attributes ) . "\n" ); @@ -74,7 +74,7 @@ class SiteExporter { */ private function exportSite( Site $site ) { if ( $site->getType() !== Site::TYPE_UNKNOWN ) { - $siteAttr = array( 'type' => $site->getType() ); + $siteAttr = [ 'type' => $site->getType() ]; } else { $siteAttr = null; } @@ -96,12 +96,12 @@ class SiteExporter { } foreach ( $site->getAllPaths() as $type => $path ) { - fwrite( $this->sink, "\t\t" . Xml::element( 'path', array( 'type' => $type ), $path ) . "\n" ); + fwrite( $this->sink, "\t\t" . Xml::element( 'path', [ 'type' => $type ], $path ) . "\n" ); } foreach ( $site->getLocalIds() as $type => $ids ) { foreach ( $ids as $id ) { - fwrite( $this->sink, "\t\t" . Xml::element( 'localid', array( 'type' => $type ), $id ) . "\n" ); + fwrite( $this->sink, "\t\t" . Xml::element( 'localid', [ 'type' => $type ], $id ) . "\n" ); } } diff --git a/includes/site/SiteImporter.php b/includes/site/SiteImporter.php index 9aefea2518..42812e14fb 100644 --- a/includes/site/SiteImporter.php +++ b/includes/site/SiteImporter.php @@ -116,7 +116,7 @@ class SiteImporter { * @return Site[] */ private function makeSiteList( DOMElement $root ) { - $sites = array(); + $sites = []; // Old sites, to get the row IDs that correspond to the global site IDs. // TODO: Get rid of internal row IDs, they just get in the way. Get rid of ORMRow, too. diff --git a/includes/site/SiteList.php b/includes/site/SiteList.php index 691e24b2ef..a94aa0b93b 100644 --- a/includes/site/SiteList.php +++ b/includes/site/SiteList.php @@ -34,7 +34,7 @@ class SiteList extends GenericArrayObject { * * @var array Array of integer */ - protected $byInternalId = array(); + protected $byInternalId = []; /** * Global site identifiers pointing to their sites offset value. @@ -43,7 +43,7 @@ class SiteList extends GenericArrayObject { * * @var array Array of string */ - protected $byGlobalId = array(); + protected $byGlobalId = []; /** * Navigational site identifiers alias inter-language prefixes @@ -53,7 +53,7 @@ class SiteList extends GenericArrayObject { * * @var array Array of string */ - protected $byNavigationId = array(); + protected $byNavigationId = []; /** * @see GenericArrayObject::getObjectType @@ -175,7 +175,7 @@ class SiteList extends GenericArrayObject { * @return bool */ public function isEmpty() { - return $this->byGlobalId === array(); + return $this->byGlobalId === []; } /** @@ -323,11 +323,11 @@ class SiteList extends GenericArrayObject { // old structure too, or update SERIAL_VERSION_ID to kill any caches. return array_merge( parent::getSerializationData(), - array( + [ 'internalIds' => $this->byInternalId, 'globalIds' => $this->byGlobalId, 'navigationIds' => $this->byNavigationId - ) + ] ); } diff --git a/includes/site/SitesCacheFileBuilder.php b/includes/site/SitesCacheFileBuilder.php index 2e42040999..b4046e364c 100644 --- a/includes/site/SitesCacheFileBuilder.php +++ b/includes/site/SitesCacheFileBuilder.php @@ -55,16 +55,16 @@ class SitesCacheFileBuilder { * @return bool */ private function cacheSites( array $sites ) { - $sitesArray = array(); + $sitesArray = []; foreach ( $sites as $site ) { $globalId = $site->getGlobalId(); $sitesArray[$globalId] = $this->getSiteAsArray( $site ); } - $json = json_encode( array( + $json = json_encode( [ 'sites' => $sitesArray - ) ); + ] ); $result = file_put_contents( $this->cacheFile, $json ); @@ -79,7 +79,7 @@ class SitesCacheFileBuilder { private function getSiteAsArray( Site $site ) { $siteEntry = unserialize( $site->serialize() ); $siteIdentifiers = $this->buildLocalIdentifiers( $site ); - $identifiersArray = array(); + $identifiersArray = []; foreach ( $siteIdentifiers as $identifier ) { $identifiersArray[] = $identifier; @@ -96,14 +96,14 @@ class SitesCacheFileBuilder { * @return array Site local identifiers */ private function buildLocalIdentifiers( Site $site ) { - $localIds = array(); + $localIds = []; foreach ( $site->getLocalIds() as $idType => $ids ) { foreach ( $ids as $id ) { - $localIds[] = array( + $localIds[] = [ 'type' => $idType, 'key' => $id - ); + ]; } } diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 13dffb46ae..0966f80954 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -164,8 +164,8 @@ abstract class ChangesListSpecialPage extends SpecialPage { */ protected function getCustomFilters() { if ( $this->customFilters === null ) { - $this->customFilters = array(); - Hooks::run( 'ChangesListSpecialPageFilters', array( $this, &$this->customFilters ) ); + $this->customFilters = []; + Hooks::run( 'ChangesListSpecialPageFilters', [ $this, &$this->customFilters ] ); } return $this->customFilters; @@ -213,7 +213,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { public function buildMainQueryConds( FormOptions $opts ) { $dbr = $this->getDB(); $user = $this->getUser(); - $conds = array(); + $conds = []; // It makes no sense to hide both anons and logged-in users. When this occurs, try a guess on // what the user meant and either show only bots or force anons to be shown. @@ -293,10 +293,10 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @return bool|ResultWrapper Result or false */ public function doMainQuery( $conds, $opts ) { - $tables = array( 'recentchanges' ); + $tables = [ 'recentchanges' ]; $fields = RecentChange::selectFields(); - $query_options = array(); - $join_conds = array(); + $query_options = []; + $join_conds = []; ChangeTags::modifyDisplayQuery( $tables, @@ -330,7 +330,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { ) { return Hooks::run( 'ChangesListSpecialPageQuery', - array( $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) + [ $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ] ); } @@ -416,7 +416,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @return array */ public function getExtraOptions( $opts ) { - return array(); + return []; } /** @@ -440,21 +440,21 @@ abstract class ChangesListSpecialPage extends SpecialPage { $cssClass = isset( $item['class'] ) ? $item['class'] : $key; $legend .= Html::element( 'dt', - array( 'class' => $cssClass ), $context->msg( $letter )->text() + [ 'class' => $cssClass ], $context->msg( $letter )->text() ) . "\n" . Html::rawElement( 'dd', - array( 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ), + [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ], $context->msg( $label )->parse() ) . "\n"; } # (+-123) $legend .= Html::rawElement( 'dt', - array( 'class' => 'mw-plusminus-pos' ), + [ 'class' => 'mw-plusminus-pos' ], $context->msg( 'recentchanges-legend-plusminus' )->parse() ) . "\n"; $legend .= Html::element( 'dd', - array( 'class' => 'mw-changeslist-legend-plusminus' ), + [ 'class' => 'mw-changeslist-legend-plusminus' ], $context->msg( 'recentchanges-label-plusminus' )->text() ) . "\n"; $legend .= Html::closeElement( 'dl' ) . "\n"; diff --git a/includes/specialpage/FormSpecialPage.php b/includes/specialpage/FormSpecialPage.php index d22875b9bd..c28c456965 100644 --- a/includes/specialpage/FormSpecialPage.php +++ b/includes/specialpage/FormSpecialPage.php @@ -95,7 +95,7 @@ abstract class FormSpecialPage extends SpecialPage { $this->getContext(), $this->getMessagePrefix() ); - $form->setSubmitCallback( array( $this, 'onSubmit' ) ); + $form->setSubmitCallback( [ $this, 'onSubmit' ] ); if ( $this->getDisplayFormat() !== 'ooui' ) { // No legend and wrapper by default in OOUI forms, but can be set manually // from alterForm() @@ -109,7 +109,7 @@ abstract class FormSpecialPage extends SpecialPage { // Retain query parameters (uselang etc) $params = array_diff_key( - $this->getRequest()->getQueryValues(), array( 'title' => null ) ); + $this->getRequest()->getQueryValues(), [ 'title' => null ] ); $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params ) ); $form->addPreText( $this->preText() ); @@ -117,7 +117,7 @@ abstract class FormSpecialPage extends SpecialPage { $this->alterForm( $form ); // Give hooks a chance to alter the form, adding extra fields or text etc - Hooks::run( 'SpecialPageBeforeFormDisplay', array( $this->getName(), &$form ) ); + Hooks::run( 'SpecialPageBeforeFormDisplay', [ $this->getName(), &$form ] ); return $form; } diff --git a/includes/specialpage/PageQueryPage.php b/includes/specialpage/PageQueryPage.php index d72744b13c..97f004f243 100644 --- a/includes/specialpage/PageQueryPage.php +++ b/includes/specialpage/PageQueryPage.php @@ -65,7 +65,7 @@ abstract class PageQueryPage extends QueryPage { $text = $wgContLang->convert( $title->getPrefixedText() ); return Linker::link( $title, htmlspecialchars( $text ) ); } else { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), + return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], Linker::getInvalidTitleDescription( $this->getContext(), $row->namespace, $row->title ) ); } } diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index bb26cf34f2..83e6db38df 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -64,43 +64,43 @@ abstract class QueryPage extends SpecialPage { if ( $qp === null ) { // QueryPage subclass, Special page name - $qp = array( - array( 'AncientPagesPage', 'Ancientpages' ), - array( 'BrokenRedirectsPage', 'BrokenRedirects' ), - array( 'DeadendPagesPage', 'Deadendpages' ), - array( 'DoubleRedirectsPage', 'DoubleRedirects' ), - array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ), - array( 'ListDuplicatedFilesPage', 'ListDuplicatedFiles' ), - array( 'LinkSearchPage', 'LinkSearch' ), - array( 'ListredirectsPage', 'Listredirects' ), - array( 'LonelyPagesPage', 'Lonelypages' ), - array( 'LongPagesPage', 'Longpages' ), - array( 'MediaStatisticsPage', 'MediaStatistics' ), - array( 'MIMEsearchPage', 'MIMEsearch' ), - array( 'MostcategoriesPage', 'Mostcategories' ), - array( 'MostimagesPage', 'Mostimages' ), - array( 'MostinterwikisPage', 'Mostinterwikis' ), - array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ), - array( 'MostlinkedTemplatesPage', 'Mostlinkedtemplates' ), - array( 'MostlinkedPage', 'Mostlinked' ), - array( 'MostrevisionsPage', 'Mostrevisions' ), - array( 'FewestrevisionsPage', 'Fewestrevisions' ), - array( 'ShortPagesPage', 'Shortpages' ), - array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ), - array( 'UncategorizedPagesPage', 'Uncategorizedpages' ), - array( 'UncategorizedImagesPage', 'Uncategorizedimages' ), - array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ), - array( 'UnusedCategoriesPage', 'Unusedcategories' ), - array( 'UnusedimagesPage', 'Unusedimages' ), - array( 'WantedCategoriesPage', 'Wantedcategories' ), - array( 'WantedFilesPage', 'Wantedfiles' ), - array( 'WantedPagesPage', 'Wantedpages' ), - array( 'WantedTemplatesPage', 'Wantedtemplates' ), - array( 'UnwatchedpagesPage', 'Unwatchedpages' ), - array( 'UnusedtemplatesPage', 'Unusedtemplates' ), - array( 'WithoutInterwikiPage', 'Withoutinterwiki' ), - ); - Hooks::run( 'wgQueryPages', array( &$qp ) ); + $qp = [ + [ 'AncientPagesPage', 'Ancientpages' ], + [ 'BrokenRedirectsPage', 'BrokenRedirects' ], + [ 'DeadendPagesPage', 'Deadendpages' ], + [ 'DoubleRedirectsPage', 'DoubleRedirects' ], + [ 'FileDuplicateSearchPage', 'FileDuplicateSearch' ], + [ 'ListDuplicatedFilesPage', 'ListDuplicatedFiles' ], + [ 'LinkSearchPage', 'LinkSearch' ], + [ 'ListredirectsPage', 'Listredirects' ], + [ 'LonelyPagesPage', 'Lonelypages' ], + [ 'LongPagesPage', 'Longpages' ], + [ 'MediaStatisticsPage', 'MediaStatistics' ], + [ 'MIMEsearchPage', 'MIMEsearch' ], + [ 'MostcategoriesPage', 'Mostcategories' ], + [ 'MostimagesPage', 'Mostimages' ], + [ 'MostinterwikisPage', 'Mostinterwikis' ], + [ 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ], + [ 'MostlinkedTemplatesPage', 'Mostlinkedtemplates' ], + [ 'MostlinkedPage', 'Mostlinked' ], + [ 'MostrevisionsPage', 'Mostrevisions' ], + [ 'FewestrevisionsPage', 'Fewestrevisions' ], + [ 'ShortPagesPage', 'Shortpages' ], + [ 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ], + [ 'UncategorizedPagesPage', 'Uncategorizedpages' ], + [ 'UncategorizedImagesPage', 'Uncategorizedimages' ], + [ 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ], + [ 'UnusedCategoriesPage', 'Unusedcategories' ], + [ 'UnusedimagesPage', 'Unusedimages' ], + [ 'WantedCategoriesPage', 'Wantedcategories' ], + [ 'WantedFilesPage', 'Wantedfiles' ], + [ 'WantedPagesPage', 'Wantedpages' ], + [ 'WantedTemplatesPage', 'Wantedtemplates' ], + [ 'UnwatchedpagesPage', 'Unwatchedpages' ], + [ 'UnusedtemplatesPage', 'Unusedtemplates' ], + [ 'WithoutInterwikiPage', 'Withoutinterwiki' ], + ]; + Hooks::run( 'wgQueryPages', [ &$qp ] ); } return $qp; @@ -165,7 +165,7 @@ abstract class QueryPage extends SpecialPage { * @since 1.18 */ function getOrderFields() { - return array( 'value' ); + return [ 'value' ]; } /** @@ -271,7 +271,7 @@ abstract class QueryPage extends SpecialPage { * @return array */ function linkParameters() { - return array(); + return []; } /** @@ -315,7 +315,7 @@ abstract class QueryPage extends SpecialPage { if ( $res ) { $num = $res->numRows(); # Fetch results - $vals = array(); + $vals = []; foreach ( $res as $row ) { if ( isset( $row->value ) ) { if ( $this->usesTimestamps() ) { @@ -328,12 +328,12 @@ abstract class QueryPage extends SpecialPage { $value = 0; } - $vals[] = array( + $vals[] = [ 'qc_type' => $this->getName(), 'qc_namespace' => $row->namespace, 'qc_title' => $row->title, 'qc_value' => $value - ); + ]; } $dbw->doAtomicSection( @@ -341,7 +341,7 @@ abstract class QueryPage extends SpecialPage { function ( IDatabase $dbw, $fname ) use ( $vals ) { # Clear out any old cached data $dbw->delete( 'querycache', - array( 'qc_type' => $this->getName() ), + [ 'qc_type' => $this->getName() ], $fname ); # Save results into the querycache table on the master @@ -350,12 +350,12 @@ abstract class QueryPage extends SpecialPage { } # Update the querycache_info record for the page $dbw->delete( 'querycache_info', - array( 'qci_type' => $this->getName() ), + [ 'qci_type' => $this->getName() ], $fname ); $dbw->insert( 'querycache_info', - array( 'qci_type' => $this->getName(), - 'qci_timestamp' => $dbw->timestamp() ), + [ 'qci_type' => $this->getName(), + 'qci_timestamp' => $dbw->timestamp() ], $fname ); } @@ -376,7 +376,7 @@ abstract class QueryPage extends SpecialPage { * @return IDatabase */ function getRecacheDB() { - return wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); + return wfGetDB( DB_SLAVE, [ $this->getName(), 'QueryPage::recache', 'vslow' ] ); } /** @@ -399,11 +399,11 @@ abstract class QueryPage extends SpecialPage { } if ( is_array( $query ) ) { - $tables = isset( $query['tables'] ) ? (array)$query['tables'] : array(); - $fields = isset( $query['fields'] ) ? (array)$query['fields'] : array(); - $conds = isset( $query['conds'] ) ? (array)$query['conds'] : array(); - $options = isset( $query['options'] ) ? (array)$query['options'] : array(); - $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : array(); + $tables = isset( $query['tables'] ) ? (array)$query['tables'] : []; + $fields = isset( $query['fields'] ) ? (array)$query['fields'] : []; + $conds = isset( $query['conds'] ) ? (array)$query['conds'] : []; + $options = isset( $query['options'] ) ? (array)$query['options'] : []; + $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : []; if ( count( $order ) ) { $options['ORDER BY'] = $order; @@ -454,7 +454,7 @@ abstract class QueryPage extends SpecialPage { */ public function fetchFromCache( $limit, $offset = false ) { $dbr = wfGetDB( DB_SLAVE ); - $options = array(); + $options = []; if ( $limit !== false ) { $options['LIMIT'] = intval( $limit ); } @@ -466,11 +466,11 @@ abstract class QueryPage extends SpecialPage { } else { $options['ORDER BY'] = 'qc_value ASC'; } - return $dbr->select( 'querycache', array( 'qc_type', + return $dbr->select( 'querycache', [ 'qc_type', 'namespace' => 'qc_namespace', 'title' => 'qc_title', - 'value' => 'qc_value' ), - array( 'qc_type' => $this->getName() ), + 'value' => 'qc_value' ], + [ 'qc_type' => $this->getName() ], __METHOD__, $options ); } @@ -480,7 +480,7 @@ abstract class QueryPage extends SpecialPage { $dbr = wfGetDB( DB_SLAVE ); $fname = get_class( $this ) . '::getCachedTimestamp'; $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp', - array( 'qci_type' => $this->getName() ), $fname ); + [ 'qci_type' => $this->getName() ], $fname ); } return $this->cachedTimestamp; } @@ -505,7 +505,7 @@ abstract class QueryPage extends SpecialPage { // Can't let $offset + $limit > $maxResults $limit = min( $limit, $maxResults - $offset ); } - return array( $limit, $offset ); + return [ $limit, $offset ]; } /** @@ -593,7 +593,7 @@ abstract class QueryPage extends SpecialPage { $dbr = $this->getRecacheDB(); $this->preprocessResults( $dbr, $res ); - $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) ); + $out->addHTML( Xml::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) ); # Top header and navigation if ( $this->shownavigation ) { @@ -650,7 +650,7 @@ abstract class QueryPage extends SpecialPage { global $wgContLang; if ( $num > 0 ) { - $html = array(); + $html = []; if ( !$this->listoutput ) { $html[] = $this->openList( $offset ); } diff --git a/includes/specialpage/RedirectSpecialPage.php b/includes/specialpage/RedirectSpecialPage.php index 5047354e1a..ea7d783148 100644 --- a/includes/specialpage/RedirectSpecialPage.php +++ b/includes/specialpage/RedirectSpecialPage.php @@ -28,10 +28,10 @@ */ abstract class RedirectSpecialPage extends UnlistedSpecialPage { // Query parameters that can be passed through redirects - protected $mAllowedRedirectParams = array(); + protected $mAllowedRedirectParams = []; // Query parameters added by redirects - protected $mAddedRedirectParams = array(); + protected $mAddedRedirectParams = []; /** * @param string|null $subpage @@ -73,11 +73,11 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage { * @return array|bool */ public function getRedirectQuery() { - $params = array(); + $params = []; $request = $this->getRequest(); foreach ( array_merge( $this->mAllowedRedirectParams, - array( 'uselang', 'useskin', 'debug' ) // parameters which can be passed to all pages + [ 'uselang', 'useskin', 'debug' ] // parameters which can be passed to all pages ) as $arg ) { if ( $request->getVal( $arg, null ) !== null ) { $params[$arg] = $request->getVal( $arg ); @@ -120,7 +120,7 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage { function __construct( $name, $redirName, $redirSubpage = false, - $allowedRedirectParams = array(), $addedRedirectParams = array() + $allowedRedirectParams = [], $addedRedirectParams = [] ) { parent::__construct( $name ); $this->redirName = $redirName; @@ -208,7 +208,7 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage { abstract class RedirectSpecialArticle extends RedirectSpecialPage { function __construct( $name ) { parent::__construct( $name ); - $redirectParams = array( + $redirectParams = [ 'action', 'redirect', 'rdfrom', # Options for preloaded edits @@ -222,9 +222,9 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage { 'redlink', # Options for action=raw; missing ctype can break JS or CSS in some browsers 'ctype', 'maxage', 'smaxage', - ); + ]; - Hooks::run( "RedirectSpecialArticleRedirectParams", array( &$redirectParams ) ); + Hooks::run( "RedirectSpecialArticleRedirectParams", [ &$redirectParams ] ); $this->mAllowedRedirectParams = $redirectParams; } } diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 6158df27a2..6a04c6a754 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -310,7 +310,7 @@ class SpecialPage { public function prefixSearchSubpages( $search, $limit, $offset ) { $subpages = $this->getSubpagesForPrefixSearch(); if ( !$subpages ) { - return array(); + return []; } return self::prefixSearchArray( $search, $limit, $subpages, $offset ); @@ -325,7 +325,7 @@ class SpecialPage { * @return string[] subpages to search from */ protected function getSubpagesForPrefixSearch() { - return array(); + return []; } /** @@ -339,12 +339,12 @@ class SpecialPage { $title = Title::newFromText( $search ); if ( !$title || !$title->canExist() ) { // No prefix suggestion in special and media namespace - return array(); + return []; } $search = SearchEngine::create(); $search->setLimitOffset( $limit, $offset ); - $search->setNamespaces( array() ); + $search->setNamespaces( [] ); $result = $search->defaultPrefixSearch( $search ); return array_map( function( Title $t ) { return $t->getPrefixedText(); @@ -377,11 +377,11 @@ class SpecialPage { $out->setRobotPolicy( $this->getRobotPolicy() ); $out->setPageTitle( $this->getDescription() ); if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) { - $out->addModuleStyles( array( + $out->addModuleStyles( [ 'mediawiki.ui.input', 'mediawiki.ui.radio', 'mediawiki.ui.checkbox', - ) ); + ] ); } } @@ -401,7 +401,7 @@ class SpecialPage { * @param SpecialPage $this * @param string|null $subPage */ - Hooks::run( 'SpecialPageBeforeExecute', array( $this, $subPage ) ); + Hooks::run( 'SpecialPageBeforeExecute', [ $this, $subPage ] ); $this->beforeExecute( $subPage ); $this->execute( $subPage ); @@ -415,7 +415,7 @@ class SpecialPage { * @param SpecialPage $this * @param string|null $subPage */ - Hooks::run( 'SpecialPageAfterExecute', array( $this, $subPage ) ); + Hooks::run( 'SpecialPageAfterExecute', [ $this, $subPage ] ); } /** @@ -626,7 +626,7 @@ class SpecialPage { */ public function msg( /* $args */ ) { $message = call_user_func_array( - array( $this->getContext(), 'msg' ), + [ $this->getContext(), 'msg' ], func_get_args() ); // RequestContext passes context to wfMessage, and the language is set from @@ -649,7 +649,7 @@ class SpecialPage { $feedTemplate = wfScript( 'api' ); foreach ( $this->getConfig()->get( 'FeedClasses' ) as $format => $class ) { - $theseParams = $params + array( 'feedformat' => $format ); + $theseParams = $params + [ 'feedformat' => $format ]; $url = wfAppendQuery( $feedTemplate, $theseParams ); $this->getOutput()->addFeedLink( $format, $url ); } diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 030e7e59a4..bc2bb31a6f 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -47,7 +47,7 @@ class SpecialPageFactory { /** * List of special page names to the subclass of SpecialPage which handles them. */ - private static $coreList = array( + private static $coreList = [ // Maintenance Reports 'BrokenRedirects' => 'BrokenRedirectsPage', 'Deadendpages' => 'DeadendPagesPage', @@ -178,7 +178,7 @@ class SpecialPageFactory { 'RunJobs' => 'SpecialRunJobs', 'Specialpages' => 'SpecialSpecialpages', 'Userlogout' => 'SpecialUserlogout', - ); + ]; private static $list; private static $aliases; @@ -259,7 +259,7 @@ class SpecialPageFactory { // This hook can be used to disable unwanted core special pages // or conditionally register special pages. - Hooks::run( 'SpecialPage_initList', array( &self::$list ) ); + Hooks::run( 'SpecialPage_initList', [ &self::$list ] ); } @@ -278,8 +278,8 @@ class SpecialPageFactory { $aliases = $wgContLang->getSpecialPageAliases(); $pageList = self::getPageList(); - self::$aliases = array(); - $keepAlias = array(); + self::$aliases = []; + $keepAlias = []; // Force every canonical name to be an alias for itself. foreach ( $pageList as $name => $stuff ) { @@ -339,7 +339,7 @@ class SpecialPageFactory { if ( isset( $aliases[$caseFoldedAlias] ) ) { $name = $aliases[$caseFoldedAlias]; } else { - return array( null, null ); + return [ null, null ]; } if ( !isset( $bits[1] ) ) { // bug 2087 @@ -348,7 +348,7 @@ class SpecialPageFactory { $par = $bits[1]; } - return array( $name, $par ); + return [ $name, $par ]; } /** @@ -389,11 +389,11 @@ class SpecialPageFactory { // @deprecated, officially since 1.18, unofficially since forever wfDeprecated( "Array syntax for \$wgSpecialPages is deprecated ($className), " . "define a subclass of SpecialPage instead.", '1.18' ); - $page = ObjectFactory::getObjectFromSpec( array( + $page = ObjectFactory::getObjectFromSpec( [ 'class' => $className, 'args' => $rec, 'closure_expansion' => false, - ) ); + ] ); } elseif ( $rec instanceof SpecialPage ) { $page = $rec; // XXX: we should deep clone here } else { @@ -423,7 +423,7 @@ class SpecialPageFactory { * @return array ( string => Specialpage ) */ public static function getUsablePages( User $user = null ) { - $pages = array(); + $pages = []; if ( $user === null ) { global $wgUser; $user = $wgUser; @@ -449,7 +449,7 @@ class SpecialPageFactory { * @return array ( string => Specialpage ) */ public static function getRegularPages() { - $pages = array(); + $pages = []; foreach ( self::getPageList() as $name => $rec ) { $page = self::getPage( $name ); if ( $page->isListed() && !$page->isRestricted() ) { @@ -468,7 +468,7 @@ class SpecialPageFactory { * @return array ( string => Specialpage ) */ public static function getRestrictedPages( User $user = null ) { - $pages = array(); + $pages = []; if ( $user === null ) { global $wgUser; $user = $wgUser; diff --git a/includes/specialpage/WantedQueryPage.php b/includes/specialpage/WantedQueryPage.php index c4140de1d8..1c19f3c756 100644 --- a/includes/specialpage/WantedQueryPage.php +++ b/includes/specialpage/WantedQueryPage.php @@ -85,9 +85,9 @@ abstract class WantedQueryPage extends QueryPage { $pageLink = Linker::link( $title, null, - array(), - array(), - array( 'broken' ) + [], + [], + [ 'broken' ] ); } return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) ); diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index cbe61bcfd6..c06db01cbe 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -39,12 +39,12 @@ class ActiveUsersPager extends UsersPager { /** * @var array */ - protected $hideGroups = array(); + protected $hideGroups = []; /** * @var array */ - protected $hideRights = array(); + protected $hideRights = []; /** * @var array @@ -97,7 +97,7 @@ class ActiveUsersPager extends UsersPager { $activeUserSeconds = $this->getConfig()->get( 'ActiveUserDays' ) * 86400; $timestamp = $dbr->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds ); - $conds = array( + $conds = [ 'qcc_type' => 'activeusers', 'qcc_namespace' => NS_USER, 'user_name = qcc_title', @@ -105,34 +105,34 @@ class ActiveUsersPager extends UsersPager { 'rc_type != ' . $dbr->addQuotes( RC_EXTERNAL ), // Don't count wikidata. 'rc_log_type IS NULL OR rc_log_type != ' . $dbr->addQuotes( 'newusers' ), 'rc_timestamp >= ' . $dbr->addQuotes( $timestamp ), - ); + ]; if ( $this->requestedUser != '' ) { $conds[] = 'qcc_title >= ' . $dbr->addQuotes( $this->requestedUser ); } if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { $conds[] = 'NOT EXISTS (' . $dbr->selectSQLText( - 'ipblocks', '1', array( 'ipb_user=user_id', 'ipb_deleted' => 1 ) + 'ipblocks', '1', [ 'ipb_user=user_id', 'ipb_deleted' => 1 ] ) . ')'; } if ( $dbr->implicitGroupby() ) { - $options = array( 'GROUP BY' => array( 'qcc_title' ) ); + $options = [ 'GROUP BY' => [ 'qcc_title' ] ]; } else { - $options = array( 'GROUP BY' => array( 'user_name', 'user_id', 'qcc_title' ) ); + $options = [ 'GROUP BY' => [ 'user_name', 'user_id', 'qcc_title' ] ]; } - return array( - 'tables' => array( 'querycachetwo', 'user', 'recentchanges' ), - 'fields' => array( 'user_name', 'user_id', 'recentedits' => 'COUNT(*)', 'qcc_title' ), + return [ + 'tables' => [ 'querycachetwo', 'user', 'recentchanges' ], + 'fields' => [ 'user_name', 'user_id', 'recentedits' => 'COUNT(*)', 'qcc_title' ], 'options' => $options, 'conds' => $conds - ); + ]; } function doBatchLookups() { parent::doBatchLookups(); - $uids = array(); + $uids = []; foreach ( $this->mResult as $row ) { $uids[] = $row->user_id; } @@ -142,12 +142,12 @@ class ActiveUsersPager extends UsersPager { // is done in two queries to avoid huge quicksorts and to make COUNT(*) correct. $dbr = $this->getDatabase(); $res = $dbr->select( 'ipblocks', - array( 'ipb_user', 'MAX(ipb_deleted) AS block_status' ), - array( 'ipb_user' => $uids ), + [ 'ipb_user', 'MAX(ipb_deleted) AS block_status' ], + [ 'ipb_user' => $uids ], __METHOD__, - array( 'GROUP BY' => array( 'ipb_user' ) ) + [ 'GROUP BY' => [ 'ipb_user' ] ] ); - $this->blockStatusByUid = array(); + $this->blockStatusByUid = []; foreach ( $res as $row ) { $this->blockStatusByUid[$row->ipb_user] = $row->block_status; // 0 or 1 } @@ -162,7 +162,7 @@ class ActiveUsersPager extends UsersPager { $lang = $this->getLanguage(); - $list = array(); + $list = []; $user = User::newFromId( $row->user_id ); // User right filter @@ -200,7 +200,7 @@ class ActiveUsersPager extends UsersPager { ->params( $userName )->numParams( $this->RCMaxAge )->escaped(); $blocked = $isBlocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : ''; - return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" ); + return Html::rawElement( 'li', [], "{$item} [{$count}]{$blocked}" ); } function getPageHeader() { @@ -208,7 +208,7 @@ class ActiveUsersPager extends UsersPager { $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : ''; # Form tag - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ); + $out = Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ); $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n"; $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n"; @@ -220,28 +220,28 @@ class ActiveUsersPager extends UsersPager { 'offset', 20, $this->requestedUser, - array( + [ 'class' => 'mw-ui-input-inline mw-autocomplete-user', 'tabindex' => 1, 'autofocus' => $this->requestedUser === '', - ) + ] ) . '
    '; $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(), - 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ), array( 'tabindex' => 2 ) ); + 'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ), [ 'tabindex' => 2 ] ); $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(), 'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ), - array( 'tabindex' => 3 ) + [ 'tabindex' => 3 ] ) . '
    '; # Submit button and form bottom $out .= Xml::submitButton( $this->msg( 'activeusers-submit' )->text(), - array( 'tabindex' => 4 ) + [ 'tabindex' => 4 ] ) . "\n"; $out .= Xml::closeElement( 'fieldset' ); $out .= Xml::closeElement( 'form' ); @@ -275,7 +275,7 @@ class SpecialActiveUsers extends SpecialPage { $out = $this->getOutput(); $out->wrapWikiMsg( "
    \n$1\n
    ", - array( 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ) ); + [ 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ] ); // Mention the level of cache staleness... $dbr = wfGetDB( DB_SLAVE, 'recentchanges' ); @@ -283,7 +283,7 @@ class SpecialActiveUsers extends SpecialPage { if ( $rcMax ) { $cTime = $dbr->selectField( 'querycache_info', 'qci_timestamp', - array( 'qci_type' => 'activeusers' ), + [ 'qci_type' => 'activeusers' ], __METHOD__ ); if ( $cTime ) { @@ -307,7 +307,7 @@ class SpecialActiveUsers extends SpecialPage { if ( $usersbody ) { $out->addHTML( $up->getNavigationBar() . - Html::rawElement( 'ul', array(), $usersbody ) . + Html::rawElement( 'ul', [], $usersbody ) . $up->getNavigationBar() ); } else { diff --git a/includes/specials/SpecialAllMessages.php b/includes/specials/SpecialAllMessages.php index 5b74c8b694..49d5d6e596 100644 --- a/includes/specials/SpecialAllMessages.php +++ b/includes/specials/SpecialAllMessages.php @@ -63,7 +63,7 @@ class SpecialAllMessages extends SpecialPage { $this->table = new AllMessagesTablePager( $this, - array(), + [], wfGetLangObj( $request->getVal( 'lang', $par ) ) ); @@ -104,7 +104,7 @@ class AllMessagesTablePager extends TablePager { $this->mConds = $conds; // FIXME: Why does this need to be set to DIR_DESCENDING to produce ascending ordering? $this->mDefaultDirection = IndexPager::DIR_DESCENDING; - $this->mLimitsShown = array( 20, 50, 100, 250, 500, 5000 ); + $this->mLimitsShown = [ 20, 50, 100, 250, 500, 5000 ]; global $wgContLang; @@ -146,18 +146,18 @@ class AllMessagesTablePager extends TablePager { } function buildForm() { - $attrs = array( 'id' => 'mw-allmessages-form-lang', 'name' => 'lang' ); + $attrs = [ 'id' => 'mw-allmessages-form-lang', 'name' => 'lang' ]; $msg = wfMessage( 'allmessages-language' ); $langSelect = Xml::languageSelector( $this->langcode, false, null, $attrs, $msg ); - $out = Xml::openElement( 'form', array( + $out = Xml::openElement( 'form', [ 'method' => 'get', 'action' => $this->getConfig()->get( 'Script' ), 'id' => 'mw-allmessages-form' - ) ) . + ] ) . Xml::fieldset( $this->msg( 'allmessages-filter-legend' )->text() ) . Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . - Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" . + Xml::openElement( 'table', [ 'class' => 'mw-allmessages-table' ] ) . "\n" . ' ' . Xml::label( $this->msg( 'allmessages-prefix' )->text(), 'mw-allmessages-form-prefix' ) . @@ -167,7 +167,7 @@ class AllMessagesTablePager extends TablePager { 'prefix', 20, str_replace( '_', ' ', $this->displayPrefix ), - array( 'id' => 'mw-allmessages-form-prefix' ) + [ 'id' => 'mw-allmessages-form-prefix' ] ) . "\n @@ -206,7 +206,7 @@ class AllMessagesTablePager extends TablePager { Xml::label( $this->msg( 'table_pager_limit_label' )->text(), 'mw-table_pager_limit_label' ) . ' ' . - $this->getLimitSelect( array( 'id' => 'mw-table_pager_limit_label' ) ) . + $this->getLimitSelect( [ 'id' => 'mw-table_pager_limit_label' ] ) . ' @@ -216,7 +216,7 @@ class AllMessagesTablePager extends TablePager { " . Xml::closeElement( 'table' ) . - $this->getHiddenFields( array( 'title', 'prefix', 'filter', 'lang', 'limit' ) ) . + $this->getHiddenFields( [ 'title', 'prefix', 'filter', 'lang', 'limit' ] ) . Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ); @@ -227,7 +227,7 @@ class AllMessagesTablePager extends TablePager { $messageNames = Language::getLocalisationCache()->getSubitemList( 'en', 'messages' ); // Normalise message names so they look like page titles and sort correctly - T86139 - $messageNames = array_map( array( $this->lang, 'ucfirst' ), $messageNames ); + $messageNames = array_map( [ $this->lang, 'ucfirst' ], $messageNames ); if ( $descending ) { rsort( $messageNames ); @@ -254,14 +254,14 @@ class AllMessagesTablePager extends TablePager { $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'page', - array( 'page_namespace', 'page_title' ), - array( 'page_namespace' => array( NS_MEDIAWIKI, NS_MEDIAWIKI_TALK ) ), + [ 'page_namespace', 'page_title' ], + [ 'page_namespace' => [ NS_MEDIAWIKI, NS_MEDIAWIKI_TALK ] ], __METHOD__, - array( 'USE INDEX' => 'name_title' ) + [ 'USE INDEX' => 'name_title' ] ); $xNames = array_flip( $messageNames ); - $pageFlags = $talkFlags = array(); + $pageFlags = $talkFlags = []; foreach ( $res as $s ) { $exists = false; @@ -286,7 +286,7 @@ class AllMessagesTablePager extends TablePager { } } - return array( 'pages' => $pageFlags, 'talks' => $talkFlags ); + return [ 'pages' => $pageFlags, 'talks' => $talkFlags ]; } /** @@ -298,7 +298,7 @@ class AllMessagesTablePager extends TablePager { * @return FakeResultWrapper */ function reallyDoQuery( $offset, $limit, $descending ) { - $result = new FakeResultWrapper( array() ); + $result = new FakeResultWrapper( [] ); $messageNames = $this->getAllMessages( $descending ); $statuses = self::getCustomisedStatuses( $messageNames, $this->langcode, $this->foreign ); @@ -312,13 +312,13 @@ class AllMessagesTablePager extends TablePager { ) { $actual = wfMessage( $key )->inLanguage( $this->langcode )->plain(); $default = wfMessage( $key )->inLanguage( $this->langcode )->useDatabase( false )->plain(); - $result->result[] = array( + $result->result[] = [ 'am_title' => $key, 'am_actual' => $actual, 'am_default' => $default, 'am_customised' => $customised, 'am_talk_exists' => isset( $statuses['talks'][$key] ) - ); + ]; $count++; } @@ -332,10 +332,10 @@ class AllMessagesTablePager extends TablePager { function getStartBody() { $tableClass = $this->getTableClass(); - return Xml::openElement( 'table', array( + return Xml::openElement( 'table', [ 'class' => "mw-datatable $tableClass", 'id' => 'mw-allmessagestable' - ) ) . + ] ) . "\n" . " " . @@ -358,14 +358,14 @@ class AllMessagesTablePager extends TablePager { $title = Title::makeTitle( NS_MEDIAWIKI, $value . $this->suffix ); $talk = Title::makeTitle( NS_MEDIAWIKI_TALK, $value . $this->suffix ); $translation = Linker::makeExternalLink( - 'https://translatewiki.net/w/i.php?' . wfArrayToCgi( array( + 'https://translatewiki.net/w/i.php?' . wfArrayToCgi( [ 'title' => 'Special:SearchTranslations', 'group' => 'mediawiki', 'grouppath' => 'mediawiki', 'query' => 'language:' . $this->getLanguage()->getCode() . '^25 ' . 'messageid:"MediaWiki:' . $value . '"^10 "' . $this->msg( $value )->inLanguage( 'en' )->plain() . '"' - ) ), + ] ), $this->msg( 'allmessages-filter-translate' )->text() ); @@ -375,9 +375,9 @@ class AllMessagesTablePager extends TablePager { $title = Linker::link( $title, $this->getLanguage()->lcfirst( $value ), - array(), - array(), - array( 'broken' ) + [], + [], + [ 'broken' ] ); } if ( $this->mCurrentRow->am_talk_exists ) { @@ -386,9 +386,9 @@ class AllMessagesTablePager extends TablePager { $talk = Linker::link( $talk, $this->talk, - array(), - array(), - array( 'broken' ) + [], + [], + [ 'broken' ] ); } @@ -426,7 +426,7 @@ class AllMessagesTablePager extends TablePager { } function getRowAttrs( $row, $isSecond = false ) { - $arr = array(); + $arr = []; if ( $row->am_customised ) { $arr['class'] = 'allmessages-customised'; @@ -441,24 +441,24 @@ class AllMessagesTablePager extends TablePager { function getCellAttrs( $field, $value ) { if ( $this->mCurrentRow->am_customised && $field === 'am_title' ) { - return array( 'rowspan' => '2', 'class' => $field ); + return [ 'rowspan' => '2', 'class' => $field ]; } elseif ( $field === 'am_title' ) { - return array( 'class' => $field ); + return [ 'class' => $field ]; } else { - return array( + return [ 'lang' => $this->lang->getHtmlCode(), 'dir' => $this->lang->getDir(), 'class' => $field - ); + ]; } } // This is not actually used, as getStartBody is overridden above function getFieldNames() { - return array( + return [ 'am_title' => $this->msg( 'allmessagesname' )->text(), 'am_default' => $this->msg( 'allmessagesdefault' )->text() - ); + ]; } function getTitle() { diff --git a/includes/specials/SpecialAllPages.php b/includes/specials/SpecialAllPages.php index 0bf93be794..b55f0b4923 100644 --- a/includes/specials/SpecialAllPages.php +++ b/includes/specials/SpecialAllPages.php @@ -100,39 +100,39 @@ class SpecialAllPages extends IncludableSpecialPage { protected function outputHTMLForm( $namespace = NS_MAIN, $from = '', $to = '', $hideRedirects = false ) { - $fields = array( - 'from' => array( + $fields = [ + 'from' => [ 'type' => 'text', 'name' => 'from', 'id' => 'nsfrom', 'size' => 30, 'label-message' => 'allpagesfrom', 'default' => str_replace( '_', ' ', $from ), - ), - 'to' => array( + ], + 'to' => [ 'type' => 'text', 'name' => 'to', 'id' => 'nsto', 'size' => 30, 'label-message' => 'allpagesto', 'default' => str_replace( '_', ' ', $to ), - ), - 'namespace' => array( + ], + 'namespace' => [ 'type' => 'namespaceselect', 'name' => 'namespace', 'id' => 'namespace', 'label-message' => 'namespace', 'all' => null, 'value' => $namespace, - ), - 'hideredirects' => array( + ], + 'hideredirects' => [ 'type' => 'check', 'name' => 'hideredirects', 'id' => 'hidredirects', 'label-message' => 'allpages-hide-redirects', 'value' => $hideRedirects, - ), - ); + ], + ]; $form = HTMLForm::factory( 'table', $fields, $this->getContext() ); $form->setMethod( 'get' ) ->setWrapperLegendMsg( 'allpages' ) @@ -182,7 +182,7 @@ class SpecialAllPages extends IncludableSpecialPage { list( , $toKey, $to ) = $toList; $dbr = wfGetDB( DB_SLAVE ); - $filterConds = array( 'page_namespace' => $namespace ); + $filterConds = [ 'page_namespace' => $namespace ]; if ( $hideredirects ) { $filterConds['page_is_redirect'] = 0; } @@ -194,18 +194,18 @@ class SpecialAllPages extends IncludableSpecialPage { } $res = $dbr->select( 'page', - array( 'page_namespace', 'page_title', 'page_is_redirect', 'page_id' ), + [ 'page_namespace', 'page_title', 'page_is_redirect', 'page_id' ], $conds, __METHOD__, - array( + [ 'ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title', - ) + ] ); if ( $res->numRows() > 0 ) { - $out = Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) ); + $out = Html::openElement( 'ul', [ 'class' => 'mw-allpages-chunk' ] ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $t = Title::newFromRow( $s ); @@ -225,7 +225,7 @@ class SpecialAllPages extends IncludableSpecialPage { if ( $res->numRows() > 2 ) { // Only apply CSS column styles if there's more than 2 entries. // Otherwise, rendering is broken as "mw-allpages-body"'s CSS column count is 3. - $out = Html::rawElement( 'div', array( 'class' => 'mw-allpages-body' ), $out ); + $out = Html::rawElement( 'div', [ 'class' => 'mw-allpages-body' ], $out ); } } else { $out = ''; @@ -240,7 +240,7 @@ class SpecialAllPages extends IncludableSpecialPage { 'page_title', $prevConds, __METHOD__, - array( 'ORDER BY' => 'page_title DESC', 'OFFSET' => $this->maxPerPage - 1 ) + [ 'ORDER BY' => 'page_title DESC', 'OFFSET' => $this->maxPerPage - 1 ] ); if ( $prevKey === false ) { @@ -251,7 +251,7 @@ class SpecialAllPages extends IncludableSpecialPage { 'page_title', $prevConds, __METHOD__, - array( 'ORDER BY' => 'page_title' ) + [ 'ORDER BY' => 'page_title' ] ); } @@ -266,12 +266,12 @@ class SpecialAllPages extends IncludableSpecialPage { return; } - $navLinks = array(); + $navLinks = []; $self = $this->getPageTitle(); // Generate a "previous page" link if needed if ( $prevTitle ) { - $query = array( 'from' => $prevTitle->getText() ); + $query = [ 'from' => $prevTitle->getText() ]; if ( $namespace ) { $query['namespace'] = $namespace; @@ -284,7 +284,7 @@ class SpecialAllPages extends IncludableSpecialPage { $navLinks[] = Linker::linkKnown( $self, $this->msg( 'prevpage', $prevTitle->getText() )->escaped(), - array(), + [], $query ); @@ -294,7 +294,7 @@ class SpecialAllPages extends IncludableSpecialPage { if ( $n == $this->maxPerPage && $s = $res->fetchObject() ) { # $s is the first link of the next chunk $t = Title::makeTitle( $namespace, $s->page_title ); - $query = array( 'from' => $t->getText() ); + $query = [ 'from' => $t->getText() ]; if ( $namespace ) { $query['namespace'] = $namespace; @@ -307,7 +307,7 @@ class SpecialAllPages extends IncludableSpecialPage { $navLinks[] = Linker::linkKnown( $self, $this->msg( 'nextpage', $t->getText() )->escaped(), - array(), + [], $query ); } @@ -317,7 +317,7 @@ class SpecialAllPages extends IncludableSpecialPage { if ( count( $navLinks ) ) { // Add pagination links $pagination = Html::rawElement( 'div', - array( 'class' => 'mw-allpages-nav' ), + [ 'class' => 'mw-allpages-nav' ], $this->getLanguage()->pipeList( $navLinks ) ); @@ -336,12 +336,12 @@ class SpecialAllPages extends IncludableSpecialPage { protected function getNamespaceKeyAndText( $ns, $text ) { if ( $text == '' ) { # shortcut for common case - return array( $ns, '', '' ); + return [ $ns, '', '' ]; } $t = Title::makeTitleSafe( $ns, $text ); if ( $t && $t->isLocal() ) { - return array( $t->getNamespace(), $t->getDBkey(), $t->getText() ); + return [ $t->getNamespace(), $t->getDBkey(), $t->getText() ]; } elseif ( $t ) { return null; } @@ -350,7 +350,7 @@ class SpecialAllPages extends IncludableSpecialPage { $text = preg_replace( '/(#|$)/', 'X$1', $text ); $t = Title::makeTitleSafe( $ns, $text ); if ( $t && $t->isLocal() ) { - return array( $t->getNamespace(), '', '' ); + return [ $t->getNamespace(), '', '' ]; } else { return null; } diff --git a/includes/specials/SpecialAncientpages.php b/includes/specials/SpecialAncientpages.php index 2da24a8ed6..724435b04f 100644 --- a/includes/specials/SpecialAncientpages.php +++ b/includes/specials/SpecialAncientpages.php @@ -41,19 +41,19 @@ class AncientPagesPage extends QueryPage { } public function getQueryInfo() { - return array( - 'tables' => array( 'page', 'revision' ), - 'fields' => array( + return [ + 'tables' => [ 'page', 'revision' ], + 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'rev_timestamp' - ), - 'conds' => array( + ], + 'conds' => [ 'page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0, 'page_latest=rev_id' - ) - ); + ] + ]; } public function usesTimestamps() { diff --git a/includes/specials/SpecialApiHelp.php b/includes/specials/SpecialApiHelp.php index b43911f56d..74b474ace4 100644 --- a/includes/specials/SpecialApiHelp.php +++ b/includes/specials/SpecialApiHelp.php @@ -39,13 +39,13 @@ class SpecialApiHelp extends UnlistedSpecialPage { // These come from transclusions $request = $this->getRequest(); - $options = array( + $options = [ 'action' => 'help', 'nolead' => true, 'submodules' => $request->getCheck( 'submodules' ), 'recursivesubmodules' => $request->getCheck( 'recursivesubmodules' ), 'title' => $request->getVal( 'title', $this->getPageTitle( '$1' )->getPrefixedText() ), - ); + ]; // These are for linking from wikitext, since url parameters are a pain // to do. @@ -78,7 +78,7 @@ class SpecialApiHelp extends UnlistedSpecialPage { try { $module = $main->getModuleFromPath( $moduleName ); } catch ( UsageException $ex ) { - $this->getOutput()->addHTML( Html::rawElement( 'span', array( 'class' => 'error' ), + $this->getOutput()->addHTML( Html::rawElement( 'span', [ 'class' => 'error' ], $this->msg( 'apihelp-no-such-module', $moduleName )->inContentLanguage()->parse() ) ); return; diff --git a/includes/specials/SpecialApiSandbox.php b/includes/specials/SpecialApiSandbox.php index 42101baa5d..e994347789 100644 --- a/includes/specials/SpecialApiSandbox.php +++ b/includes/specials/SpecialApiSandbox.php @@ -39,13 +39,13 @@ class SpecialApiSandbox extends SpecialPage { } $out->addJsConfigVars( 'apihighlimits', $this->getUser()->isAllowed( 'apihighlimits' ) ); - $out->addModuleStyles( array( + $out->addModuleStyles( [ 'mediawiki.special.apisandbox.styles', - ) ); - $out->addModules( array( + ] ); + $out->addModules( [ 'mediawiki.special.apisandbox', 'mediawiki.apipretty', - ) ); + ] ); $out->wrapWikiMsg( "
    \n$1\n
    ", 'apisandbox-jsonly' diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index d198ea1cd2..993065586d 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -45,7 +45,7 @@ class SpecialBlock extends FormSpecialPage { protected $alreadyBlocked; /** @var array */ - protected $preErrors = array(); + protected $preErrors = []; public function __construct() { parent::__construct( 'Block', 'block' ); @@ -114,7 +114,7 @@ class SpecialBlock extends FormSpecialPage { if ( $s ) { $form->addHeaderText( Html::rawElement( 'div', - array( 'class' => 'error' ), + [ 'class' => 'error' ], $s ) ); } @@ -132,100 +132,100 @@ class SpecialBlock extends FormSpecialPage { $suggestedDurations = self::getSuggestedDurations(); - $a = array( - 'Target' => array( + $a = [ + 'Target' => [ 'type' => 'text', 'label-message' => 'ipaddressorusername', 'id' => 'mw-bi-target', 'size' => '45', 'autofocus' => true, 'required' => true, - 'validation-callback' => array( __CLASS__, 'validateTargetField' ), + 'validation-callback' => [ __CLASS__, 'validateTargetField' ], 'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest - ), - 'Expiry' => array( + ], + 'Expiry' => [ 'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother', 'label-message' => 'ipbexpiry', 'required' => true, 'options' => $suggestedDurations, 'other' => $this->msg( 'ipbother' )->text(), 'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(), - ), - 'Reason' => array( + ], + 'Reason' => [ 'type' => 'selectandother', 'maxlength' => 255, 'label-message' => 'ipbreason', 'options-message' => 'ipbreason-dropdown', - ), - 'CreateAccount' => array( + ], + 'CreateAccount' => [ 'type' => 'check', 'label-message' => 'ipbcreateaccount', 'default' => true, - ), - ); + ], + ]; if ( self::canBlockEmail( $user ) ) { - $a['DisableEmail'] = array( + $a['DisableEmail'] = [ 'type' => 'check', 'label-message' => 'ipbemailban', - ); + ]; } if ( $wgBlockAllowsUTEdit ) { - $a['DisableUTEdit'] = array( + $a['DisableUTEdit'] = [ 'type' => 'check', 'label-message' => 'ipb-disableusertalk', 'default' => false, - ); + ]; } - $a['AutoBlock'] = array( + $a['AutoBlock'] = [ 'type' => 'check', 'label-message' => 'ipbenableautoblock', 'default' => true, - ); + ]; # Allow some users to hide name from block log, blocklist and listusers if ( $user->isAllowed( 'hideuser' ) ) { - $a['HideUser'] = array( + $a['HideUser'] = [ 'type' => 'check', 'label-message' => 'ipbhidename', 'cssclass' => 'mw-block-hideuser', - ); + ]; } # Watchlist their user page? (Only if user is logged in) if ( $user->isLoggedIn() ) { - $a['Watch'] = array( + $a['Watch'] = [ 'type' => 'check', 'label-message' => 'ipbwatchuser', - ); + ]; } - $a['HardBlock'] = array( + $a['HardBlock'] = [ 'type' => 'check', 'label-message' => 'ipb-hardblock', 'default' => false, - ); + ]; # This is basically a copy of the Target field, but the user can't change it, so we # can see if the warnings we maybe showed to the user before still apply - $a['PreviousTarget'] = array( + $a['PreviousTarget'] = [ 'type' => 'hidden', 'default' => false, - ); + ]; # We'll turn this into a checkbox if we need to - $a['Confirm'] = array( + $a['Confirm'] = [ 'type' => 'hidden', 'default' => '', 'label-message' => 'ipb-confirm', - ); + ]; $this->maybeAlterFormDefaults( $a ); // Allow extensions to add more fields - Hooks::run( 'SpecialBlockModifyFormFields', array( $this, &$a ) ); + Hooks::run( 'SpecialBlockModifyFormFields', [ $this, &$a ] ); return $a; } @@ -300,21 +300,21 @@ class SpecialBlock extends FormSpecialPage { } $this->alreadyBlocked = true; - $this->preErrors[] = array( 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ); + $this->preErrors[] = [ 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ]; } # We always need confirmation to do HideUser if ( $this->requestedHideUser ) { $fields['Confirm']['type'] = 'check'; unset( $fields['Confirm']['default'] ); - $this->preErrors[] = array( 'ipb-confirmhideuser', 'ipb-confirmaction' ); + $this->preErrors[] = [ 'ipb-confirmhideuser', 'ipb-confirmaction' ]; } # Or if the user is trying to block themselves if ( (string)$this->target === $this->getUser()->getName() ) { $fields['Confirm']['type'] = 'check'; unset( $fields['Confirm']['default'] ); - $this->preErrors[] = array( 'ipb-blockingself', 'ipb-confirmaction' ); + $this->preErrors[] = [ 'ipb-blockingself', 'ipb-confirmaction' ]; } } @@ -323,32 +323,32 @@ class SpecialBlock extends FormSpecialPage { * @return string */ protected function preText() { - $this->getOutput()->addModules( array( 'mediawiki.special.block', 'mediawiki.userSuggest' ) ); + $this->getOutput()->addModules( [ 'mediawiki.special.block', 'mediawiki.userSuggest' ] ); $blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' ); $text = $this->msg( 'blockiptext', $blockCIDRLimit['IPv4'], $blockCIDRLimit['IPv6'] )->parse(); - $otherBlockMessages = array(); + $otherBlockMessages = []; if ( $this->target !== null ) { # Get other blocks, i.e. from GlobalBlocking or TorBlock extension - Hooks::run( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target ) ); + Hooks::run( 'OtherBlockLogLink', [ &$otherBlockMessages, $this->target ] ); if ( count( $otherBlockMessages ) ) { $s = Html::rawElement( 'h2', - array(), + [], $this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse() ) . "\n"; $list = ''; foreach ( $otherBlockMessages as $link ) { - $list .= Html::rawElement( 'li', array(), $link ) . "\n"; + $list .= Html::rawElement( 'li', [], $link ) . "\n"; } $s .= Html::rawElement( 'ul', - array( 'class' => 'mw-blockip-alreadyblocked' ), + [ 'class' => 'mw-blockip-alreadyblocked' ], $list ) . "\n"; @@ -364,7 +364,7 @@ class SpecialBlock extends FormSpecialPage { * @return string */ protected function postText() { - $links = array(); + $links = []; $this->getOutput()->addModuleStyles( 'mediawiki.special' ); @@ -388,7 +388,7 @@ class SpecialBlock extends FormSpecialPage { $message = $this->msg( 'ipb-unblock' )->parse(); $list = SpecialPage::getTitleFor( 'Unblock' ); } - $links[] = Linker::linkKnown( $list, $message, array() ); + $links[] = Linker::linkKnown( $list, $message, [] ); # Link to the block list $links[] = Linker::linkKnown( @@ -403,14 +403,14 @@ class SpecialBlock extends FormSpecialPage { $links[] = Linker::linkKnown( $this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(), $this->msg( 'ipb-edit-dropdown' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); } $text = Html::rawElement( 'p', - array( 'class' => 'mw-ipb-conveniencelinks' ), + [ 'class' => 'mw-ipb-conveniencelinks' ], $this->getLanguage()->pipeList( $links ) ); @@ -424,11 +424,11 @@ class SpecialBlock extends FormSpecialPage { 'block', $userTitle, '', - array( + [ 'lim' => 10, - 'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ), + 'msgKey' => [ 'blocklog-showlog', $userTitle->getText() ], 'showIfEmpty' => false - ) + ] ); $text .= $out; @@ -439,12 +439,12 @@ class SpecialBlock extends FormSpecialPage { 'suppress', $userTitle, '', - array( + [ 'lim' => 10, - 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ), - 'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ), + 'conds' => [ 'log_action' => [ 'block', 'reblock', 'unblock' ] ], + 'msgKey' => [ 'blocklog-showsuppresslog', $userTitle->getText() ], 'showIfEmpty' => false - ) + ] ); $text .= $out; @@ -514,11 +514,11 @@ class SpecialBlock extends FormSpecialPage { list( $target, $type ) = Block::parseTarget( $target ); if ( $type !== null ) { - return array( $target, $type ); + return [ $target, $type ]; } } - return array( null, null ); + return [ null, null ]; } /** @@ -534,7 +534,7 @@ class SpecialBlock extends FormSpecialPage { if ( !$status->isOK() ) { $errors = $status->getErrorsArray(); - return call_user_func_array( array( $form, 'msg' ), $errors[0] ); + return call_user_func_array( [ $form, 'msg' ], $errors[0] ); } else { return true; } @@ -619,7 +619,7 @@ class SpecialBlock extends FormSpecialPage { # This might have been a hidden field or a checkbox, so interesting data # can come from it - $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', null, false ), true ); + $data['Confirm'] = !in_array( $data['Confirm'], [ '', '0', null, false ], true ); /** @var User $target */ list( $target, $type ) = self::getTargetAndType( $data['Target'] ); @@ -638,7 +638,7 @@ class SpecialBlock extends FormSpecialPage { if ( $target === $performer->getName() && ( $data['PreviousTarget'] !== $target || !$data['Confirm'] ) ) { - return array( 'ipb-blockingself', 'ipb-confirmaction' ); + return [ 'ipb-blockingself', 'ipb-confirmaction' ]; } } elseif ( $type == Block::TYPE_RANGE ) { $userId = 0; @@ -647,7 +647,7 @@ class SpecialBlock extends FormSpecialPage { $userId = 0; } else { # This should have been caught in the form field validation - return array( 'badipaddress' ); + return [ 'badipaddress' ]; } $expiryTime = self::parseExpiryInput( $data['Expiry'] ); @@ -660,13 +660,13 @@ class SpecialBlock extends FormSpecialPage { // check, if the time could be parsed !$expiryTime ) { - return array( 'ipb_expiry_invalid' ); + return [ 'ipb_expiry_invalid' ]; } // an expiry time should be in the future, not in the // past (wouldn't make any sense) - bug T123069 if ( $expiryTime < wfTimestampNow() ) { - return array( 'ipb_expiry_old' ); + return [ 'ipb_expiry_old' ]; } if ( !isset( $data['DisableEmail'] ) ) { @@ -685,7 +685,7 @@ class SpecialBlock extends FormSpecialPage { # or by race conditions (user has hideuser and block rights, loads block form, # and loses hideuser rights before submission); so need to fail completely # rather than just silently disable hiding - return array( 'badaccess-group0' ); + return [ 'badaccess-group0' ]; } # Recheck params here... @@ -693,16 +693,16 @@ class SpecialBlock extends FormSpecialPage { $data['HideUser'] = false; # IP users should not be hidden } elseif ( !wfIsInfinity( $data['Expiry'] ) ) { # Bad expiry. - return array( 'ipb_expiry_temp' ); + return [ 'ipb_expiry_temp' ]; } elseif ( $wgHideUserContribLimit !== false && $user->getEditCount() > $wgHideUserContribLimit ) { # Typically, the user should have a handful of edits. # Disallow hiding users with many edits for performance. - return array( array( 'ipb_hide_invalid', - Message::numParam( $wgHideUserContribLimit ) ) ); + return [ [ 'ipb_hide_invalid', + Message::numParam( $wgHideUserContribLimit ) ] ]; } elseif ( !$data['Confirm'] ) { - return array( 'ipb-confirmhideuser', 'ipb-confirmaction' ); + return [ 'ipb-confirmhideuser', 'ipb-confirmaction' ]; } } @@ -720,8 +720,8 @@ class SpecialBlock extends FormSpecialPage { $block->isAutoblocking( $data['AutoBlock'] ); $block->mHideName = $data['HideUser']; - $reason = array( 'hookaborted' ); - if ( !Hooks::run( 'BlockIp', array( &$block, &$performer, &$reason ) ) ) { + $reason = [ 'hookaborted' ]; + if ( !Hooks::run( 'BlockIp', [ &$block, &$performer, &$reason ] ) ) { return $reason; } @@ -738,7 +738,7 @@ class SpecialBlock extends FormSpecialPage { # Show form unless the user is already aware of this... if ( $blockNotConfirmed || $reblockNotAllowed ) { - return array( array( 'ipb_already_blocked', $block->getTarget() ) ); + return [ [ 'ipb_already_blocked', $block->getTarget() ] ]; # Otherwise, try to update the block... } else { # This returns direct blocks before autoblocks/rangeblocks, since we should @@ -746,13 +746,13 @@ class SpecialBlock extends FormSpecialPage { $currentBlock = Block::newFromTarget( $target ); if ( $block->equals( $currentBlock ) ) { - return array( array( 'ipb_already_blocked', $block->getTarget() ) ); + return [ [ 'ipb_already_blocked', $block->getTarget() ] ]; } # If the name was hidden and the blocking user cannot hide # names, then don't allow any block changes... if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) { - return array( 'cant-see-hidden-user' ); + return [ 'cant-see-hidden-user' ]; } $currentBlock->isHardblock( $block->isHardblock() ); @@ -782,7 +782,7 @@ class SpecialBlock extends FormSpecialPage { $logaction = 'block'; } - Hooks::run( 'BlockIpComplete', array( $block, $performer ) ); + Hooks::run( 'BlockIpComplete', [ $block, $performer ] ); # Set *_deleted fields if requested if ( $data['HideUser'] ) { @@ -803,7 +803,7 @@ class SpecialBlock extends FormSpecialPage { $data['AutoBlock'] = $block->isAutoblocking(); # Prepare log parameters - $logParams = array(); + $logParams = []; $logParams['5::duration'] = $data['Expiry']; $logParams['6::flags'] = self::blockLogFlags( $data, $type ); @@ -815,8 +815,8 @@ class SpecialBlock extends FormSpecialPage { $logEntry->setPerformer( $performer ); $logEntry->setParameters( $logParams ); # Relate log ID to block IDs (bug 25763) - $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] ); - $logEntry->setRelations( array( 'ipb_id' => $blockIds ) ); + $blockIds = array_merge( [ $status['id'] ], $status['autoIds'] ); + $logEntry->setRelations( [ 'ipb_id' => $blockIds ] ); $logId = $logEntry->insert(); $logEntry->publish( $logId ); @@ -833,13 +833,13 @@ class SpecialBlock extends FormSpecialPage { * @return array */ public static function getSuggestedDurations( $lang = null ) { - $a = array(); + $a = []; $msg = $lang === null ? wfMessage( 'ipboptions' )->inContentLanguage()->text() : wfMessage( 'ipboptions' )->inLanguage( $lang )->text(); if ( $msg == '-' ) { - return array(); + return []; } foreach ( explode( ',', $msg ) as $option ) { @@ -931,7 +931,7 @@ class SpecialBlock extends FormSpecialPage { */ protected static function blockLogFlags( array $data, $type ) { global $wgBlockAllowsUTEdit; - $flags = array(); + $flags = []; # when blocking a user the option 'anononly' is not available/has no effect # -> do not write this into log @@ -1001,7 +1001,7 @@ class SpecialBlock extends FormSpecialPage { $user = User::newFromName( $search ); if ( !$user ) { // No prefix suggestion for invalid user - return array(); + return []; } // Autocomplete subpage as user list - public to allow caching return UserNamePrefixSearch::search( 'public', $search, $limit, $offset ); diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index 73a2774d73..e589ecb00a 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -46,13 +46,13 @@ class SpecialBlockList extends SpecialPage { $out = $this->getOutput(); $lang = $this->getLanguage(); $out->setPageTitle( $this->msg( 'ipblocklist' ) ); - $out->addModuleStyles( array( 'mediawiki.special', 'mediawiki.special.blocklist' ) ); + $out->addModuleStyles( [ 'mediawiki.special', 'mediawiki.special.blocklist' ] ); $request = $this->getRequest(); $par = $request->getVal( 'ip', $par ); $this->target = trim( $request->getVal( 'wpTarget', $par ) ); - $this->options = $request->getArray( 'wpOptions', array() ); + $this->options = $request->getArray( 'wpOptions', [] ); $action = $request->getText( 'action' ); @@ -68,38 +68,38 @@ class SpecialBlockList extends SpecialPage { $pager = $this->getBlockListPager(); # Just show the block list - $fields = array( - 'Target' => array( + $fields = [ + 'Target' => [ 'type' => 'user', 'label-message' => 'ipaddressorusername', 'tabindex' => '1', 'size' => '45', 'default' => $this->target, - ), - 'Options' => array( + ], + 'Options' => [ 'type' => 'multiselect', - 'options-messages' => array( + 'options-messages' => [ 'blocklist-userblocks' => 'userblocks', 'blocklist-tempblocks' => 'tempblocks', 'blocklist-addressblocks' => 'addressblocks', 'blocklist-rangeblocks' => 'rangeblocks', - ), + ], 'flatlist' => true, - ), - 'Limit' => array( + ], + 'Limit' => [ 'type' => 'limitselect', 'label-message' => 'table_pager_limit_label', - 'options' => array( + 'options' => [ $lang->formatNum( 20 ) => 20, $lang->formatNum( 50 ) => 50, $lang->formatNum( 100 ) => 100, $lang->formatNum( 250 ) => 250, $lang->formatNum( 500 ) => 500, - ), + ], 'name' => 'limit', 'default' => $pager->getLimit(), - ), - ); + ], + ]; $context = new DerivativeContext( $this->getContext() ); $context->setTitle( $this->getPageTitle() ); // Remove subpage $form = HTMLForm::factory( 'ooui', $fields, $context ); @@ -118,7 +118,7 @@ class SpecialBlockList extends SpecialPage { * @return BlockListPager */ protected function getBlockListPager() { - $conds = array(); + $conds = []; # Is the user allowed to see hidden blocks? if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { $conds['ipb_deleted'] = 0; @@ -138,10 +138,10 @@ class SpecialBlockList extends SpecialPage { list( $start, $end ) = IP::parseRange( $target ); $dbr = wfGetDB( DB_SLAVE ); $conds[] = $dbr->makeList( - array( + [ 'ipb_address' => $target, Block::getRangeCond( $start, $end ) - ), + ], LIST_OR ); $conds['ipb_auto'] = 0; @@ -179,14 +179,14 @@ class SpecialBlockList extends SpecialPage { $out = $this->getOutput(); # Check for other blocks, i.e. global/tor blocks - $otherBlockLink = array(); - Hooks::run( 'OtherBlockLogLink', array( &$otherBlockLink, $this->target ) ); + $otherBlockLink = []; + Hooks::run( 'OtherBlockLogLink', [ &$otherBlockLink, $this->target ] ); # Show additional header for the local block only when other blocks exists. # Not necessary in a standard installation without such extensions enabled if ( count( $otherBlockLink ) ) { $out->addHTML( - Html::element( 'h2', array(), $this->msg( 'ipblocklist-localblock' )->text() ) . "\n" + Html::element( 'h2', [], $this->msg( 'ipblocklist-localblock' )->text() ) . "\n" ); } @@ -202,17 +202,17 @@ class SpecialBlockList extends SpecialPage { $out->addHTML( Html::rawElement( 'h2', - array(), + [], $this->msg( 'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse() ) . "\n" ); $list = ''; foreach ( $otherBlockLink as $link ) { - $list .= Html::rawElement( 'li', array(), $link ) . "\n"; + $list .= Html::rawElement( 'li', [], $link ) . "\n"; } $out->addHTML( Html::rawElement( 'ul', - array( 'class' => 'mw-ipblocklist-otherblocks' ), + [ 'class' => 'mw-ipblocklist-otherblocks' ], $list ) . "\n" ); } @@ -242,14 +242,14 @@ class BlockListPager extends TablePager { static $headers = null; if ( $headers === null ) { - $headers = array( + $headers = [ 'ipb_timestamp' => 'blocklist-timestamp', 'ipb_target' => 'blocklist-target', 'ipb_expiry' => 'blocklist-expiry', 'ipb_by' => 'blocklist-by', 'ipb_params' => 'blocklist-params', 'ipb_reason' => 'blocklist-reason', - ); + ]; foreach ( $headers as $key => $val ) { $headers[$key] = $this->msg( $val )->text(); } @@ -261,7 +261,7 @@ class BlockListPager extends TablePager { function formatValue( $name, $value ) { static $msg = null; if ( $msg === null ) { - $keys = array( + $keys = [ 'anononlyblock', 'createaccountblock', 'noautoblockblock', @@ -269,7 +269,7 @@ class BlockListPager extends TablePager { 'blocklist-nousertalk', 'unblocklink', 'change-blocklink', - ); + ]; foreach ( $keys as $key ) { $msg[$key] = $this->msg( $key )->escaped(); @@ -320,8 +320,8 @@ class BlockListPager extends TablePager { $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Unblock' ), $msg['unblocklink'], - array(), - array( 'wpTarget' => "#{$row->ipb_id}" ) + [], + [ 'wpTarget' => "#{$row->ipb_id}" ] ); } else { $links[] = Linker::linkKnown( @@ -335,7 +335,7 @@ class BlockListPager extends TablePager { } $formatted .= ' ' . Html::rawElement( 'span', - array( 'class' => 'mw-blocklist-actions' ), + [ 'class' => 'mw-blocklist-actions' ], $this->msg( 'parentheses' )->rawParams( $language->pipeList( $links ) )->escaped() ); @@ -356,7 +356,7 @@ class BlockListPager extends TablePager { break; case 'ipb_params': - $properties = array(); + $properties = []; if ( $row->ipb_anon_only ) { $properties[] = $msg['anononlyblock']; } @@ -387,9 +387,9 @@ class BlockListPager extends TablePager { } function getQueryInfo() { - $info = array( - 'tables' => array( 'ipblocks', 'user' ), - 'fields' => array( + $info = [ + 'tables' => [ 'ipblocks', 'user' ], + 'fields' => [ 'ipb_id', 'ipb_address', 'ipb_user', @@ -408,10 +408,10 @@ class BlockListPager extends TablePager { 'ipb_deleted', 'ipb_block_email', 'ipb_allow_usertalk', - ), + ], 'conds' => $this->conds, - 'join_conds' => array( 'user' => array( 'LEFT JOIN', 'user_id = ipb_by' ) ) - ); + 'join_conds' => [ 'user' => [ 'LEFT JOIN', 'user_id = ipb_by' ] ] + ]; # Filter out any expired blocks $db = $this->getDatabase(); diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php index 53798c0b7f..d185203d4d 100644 --- a/includes/specials/SpecialBooksources.php +++ b/includes/specials/SpecialBooksources.php @@ -124,10 +124,10 @@ class SpecialBookSources extends SpecialPage { $form = Html::openElement( 'fieldset' ) . "\n"; $form .= Html::element( 'legend', - array(), + [], $this->msg( 'booksources-search-legend' )->text() ) . "\n"; - $form .= Html::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ) . "\n"; + $form .= Html::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ) . "\n"; $form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) . "\n"; $form .= '

    ' . Xml::inputLabel( $this->msg( 'booksources-isbn' )->text(), @@ -135,12 +135,12 @@ class SpecialBookSources extends SpecialPage { 'isbn', 20, $this->isbn, - array( 'autofocus' => '', 'class' => 'mw-ui-input-inline' ) + [ 'autofocus' => '', 'class' => 'mw-ui-input-inline' ] ); $form .= ' ' . Html::submitButton( $this->msg( 'booksources-search' )->text(), - array(), array( 'mw-ui-progressive' ) + [], [ 'mw-ui-progressive' ] ) . "

    \n"; $form .= Html::closeElement( 'form' ) . "\n"; @@ -161,7 +161,7 @@ class SpecialBookSources extends SpecialPage { # Hook to allow extensions to insert additional HTML, # e.g. for API-interacting plugins and so on - Hooks::run( 'BookInformation', array( $this->isbn, $this->getOutput() ) ); + Hooks::run( 'BookInformation', [ $this->isbn, $this->getOutput() ] ); # Check for a local page such as Project:Book_sources and use that if available $page = $this->msg( 'booksources' )->inContentLanguage()->text(); @@ -204,8 +204,8 @@ class SpecialBookSources extends SpecialPage { private function makeListItem( $label, $url ) { $url = str_replace( '$1', $this->isbn, $url ); - return Html::rawElement( 'li', array(), - Html::element( 'a', array( 'href' => $url, 'class' => 'external' ), $label ) ); + return Html::rawElement( 'li', [], + Html::element( 'a', [ 'href' => $url, 'class' => 'external' ], $label ) ); } protected function getGroupName() { diff --git a/includes/specials/SpecialBotPasswords.php b/includes/specials/SpecialBotPasswords.php index 93c36abca7..47e3316365 100644 --- a/includes/specials/SpecialBotPasswords.php +++ b/includes/specials/SpecialBotPasswords.php @@ -64,7 +64,7 @@ class SpecialBotPasswords extends FormSpecialPage { $par = null; } elseif ( strlen( $par ) > BotPassword::APPID_MAXLENGTH ) { throw new ErrorPageError( 'botpasswords', 'botpasswords-bad-appid', - array( htmlspecialchars( $par ) ) ); + [ htmlspecialchars( $par ) ] ); } parent::execute( $par ); @@ -88,40 +88,40 @@ class SpecialBotPasswords extends FormSpecialPage { $user = $this->getUser(); $request = $this->getRequest(); - $fields = array(); + $fields = []; if ( $this->par !== null ) { $this->botPassword = BotPassword::newFromCentralId( $this->userId, $this->par ); if ( !$this->botPassword ) { - $this->botPassword = BotPassword::newUnsaved( array( + $this->botPassword = BotPassword::newUnsaved( [ 'centralId' => $this->userId, 'appId' => $this->par, - ) ); + ] ); } $sep = BotPassword::getSeparator(); - $fields[] = array( + $fields[] = [ 'type' => 'info', 'label-message' => 'username', 'default' => $this->getUser()->getName() . $sep . $this->par - ); + ]; if ( $this->botPassword->isSaved() ) { - $fields['resetPassword'] = array( + $fields['resetPassword'] = [ 'type' => 'check', 'label-message' => 'botpasswords-label-resetpassword', - ); + ]; } $lang = $this->getLanguage(); $showGrants = MWGrants::getValidGrants(); - $fields['grants'] = array( + $fields['grants'] = [ 'type' => 'checkmatrix', 'label-message' => 'botpasswords-label-grants', 'help-message' => 'botpasswords-help-grants', - 'columns' => array( + 'columns' => [ $this->msg( 'botpasswords-label-grants-column' )->escaped() => 'grant' - ), + ], 'rows' => array_combine( array_map( 'MWGrants::getGrantsLink', $showGrants ), $showGrants @@ -147,9 +147,9 @@ class SpecialBotPasswords extends FormSpecialPage { }, MWGrants::getHiddenGrants() ), - ); + ]; - $fields['restrictions'] = array( + $fields['restrictions'] = [ 'type' => 'textarea', 'label-message' => 'botpasswords-label-restrictions', 'required' => true, @@ -163,32 +163,32 @@ class SpecialBotPasswords extends FormSpecialPage { return $ex->getMessage(); } }, - ); + ]; } else { $dbr = BotPassword::getDB( DB_SLAVE ); $res = $dbr->select( 'bot_passwords', - array( 'bp_app_id' ), - array( 'bp_user' => $this->userId ), + [ 'bp_app_id' ], + [ 'bp_user' => $this->userId ], __METHOD__ ); foreach ( $res as $row ) { - $fields[] = array( + $fields[] = [ 'section' => 'existing', 'type' => 'info', 'raw' => true, 'default' => Linker::link( $this->getPageTitle( $row->bp_app_id ), htmlspecialchars( $row->bp_app_id ), - array(), - array(), - array( 'known' ) + [], + [], + [ 'known' ] ), - ); + ]; } - $fields['appId'] = array( + $fields['appId'] = [ 'section' => 'createnew', 'type' => 'textwithbutton', 'label-message' => 'botpasswords-label-appid', @@ -200,13 +200,13 @@ class SpecialBotPasswords extends FormSpecialPage { $v = trim( $v ); return $v !== '' && strlen( $v ) <= BotPassword::APPID_MAXLENGTH; }, - ); + ]; - $fields[] = array( + $fields[] = [ 'type' => 'hidden', 'default' => 'new', 'name' => 'op', - ); + ]; } return $fields; @@ -221,33 +221,33 @@ class SpecialBotPasswords extends FormSpecialPage { if ( $this->par !== null ) { if ( $this->botPassword->isSaved() ) { $form->setWrapperLegendMsg( 'botpasswords-editexisting' ); - $form->addButton( array( + $form->addButton( [ 'name' => 'op', 'value' => 'update', 'label-message' => 'botpasswords-label-update', - 'flags' => array( 'primary', 'progressive' ), - ) ); - $form->addButton( array( + 'flags' => [ 'primary', 'progressive' ], + ] ); + $form->addButton( [ 'name' => 'op', 'value' => 'delete', 'label-message' => 'botpasswords-label-delete', - 'flags' => array( 'destructive' ), - ) ); + 'flags' => [ 'destructive' ], + ] ); } else { $form->setWrapperLegendMsg( 'botpasswords-createnew' ); - $form->addButton( array( + $form->addButton( [ 'name' => 'op', 'value' => 'create', 'label-message' => 'botpasswords-label-create', - 'flags' => array( 'primary', 'constructive' ), - ) ); + 'flags' => [ 'primary', 'constructive' ], + ] ); } - $form->addButton( array( + $form->addButton( [ 'name' => 'op', 'value' => 'cancel', 'label-message' => 'botpasswords-label-cancel' - ) ); + ] ); } } @@ -284,7 +284,7 @@ class SpecialBotPasswords extends FormSpecialPage { } private function save( array $data ) { - $bp = BotPassword::newUnsaved( array( + $bp = BotPassword::newUnsaved( [ 'centralId' => $this->userId, 'appId' => $this->par, 'restrictions' => MWRestrictions::newFromJson( $data['restrictions'] ), @@ -292,7 +292,7 @@ class SpecialBotPasswords extends FormSpecialPage { MWGrants::getHiddenGrants(), preg_replace( '/^grant-/', '', $data['grants'] ) ) - ) ); + ] ); if ( $this->operation === 'insert' || !empty( $data['resetPassword'] ) ) { $this->password = PasswordFactory::generateRandomPasswordString( diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index 71616fa2a2..4c3fbe5b18 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -51,44 +51,44 @@ class BrokenRedirectsPage extends QueryPage { public function getQueryInfo() { $dbr = wfGetDB( DB_SLAVE ); - return array( - 'tables' => array( + return [ + 'tables' => [ 'redirect', 'p1' => 'page', 'p2' => 'page', - ), - 'fields' => array( + ], + 'fields' => [ 'namespace' => 'p1.page_namespace', 'title' => 'p1.page_title', 'value' => 'p1.page_title', 'rd_namespace', 'rd_title', - ), - 'conds' => array( + ], + 'conds' => [ // Exclude pages that don't exist locally as wiki pages, // but aren't "broken" either. // Special pages and interwiki links 'rd_namespace >= 0', 'rd_interwiki IS NULL OR rd_interwiki = ' . $dbr->addQuotes( '' ), 'p2.page_namespace IS NULL', - ), - 'join_conds' => array( - 'p1' => array( 'JOIN', array( + ], + 'join_conds' => [ + 'p1' => [ 'JOIN', [ 'rd_from=p1.page_id', - ) ), - 'p2' => array( 'LEFT JOIN', array( + ] ], + 'p2' => [ 'LEFT JOIN', [ 'rd_namespace=p2.page_namespace', 'rd_title=p2.page_title' - ) ), - ), - ); + ] ], + ], + ]; } /** * @return array */ function getOrderFields() { - return array( 'rd_namespace', 'rd_title', 'rd_from' ); + return [ 'rd_namespace', 'rd_title', 'rd_from' ]; } /** @@ -117,10 +117,10 @@ class BrokenRedirectsPage extends QueryPage { $from = Linker::linkKnown( $fromObj, null, - array(), - array( 'redirect' => 'no' ) + [], + [ 'redirect' => 'no' ] ); - $links = array(); + $links = []; // if the page is editable, add an edit link if ( // check user permissions @@ -131,16 +131,16 @@ class BrokenRedirectsPage extends QueryPage { $links[] = Linker::linkKnown( $fromObj, $this->msg( 'brokenredirects-edit' )->escaped(), - array(), - array( 'action' => 'edit' ) + [], + [ 'action' => 'edit' ] ); } $to = Linker::link( $toObj, null, - array(), - array(), - array( 'broken' ) + [], + [], + [ 'broken' ] ); $arr = $this->getLanguage()->getArrow(); @@ -150,8 +150,8 @@ class BrokenRedirectsPage extends QueryPage { $links[] = Linker::linkKnown( $fromObj, $this->msg( 'brokenredirects-delete' )->escaped(), - array(), - array( 'action' => 'delete' ) + [], + [ 'action' => 'delete' ] ); } diff --git a/includes/specials/SpecialCachedPage.php b/includes/specials/SpecialCachedPage.php index cb9b07cde4..14c84e9d97 100644 --- a/includes/specials/SpecialCachedPage.php +++ b/includes/specials/SpecialCachedPage.php @@ -92,7 +92,7 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { $this->cacheHelper = new CacheHelper(); $this->cacheHelper->setCacheEnabled( $this->cacheEnabled ); - $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) ); + $this->cacheHelper->setOnInitializedHandler( [ $this, 'onCacheInitialized' ] ); $keyArgs = $this->getCacheKey(); @@ -124,7 +124,7 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * * @return mixed */ - public function getCachedValue( $computeFunction, $args = array(), $key = null ) { + public function getCachedValue( $computeFunction, $args = [], $key = null ) { return $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ); } @@ -140,7 +140,7 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * @param array $args * @param string|null $key */ - public function addCachedHTML( $computeFunction, $args = array(), $key = null ) { + public function addCachedHTML( $computeFunction, $args = [], $key = null ) { $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, @@ -180,10 +180,10 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * @return array */ protected function getCacheKey() { - return array( + return [ $this->mName, $this->getLanguage()->getCode() - ); + ]; } /** diff --git a/includes/specials/SpecialCategories.php b/includes/specials/SpecialCategories.php index 564579a8bb..5314f63489 100644 --- a/includes/specials/SpecialCategories.php +++ b/includes/specials/SpecialCategories.php @@ -78,7 +78,7 @@ class SpecialCategories extends SpecialPage { $cap->doQuery(); $this->getOutput()->addHTML( - Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) . + Html::openElement( 'div', [ 'class' => 'mw-spcontent' ] ) . $this->msg( 'categoriespagetext', $cap->getNumRows() )->parseAsBlock() . $cap->getStartForm( $from ) . $cap->getNavigationBar() . @@ -125,12 +125,12 @@ class CategoryPager extends AlphabeticPager { } function getQueryInfo() { - return array( - 'tables' => array( 'category' ), - 'fields' => array( 'cat_title', 'cat_pages' ), - 'conds' => array( 'cat_pages > 0' ), - 'options' => array( 'USE INDEX' => 'cat_title' ), - ); + return [ + 'tables' => [ 'category' ], + 'fields' => [ 'cat_title', 'cat_pages' ], + 'conds' => [ 'cat_pages > 0' ], + 'options' => [ 'USE INDEX' => 'cat_title' ], + ]; } function getIndexField() { @@ -182,17 +182,17 @@ class CategoryPager extends AlphabeticPager { public function getStartForm( $from ) { return Xml::tags( 'form', - array( 'method' => 'get', 'action' => wfScript() ), + [ 'method' => 'get', 'action' => wfScript() ], Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . Xml::fieldset( $this->msg( 'categories' )->text(), Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(), - 'from', 'from', 20, $from, array( 'class' => 'mw-ui-input-inline' ) ) . + 'from', 'from', 20, $from, [ 'class' => 'mw-ui-input-inline' ] ) . ' ' . Html::submitButton( $this->msg( 'categories-submit' )->text(), - array(), array( 'mw-ui-progressive' ) + [], [ 'mw-ui-progressive' ] ) ) ); diff --git a/includes/specials/SpecialChangeContentModel.php b/includes/specials/SpecialChangeContentModel.php index 1f32e3f808..d495120e0c 100644 --- a/includes/specials/SpecialChangeContentModel.php +++ b/includes/specials/SpecialChangeContentModel.php @@ -69,26 +69,26 @@ class SpecialChangeContentModel extends FormSpecialPage { protected function getFormFields() { $that = $this; - $fields = array( - 'pagetitle' => array( + $fields = [ + 'pagetitle' => [ 'type' => 'title', 'creatable' => true, 'name' => 'pagetitle', 'default' => $this->par, 'label-message' => 'changecontentmodel-title-label', - 'validation-callback' => array( $this, 'validateTitle' ), - ), - ); + 'validation-callback' => [ $this, 'validateTitle' ], + ], + ]; if ( $this->title ) { $fields['pagetitle']['readonly'] = true; - $fields += array( - 'model' => array( + $fields += [ + 'model' => [ 'type' => 'select', 'name' => 'model', 'options' => $this->getOptionsForTitle( $this->title ), 'label-message' => 'changecontentmodel-model-label' - ), - 'reason' => array( + ], + 'reason' => [ 'type' => 'text', 'name' => 'reason', 'validation-callback' => function( $reason ) use ( $that ) { @@ -100,8 +100,8 @@ class SpecialChangeContentModel extends FormSpecialPage { return true; }, 'label-message' => 'changecontentmodel-reason-label', - ), - ); + ], + ]; } return $fields; @@ -109,7 +109,7 @@ class SpecialChangeContentModel extends FormSpecialPage { private function getOptionsForTitle( Title $title = null ) { $models = ContentHandler::getContentModels(); - $options = array(); + $options = []; foreach ( $models as $model ) { $handler = ContentHandler::getForModelID( $model ); if ( !$handler->supportsDirectEditing() ) { @@ -152,7 +152,7 @@ class SpecialChangeContentModel extends FormSpecialPage { $out = $this->getOutput(); $wikitext = $out->formatPermissionsErrorMessage( $errors ); // Hack to get our wikitext parsed - return Status::newFatal( new RawMessage( '$1', array( $wikitext ) ) ); + return Status::newFatal( new RawMessage( '$1', [ $wikitext ] ) ); } $page = WikiPage::factory( $this->title ); @@ -188,10 +188,10 @@ class SpecialChangeContentModel extends FormSpecialPage { $log->setPerformer( $user ); $log->setTarget( $this->title ); $log->setComment( $data['reason'] ); - $log->setParameters( array( + $log->setParameters( [ '4::oldmodel' => $oldModel, '5::newmodel' => $data['model'] - ) ); + ] ); $formatter = LogFormatter::newFromEntry( $log ); $formatter->setContext( RequestContext::newExtraneousContext( $this->title ) ); diff --git a/includes/specials/SpecialChangeEmail.php b/includes/specials/SpecialChangeEmail.php index 989bae9945..4c3fc0e114 100644 --- a/includes/specials/SpecialChangeEmail.php +++ b/includes/specials/SpecialChangeEmail.php @@ -81,30 +81,30 @@ class SpecialChangeEmail extends FormSpecialPage { protected function getFormFields() { $user = $this->getUser(); - $fields = array( - 'Name' => array( + $fields = [ + 'Name' => [ 'type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), - ), - 'OldEmail' => array( + ], + 'OldEmail' => [ 'type' => 'info', 'label-message' => 'changeemail-oldemail', 'default' => $user->getEmail() ?: $this->msg( 'changeemail-none' )->text(), - ), - 'NewEmail' => array( + ], + 'NewEmail' => [ 'type' => 'email', 'label-message' => 'changeemail-newemail', 'autofocus' => true, 'help-message' => 'changeemail-newemail-help', - ), - ); + ], + ]; if ( $this->getConfig()->get( 'RequirePasswordforEmailChange' ) ) { - $fields['Password'] = array( + $fields['Password'] = [ 'type' => 'password', 'label-message' => 'changeemail-password' - ); + ]; } return $fields; @@ -200,7 +200,7 @@ class SpecialChangeEmail extends FormSpecialPage { return $status; } - Hooks::run( 'PrefsEmailAudit', array( $user, $oldaddr, $newaddr ) ); + Hooks::run( 'PrefsEmailAudit', [ $user, $oldaddr, $newaddr ] ); $user->saveSettings(); diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 3e5a936ba3..4f7ba25dcb 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -90,55 +90,55 @@ class SpecialChangePassword extends FormSpecialPage { $oldpassMsg = $user->isLoggedIn() ? 'oldpassword' : 'resetpass-temp-password'; } - $fields = array( - 'Name' => array( + $fields = [ + 'Name' => [ 'type' => 'info', 'label-message' => 'username', 'default' => $request->getVal( 'wpName', $user->getName() ), - ), - 'Password' => array( + ], + 'Password' => [ 'type' => 'password', 'label-message' => $oldpassMsg, - ), - 'NewPassword' => array( + ], + 'NewPassword' => [ 'type' => 'password', 'label-message' => 'newpassword', - ), - 'Retype' => array( + ], + 'Retype' => [ 'type' => 'password', 'label-message' => 'retypenew', - ), - ); + ], + ]; if ( !$this->getUser()->isLoggedIn() ) { - $fields['LoginOnChangeToken'] = array( + $fields['LoginOnChangeToken'] = [ 'type' => 'hidden', 'label' => 'Change Password Token', 'default' => LoginForm::getLoginToken()->toString(), - ); + ]; } - $extraFields = array(); - Hooks::run( 'ChangePasswordForm', array( &$extraFields ) ); + $extraFields = []; + Hooks::run( 'ChangePasswordForm', [ &$extraFields ] ); foreach ( $extraFields as $extra ) { list( $name, $label, $type, $default ) = $extra; - $fields[$name] = array( + $fields[$name] = [ 'type' => $type, 'name' => $name, 'label-message' => $label, 'default' => $default, - ); + ]; } if ( !$user->isLoggedIn() ) { - $fields['Remember'] = array( + $fields['Remember'] = [ 'type' => 'check', 'label' => $this->msg( 'remembermypassword' ) ->numParams( ceil( $this->getConfig()->get( 'CookieExpiration' ) / ( 3600 * 24 ) ) )->text(), 'default' => $request->getVal( 'wpRemember' ), - ); + ]; } return $fields; @@ -153,10 +153,10 @@ class SpecialChangePassword extends FormSpecialPage { ? 'resetpass-submit-loggedin' : 'resetpass_submit' ); - $form->addButton( array( + $form->addButton( [ 'name' => 'wpCancel', 'value' => $this->msg( 'resetpass-submit-cancel' )->text() - ) ); + ] ); $form->setHeaderText( $this->msg( 'resetpass_text' )->parseAsBlock() ); if ( $this->mPreTextMessage instanceof Message ) { $form->addPreText( $this->mPreTextMessage->parseAsBlock() ); @@ -217,13 +217,13 @@ class SpecialChangePassword extends FormSpecialPage { $request = $this->getRequest(); LoginForm::clearLoginToken(); $token = LoginForm::getLoginToken()->toString(); - $data = array( + $data = [ 'action' => 'submitlogin', 'wpName' => $this->mUserName, 'wpDomain' => $this->mDomain, 'wpLoginToken' => $token, 'wpPassword' => $request->getVal( 'wpNewPassword' ), - ) + $request->getValues( 'wpRemember', 'returnto', 'returntoquery' ); + ] + $request->getValues( 'wpRemember', 'returnto', 'returntoquery' ); $login = new LoginForm( new DerivativeRequest( $request, $data, true ) ); $login->setContext( $this->getContext() ); $login->execute( null ); @@ -253,7 +253,7 @@ class SpecialChangePassword extends FormSpecialPage { } if ( $newpass !== $retype ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'badretype' ] ); return Status::newFatal( $this->msg( 'badretype' ) ); } @@ -268,7 +268,7 @@ class SpecialChangePassword extends FormSpecialPage { // @todo Make these separate messages, since the message is written for both cases if ( !$user->checkTemporaryPassword( $oldpass ) && !$user->checkPassword( $oldpass ) ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'wrongpassword' ] ); return Status::newFatal( $this->msg( 'resetpass-wrong-oldpass' ) ); } @@ -280,8 +280,8 @@ class SpecialChangePassword extends FormSpecialPage { // Do AbortChangePassword after checking mOldpass, so we don't leak information // by possibly aborting a new password before verifying the old password. $abortMsg = 'resetpass-abort-generic'; - if ( !Hooks::run( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) ); + if ( !Hooks::run( 'AbortChangePassword', [ $user, $oldpass, $newpass, &$abortMsg ] ) ) { + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'abortreset' ] ); return Status::newFatal( $this->msg( $abortMsg ) ); } @@ -292,9 +292,9 @@ class SpecialChangePassword extends FormSpecialPage { try { $user->setPassword( $newpass ); - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'success' ] ); } catch ( PasswordError $e ) { - Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) ); + Hooks::run( 'PrefsPasswordAudit', [ $user, $newpass, 'error' ] ); return Status::newFatal( new RawMessage( $e->getMessage() ) ); } @@ -331,12 +331,12 @@ class SpecialChangePassword extends FormSpecialPage { ); } // Give extensions a chance to force an expiration - Hooks::run( 'ResetPasswordExpiration', array( $this, &$newExpire ) ); + Hooks::run( 'ResetPasswordExpiration', [ $this, &$newExpire ] ); $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'user', - array( 'user_password_expires' => $dbw->timestampOrNull( $newExpire ) ), - array( 'user_id' => $user->getID() ), + [ 'user_password_expires' => $dbw->timestampOrNull( $newExpire ) ], + [ 'user_id' => $user->getID() ], __METHOD__ ); } diff --git a/includes/specials/SpecialComparePages.php b/includes/specials/SpecialComparePages.php index fbc5984e02..35cc6b84f2 100644 --- a/includes/specials/SpecialComparePages.php +++ b/includes/specials/SpecialComparePages.php @@ -51,56 +51,56 @@ class SpecialComparePages extends SpecialPage { $this->outputHeader(); $this->getOutput()->addModuleStyles( 'mediawiki.special.comparepages.styles' ); - $form = HTMLForm::factory( 'ooui', array( - 'Page1' => array( + $form = HTMLForm::factory( 'ooui', [ + 'Page1' => [ 'type' => 'title', 'name' => 'page1', 'label-message' => 'compare-page1', 'size' => '40', 'section' => 'page1', - 'validation-callback' => array( $this, 'checkExistingTitle' ), - ), - 'Revision1' => array( + 'validation-callback' => [ $this, 'checkExistingTitle' ], + ], + 'Revision1' => [ 'type' => 'int', 'name' => 'rev1', 'label-message' => 'compare-rev1', 'size' => '8', 'section' => 'page1', - 'validation-callback' => array( $this, 'checkExistingRevision' ), - ), - 'Page2' => array( + 'validation-callback' => [ $this, 'checkExistingRevision' ], + ], + 'Page2' => [ 'type' => 'title', 'name' => 'page2', 'label-message' => 'compare-page2', 'size' => '40', 'section' => 'page2', - 'validation-callback' => array( $this, 'checkExistingTitle' ), - ), - 'Revision2' => array( + 'validation-callback' => [ $this, 'checkExistingTitle' ], + ], + 'Revision2' => [ 'type' => 'int', 'name' => 'rev2', 'label-message' => 'compare-rev2', 'size' => '8', 'section' => 'page2', - 'validation-callback' => array( $this, 'checkExistingRevision' ), - ), - 'Action' => array( + 'validation-callback' => [ $this, 'checkExistingRevision' ], + ], + 'Action' => [ 'type' => 'hidden', 'name' => 'action', - ), - 'Diffonly' => array( + ], + 'Diffonly' => [ 'type' => 'hidden', 'name' => 'diffonly', - ), - 'Unhide' => array( + ], + 'Unhide' => [ 'type' => 'hidden', 'name' => 'unhide', - ), - ), $this->getContext(), 'compare' ); + ], + ], $this->getContext(), 'compare' ); $form->setSubmitTextMsg( 'compare-submit' ); $form->suppressReset(); $form->setMethod( 'get' ); - $form->setSubmitCallback( array( __CLASS__, 'showDiff' ) ); + $form->setSubmitCallback( [ __CLASS__, 'showDiff' ] ); $form->loadData(); $form->displayForm( '' ); diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index 5ed33e052c..914781c16a 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -83,17 +83,17 @@ class EmailConfirmation extends UnlistedSpecialPage { $out = $this->getOutput(); if ( !$user->isEmailConfirmed() ) { - $descriptor = array(); + $descriptor = []; if ( $user->isEmailConfirmationPending() ) { - $descriptor += array( - 'pending' => array( + $descriptor += [ + 'pending' => [ 'type' => 'info', 'raw' => true, 'default' => "
    \n" . $this->msg( 'confirmemail_pending' )->escaped() . "\n
    ", - ), - ); + ], + ]; } $out->addWikiMsg( 'confirmemail_text' ); @@ -102,7 +102,7 @@ class EmailConfirmation extends UnlistedSpecialPage { ->setMethod( 'post' ) ->setAction( $this->getPageTitle()->getLocalURL() ) ->setSubmitTextMsg( 'confirmemail_send' ) - ->setSubmitCallback( array( $this, 'submitSend' ) ); + ->setSubmitCallback( [ $this, 'submitSend' ] ); $retval = $form->show(); diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 0e3c9aac4b..254d9e2401 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -40,7 +40,7 @@ class SpecialContributions extends IncludableSpecialPage { $out->addModuleStyles( 'mediawiki.special' ); $this->addHelpLink( 'Help:User contributions' ); - $this->opts = array(); + $this->opts = []; $request = $this->getRequest(); if ( $par !== null ) { @@ -132,10 +132,10 @@ class SpecialContributions extends IncludableSpecialPage { $feedType = $request->getVal( 'feed' ); - $feedParams = array( + $feedParams = [ 'action' => 'feedcontributions', 'user' => $target, - ); + ]; if ( $this->opts['topOnly'] ) { $feedParams['toponly'] = true; } @@ -174,11 +174,11 @@ class SpecialContributions extends IncludableSpecialPage { // Add RSS/atom links $this->addFeedLinks( $feedParams ); - if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', array( $id, $userObj, $this ) ) ) { + if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) { if ( !$this->including() ) { $out->addHTML( $this->getForm() ); } - $pager = new ContribsPager( $this->getContext(), array( + $pager = new ContribsPager( $this->getContext(), [ 'target' => $target, 'contribs' => $this->opts['contribs'], 'namespace' => $this->opts['namespace'], @@ -190,7 +190,7 @@ class SpecialContributions extends IncludableSpecialPage { 'newOnly' => $this->opts['newOnly'], 'nsInvert' => $this->opts['nsInvert'], 'associated' => $this->opts['associated'], - ) ); + ] ); if ( !$pager->getNumRows() ) { $out->addWikiMsg( 'nocontribs', $target ); @@ -228,7 +228,7 @@ class SpecialContributions extends IncludableSpecialPage { if ( !$this->msg( $message, $target )->isDisabled() ) { $out->wrapWikiMsg( "", - array( $message, $target ) ); + [ $message, $target ] ); } } } @@ -248,10 +248,10 @@ class SpecialContributions extends IncludableSpecialPage { if ( !User::isIP( $userObj->getName() ) ) { $this->getOutput()->wrapWikiMsg( "
    \n\$1\n
    ", - array( + [ 'contributions-userdoesnotexist', wfEscapeWikiText( $userObj->getName() ), - ) + ] ); if ( !$this->including() ) { $this->getOutput()->setStatusCode( 404 ); @@ -284,17 +284,17 @@ class SpecialContributions extends IncludableSpecialPage { 'block', $nt, '', - array( + [ 'lim' => 1, 'showIfEmpty' => false, - 'msgKey' => array( + 'msgKey' => [ $userObj->isAnon() ? 'sp-contributions-blocked-notice-anon' : 'sp-contributions-blocked-notice', $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice' - ), + ], 'offset' => '' # don't use WebRequest parameter offset - ) + ] ); } } @@ -340,8 +340,8 @@ class SpecialContributions extends IncludableSpecialPage { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log', 'block' ), $this->msg( 'sp-contributions-blocklog' )->escaped(), - array(), - array( 'page' => $userpage->getPrefixedText() ) + [], + [ 'page' => $userpage->getPrefixedText() ] ); # Suppression log link (bug 59120) @@ -349,8 +349,8 @@ class SpecialContributions extends IncludableSpecialPage { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log', 'suppress' ), $this->msg( 'sp-contributions-suppresslog' )->escaped(), - array(), - array( 'offender' => $username ) + [], + [ 'offender' => $username ] ); } } @@ -384,7 +384,7 @@ class SpecialContributions extends IncludableSpecialPage { ); } - Hooks::run( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) ); + Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools ] ); return $tools; } @@ -443,15 +443,15 @@ class SpecialContributions extends IncludableSpecialPage { $form = Html::openElement( 'form', - array( + [ 'method' => 'get', 'action' => wfScript(), 'class' => 'mw-contributions-form' - ) + ] ); # Add hidden params for tracking except for parameters in $skipParameters - $skipParameters = array( + $skipParameters = [ 'namespace', 'nsInvert', 'deletedOnly', @@ -463,7 +463,7 @@ class SpecialContributions extends IncludableSpecialPage { 'newOnly', 'associated', 'tagfilter' - ); + ]; foreach ( $this->opts as $name => $value ) { if ( in_array( $name, $skipParameters ) ) { @@ -477,11 +477,11 @@ class SpecialContributions extends IncludableSpecialPage { if ( $tagFilter ) { $filterSelection = Html::rawElement( 'td', - array(), + [], implode( ' ', $tagFilter ) ); } else { - $filterSelection = Html::rawElement( 'td', array( 'colspan' => 2 ), '' ); + $filterSelection = Html::rawElement( 'td', [ 'colspan' => 2 ], '' ); } $this->getOutput()->addModules( 'mediawiki.userSuggest' ); @@ -492,7 +492,7 @@ class SpecialContributions extends IncludableSpecialPage { 'newbie', 'newbie', $this->opts['contribs'] == 'newbie', - array( 'class' => 'mw-input' ) + [ 'class' => 'mw-input' ] ); $labelUsername = Xml::radioLabel( $this->msg( 'sp-contributions-username' )->text(), @@ -500,145 +500,145 @@ class SpecialContributions extends IncludableSpecialPage { 'user', 'user', $this->opts['contribs'] == 'user', - array( 'class' => 'mw-input' ) + [ 'class' => 'mw-input' ] ); $input = Html::input( 'target', $this->opts['target'], 'text', - array( + [ 'size' => '40', 'required' => '', - 'class' => array( + 'class' => [ 'mw-input', 'mw-ui-input-inline', 'mw-autocomplete-user', // used by mediawiki.userSuggest - ), - ) + ( + ], + ] + ( // Only autofocus if target hasn't been specified or in non-newbies mode ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] ) - ? array() : array( 'autofocus' => true ) + ? [] : [ 'autofocus' => true ] ) ); $targetSelection = Html::rawElement( 'td', - array( 'colspan' => 2 ), + [ 'colspan' => 2 ], $labelNewbies . '
    ' . $labelUsername . ' ' . $input . ' ' ); $namespaceSelection = Xml::tags( 'td', - array(), + [], Xml::label( $this->msg( 'namespace' )->text(), 'namespace', '' ) . Html::namespaceSelector( - array( 'selected' => $this->opts['namespace'], 'all' => '' ), - array( + [ 'selected' => $this->opts['namespace'], 'all' => '' ], + [ 'name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector', - ) + ] ) . ' ' . Html::rawElement( 'span', - array( 'class' => 'mw-input-with-label' ), + [ 'class' => 'mw-input-with-label' ], Xml::checkLabel( $this->msg( 'invert' )->text(), 'nsInvert', 'nsInvert', $this->opts['nsInvert'], - array( + [ 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' - ) + ] ) . ' ' ) . - Html::rawElement( 'span', array( 'class' => 'mw-input-with-label' ), + Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ], Xml::checkLabel( $this->msg( 'namespace_association' )->text(), 'associated', 'associated', $this->opts['associated'], - array( + [ 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' - ) + ] ) . ' ' ) ); - $filters = array(); + $filters = []; if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) { $filters[] = Html::rawElement( 'span', - array( 'class' => 'mw-input-with-label' ), + [ 'class' => 'mw-input-with-label' ], Xml::checkLabel( $this->msg( 'history-show-deleted' )->text(), 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'], - array( 'class' => 'mw-input' ) + [ 'class' => 'mw-input' ] ) ); } $filters[] = Html::rawElement( 'span', - array( 'class' => 'mw-input-with-label' ), + [ 'class' => 'mw-input-with-label' ], Xml::checkLabel( $this->msg( 'sp-contributions-toponly' )->text(), 'topOnly', 'mw-show-top-only', $this->opts['topOnly'], - array( 'class' => 'mw-input' ) + [ 'class' => 'mw-input' ] ) ); $filters[] = Html::rawElement( 'span', - array( 'class' => 'mw-input-with-label' ), + [ 'class' => 'mw-input-with-label' ], Xml::checkLabel( $this->msg( 'sp-contributions-newonly' )->text(), 'newOnly', 'mw-show-new-only', $this->opts['newOnly'], - array( 'class' => 'mw-input' ) + [ 'class' => 'mw-input' ] ) ); Hooks::run( 'SpecialContributions::getForm::filters', - array( $this, &$filters ) + [ $this, &$filters ] ); $extraOptions = Html::rawElement( 'td', - array( 'colspan' => 2 ), + [ 'colspan' => 2 ], implode( '', $filters ) ); - $dateSelectionAndSubmit = Xml::tags( 'td', array( 'colspan' => 2 ), + $dateSelectionAndSubmit = Xml::tags( 'td', [ 'colspan' => 2 ], Xml::dateMenu( $this->opts['year'] === '' ? MWTimestamp::getInstance()->format( 'Y' ) : $this->opts['year'], $this->opts['month'] ) . ' ' . Html::submitButton( $this->msg( 'sp-contributions-submit' )->text(), - array( 'class' => 'mw-submit' ), array( 'mw-ui-progressive' ) + [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ] ) ); $form .= Xml::fieldset( $this->msg( 'sp-contributions-search' )->text() ); - $form .= Html::rawElement( 'table', array( 'class' => 'mw-contributions-table' ), "\n" . - Html::rawElement( 'tr', array(), $targetSelection ) . "\n" . - Html::rawElement( 'tr', array(), $namespaceSelection ) . "\n" . - Html::rawElement( 'tr', array(), $filterSelection ) . "\n" . - Html::rawElement( 'tr', array(), $extraOptions ) . "\n" . - Html::rawElement( 'tr', array(), $dateSelectionAndSubmit ) . "\n" + $form .= Html::rawElement( 'table', [ 'class' => 'mw-contributions-table' ], "\n" . + Html::rawElement( 'tr', [], $targetSelection ) . "\n" . + Html::rawElement( 'tr', [], $namespaceSelection ) . "\n" . + Html::rawElement( 'tr', [], $filterSelection ) . "\n" . + Html::rawElement( 'tr', [], $extraOptions ) . "\n" . + Html::rawElement( 'tr', [], $dateSelectionAndSubmit ) . "\n" ); $explain = $this->msg( 'sp-contributions-explain' ); @@ -663,7 +663,7 @@ class SpecialContributions extends IncludableSpecialPage { $user = User::newFromName( $search ); if ( !$user ) { // No prefix suggestion for invalid user - return array(); + return []; } // Autocomplete subpage as user list - public to allow caching return UserNamePrefixSearch::search( 'public', $search, $limit, $offset ); @@ -697,12 +697,12 @@ class ContribsPager extends ReverseChronologicalPager { function __construct( IContextSource $context, array $options ) { parent::__construct( $context ); - $msgs = array( + $msgs = [ 'diff', 'hist', 'pipe-separator', 'uctop' - ); + ]; foreach ( $msgs as $msg ) { $this->messages[$msg] = $this->msg( $msg )->escaped(); @@ -771,15 +771,15 @@ class ContribsPager extends ReverseChronologicalPager { * $limit: see phpdoc above * $descending: see phpdoc above */ - $data = array( $this->mDb->select( + $data = [ $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds - ) ); + ) ]; Hooks::run( 'ContribsPager::reallyDoQuery', - array( &$data, $this, $offset, $limit, $descending ) + [ &$data, $this, $offset, $limit, $descending ] ); - $result = array(); + $result = []; // loop all results and collect them in an array foreach ( $data as $query ) { @@ -824,23 +824,23 @@ class ContribsPager extends ReverseChronologicalPager { # Get the current user name for accounts $join_cond['user'] = Revision::userJoinCond(); - $options = array(); + $options = []; if ( $index ) { - $options['USE INDEX'] = array( 'revision' => $index ); + $options['USE INDEX'] = [ 'revision' => $index ]; } - $queryInfo = array( + $queryInfo = [ 'tables' => $tables, 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields(), - array( 'page_namespace', 'page_title', 'page_is_new', - 'page_latest', 'page_is_redirect', 'page_len' ) + [ 'page_namespace', 'page_title', 'page_is_new', + 'page_latest', 'page_is_redirect', 'page_len' ] ), 'conds' => $conds, 'options' => $options, 'join_conds' => $join_cond - ); + ]; ChangeTags::modifyDisplayQuery( $queryInfo['tables'], @@ -851,15 +851,15 @@ class ContribsPager extends ReverseChronologicalPager { $this->tagFilter ); - Hooks::run( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) ); + Hooks::run( 'ContribsPager::getQueryInfo', [ &$this, &$queryInfo ] ); return $queryInfo; } function getUserCond() { - $condition = array(); - $join_conds = array(); - $tables = array( 'revision', 'page', 'user' ); + $condition = []; + $join_conds = []; + $tables = [ 'revision', 'page', 'user' ]; $index = false; if ( $this->contribs == 'newbie' ) { $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ ); @@ -870,12 +870,12 @@ class ContribsPager extends ReverseChronologicalPager { if ( count( $groupsWithBotPermission ) ) { $tables[] = 'user_groups'; $condition[] = 'ug_group IS NULL'; - $join_conds['user_groups'] = array( - 'LEFT JOIN', array( + $join_conds['user_groups'] = [ + 'LEFT JOIN', [ 'ug_user = rev_user', 'ug_group' => $groupsWithBotPermission - ) - ); + ] + ]; } } else { $uid = User::idFromName( $this->target ); @@ -900,7 +900,7 @@ class ContribsPager extends ReverseChronologicalPager { $condition[] = 'rev_parent_id = 0'; } - return array( $tables, $index, $condition, $join_conds ); + return [ $tables, $index, $condition, $join_conds ]; } function getNamespaceCond() { @@ -910,21 +910,21 @@ class ContribsPager extends ReverseChronologicalPager { $bool_op = $this->nsInvert ? 'AND' : 'OR'; if ( !$this->associated ) { - return array( "page_namespace $eq_op $selectedNS" ); + return [ "page_namespace $eq_op $selectedNS" ]; } $associatedNS = $this->mDb->addQuotes( MWNamespace::getAssociated( $this->namespace ) ); - return array( + return [ "page_namespace $eq_op $selectedNS " . $bool_op . " page_namespace $eq_op $associatedNS" - ); + ]; } - return array(); + return []; } function getIndexField() { @@ -934,7 +934,7 @@ class ContribsPager extends ReverseChronologicalPager { function doBatchLookups() { # Do a link batch query $this->mResult->seek( 0 ); - $revIds = array(); + $revIds = []; $batch = new LinkBatch(); # Give some pointers to make (last) links foreach ( $this->mResult as $row ) { @@ -983,7 +983,7 @@ class ContribsPager extends ReverseChronologicalPager { function formatRow( $row ) { $ret = ''; - $classes = array(); + $classes = []; /* * There may be more than just revision rows. To make sure that we'll only be processing @@ -1002,14 +1002,14 @@ class ContribsPager extends ReverseChronologicalPager { MediaWiki\restoreWarnings(); if ( $validRevision ) { - $classes = array(); + $classes = []; $page = Title::newFromRow( $row ); $link = Linker::link( $page, htmlspecialchars( $page->getPrefixedText() ), - array( 'class' => 'mw-contributions-title' ), - $page->isRedirect() ? array( 'redirect' => 'no' ) : array() + [ 'class' => 'mw-contributions-title' ], + $page->isRedirect() ? [ 'redirect' => 'no' ] : [] ); # Mark current revisions $topmarktext = ''; @@ -1029,11 +1029,11 @@ class ContribsPager extends ReverseChronologicalPager { $difftext = Linker::linkKnown( $page, $this->messages['diff'], - array(), - array( + [], + [ 'diff' => 'prev', 'oldid' => $row->rev_id - ) + ] ); } else { $difftext = $this->messages['diff']; @@ -1041,8 +1041,8 @@ class ContribsPager extends ReverseChronologicalPager { $histlink = Linker::linkKnown( $page, $this->messages['hist'], - array(), - array( 'action' => 'history' ) + [], + [ 'action' => 'history' ] ); if ( $row->rev_parent_id === null ) { @@ -1074,8 +1074,8 @@ class ContribsPager extends ReverseChronologicalPager { $d = Linker::linkKnown( $page, htmlspecialchars( $date ), - array( 'class' => 'mw-changeslist-date' ), - array( 'oldid' => intval( $row->rev_id ) ) + [ 'class' => 'mw-changeslist-date' ], + [ 'oldid' => intval( $row->rev_id ) ] ); } else { $d = htmlspecialchars( $date ); @@ -1136,13 +1136,13 @@ class ContribsPager extends ReverseChronologicalPager { } // Let extensions add data - Hooks::run( 'ContributionsLineEnding', array( $this, &$ret, $row, &$classes ) ); + Hooks::run( 'ContributionsLineEnding', [ $this, &$ret, $row, &$classes ] ); - if ( $classes === array() && $ret === '' ) { + if ( $classes === [] && $ret === '' ) { wfDebug( "Dropping Special:Contribution row that could not be formatted\n" ); $ret = "\n"; } else { - $ret = Html::rawElement( 'li', array( 'class' => $classes ), $ret ) . "\n"; + $ret = Html::rawElement( 'li', [ 'class' => $classes ], $ret ) . "\n"; } return $ret; diff --git a/includes/specials/SpecialCreateAccount.php b/includes/specials/SpecialCreateAccount.php index f8c683207f..69ddcf9aae 100644 --- a/includes/specials/SpecialCreateAccount.php +++ b/includes/specials/SpecialCreateAccount.php @@ -33,7 +33,7 @@ class SpecialCreateAccount extends SpecialRedirectToSpecial { 'CreateAccount', 'Userlogin', 'signup', - array( 'returnto', 'returntoquery', 'uselang' ) + [ 'returnto', 'returntoquery', 'uselang' ] ); } diff --git a/includes/specials/SpecialDeadendpages.php b/includes/specials/SpecialDeadendpages.php index 44137c1ea0..f13f231dc4 100644 --- a/includes/specials/SpecialDeadendpages.php +++ b/includes/specials/SpecialDeadendpages.php @@ -57,34 +57,34 @@ class DeadendPagesPage extends PageQueryPage { } function getQueryInfo() { - return array( - 'tables' => array( 'page', 'pagelinks' ), - 'fields' => array( + return [ + 'tables' => [ 'page', 'pagelinks' ], + 'fields' => [ 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_title' - ), - 'conds' => array( + ], + 'conds' => [ 'pl_from IS NULL', 'page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0 - ), - 'join_conds' => array( - 'pagelinks' => array( + ], + 'join_conds' => [ + 'pagelinks' => [ 'LEFT JOIN', - array( 'page_id=pl_from' ) - ) - ) - ); + [ 'page_id=pl_from' ] + ] + ] + ]; } function getOrderFields() { // For some crazy reason ordering by a constant // causes a filesort if ( count( MWNamespace::getContentNamespaces() ) > 1 ) { - return array( 'page_namespace', 'page_title' ); + return [ 'page_namespace', 'page_title' ]; } else { - return array( 'page_title' ); + return [ 'page_title' ]; } } diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index f6d560f4e0..b790fdf5a8 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -39,7 +39,7 @@ class DeletedContribsPager extends IndexPager { function __construct( IContextSource $context, $target, $namespace = false ) { parent::__construct( $context ); - $msgs = array( 'deletionlog', 'undeleteviewlink', 'diff' ); + $msgs = [ 'deletionlog', 'undeleteviewlink', 'diff' ]; foreach ( $msgs as $msg ) { $this->messages[$msg] = $this->msg( $msg )->escaped(); } @@ -67,15 +67,15 @@ class DeletedContribsPager extends IndexPager { ' != ' . Revision::SUPPRESSED_USER; } - return array( - 'tables' => array( 'archive' ), - 'fields' => array( + return [ + 'tables' => [ 'archive' ], + 'fields' => [ 'ar_rev_id', 'ar_namespace', 'ar_title', 'ar_timestamp', 'ar_comment', 'ar_minor_edit', 'ar_user', 'ar_user_text', 'ar_deleted' - ), + ], 'conds' => $conds, - 'options' => array( 'USE INDEX' => $index ) - ); + 'options' => [ 'USE INDEX' => $index ] + ]; } /** @@ -88,16 +88,16 @@ class DeletedContribsPager extends IndexPager { * @return ResultWrapper */ function reallyDoQuery( $offset, $limit, $descending ) { - $data = array( parent::reallyDoQuery( $offset, $limit, $descending ) ); + $data = [ parent::reallyDoQuery( $offset, $limit, $descending ) ]; // This hook will allow extensions to add in additional queries, nearly // identical to ContribsPager::reallyDoQuery. Hooks::run( 'DeletedContribsPager::reallyDoQuery', - array( &$data, $this, $offset, $limit, $descending ) + [ &$data, $this, $offset, $limit, $descending ] ); - $result = array(); + $result = []; // loop all results and collect them in an array foreach ( $data as $query ) { @@ -124,12 +124,12 @@ class DeletedContribsPager extends IndexPager { } function getUserCond() { - $condition = array(); + $condition = []; $condition['ar_user_text'] = $this->target; $index = 'usertext_timestamp'; - return array( $index, $condition ); + return [ $index, $condition ]; } function getIndexField() { @@ -149,19 +149,19 @@ class DeletedContribsPager extends IndexPager { return $this->mNavigationBar; } - $linkTexts = array( + $linkTexts = [ 'prev' => $this->msg( 'pager-newer-n' )->numParams( $this->mLimit )->escaped(), 'next' => $this->msg( 'pager-older-n' )->numParams( $this->mLimit )->escaped(), 'first' => $this->msg( 'histlast' )->escaped(), 'last' => $this->msg( 'histfirst' )->escaped() - ); + ]; $pagingLinks = $this->getPagingLinks( $linkTexts ); $limitLinks = $this->getLimitLinks(); $lang = $this->getLanguage(); $limits = $lang->pipeList( $limitLinks ); - $firstLast = $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ); + $firstLast = $lang->pipeList( [ $pagingLinks['first'], $pagingLinks['last'] ] ); $firstLast = $this->msg( 'parentheses' )->rawParams( $firstLast )->escaped(); $prevNext = $this->msg( 'viewprevnext' ) ->rawParams( @@ -177,9 +177,9 @@ class DeletedContribsPager extends IndexPager { function getNamespaceCond() { if ( $this->namespace !== '' ) { - return array( 'ar_namespace' => (int)$this->namespace ); + return [ 'ar_namespace' => (int)$this->namespace ]; } else { - return array(); + return []; } } @@ -192,7 +192,7 @@ class DeletedContribsPager extends IndexPager { */ function formatRow( $row ) { $ret = ''; - $classes = array(); + $classes = []; /* * There may be more than just revision rows. To make sure that we'll only be processing @@ -215,13 +215,13 @@ class DeletedContribsPager extends IndexPager { } // Let extensions add data - Hooks::run( 'DeletedContributionsLineEnding', array( $this, &$ret, $row, &$classes ) ); + Hooks::run( 'DeletedContributionsLineEnding', [ $this, &$ret, $row, &$classes ] ); - if ( $classes === array() && $ret === '' ) { + if ( $classes === [] && $ret === '' ) { wfDebug( "Dropping Special:DeletedContribution row that could not be formatted\n" ); $ret = "\n"; } else { - $ret = Html::rawElement( 'li', array( 'class' => $classes ), $ret ) . "\n"; + $ret = Html::rawElement( 'li', [ 'class' => $classes ], $ret ) . "\n"; } return $ret; @@ -242,7 +242,7 @@ class DeletedContribsPager extends IndexPager { function formatRevisionRow( $row ) { $page = Title::makeTitle( $row->ar_namespace, $row->ar_title ); - $rev = new Revision( array( + $rev = new Revision( [ 'title' => $page, 'id' => $row->ar_rev_id, 'comment' => $row->ar_comment, @@ -251,7 +251,7 @@ class DeletedContribsPager extends IndexPager { 'timestamp' => $row->ar_timestamp, 'minor_edit' => $row->ar_minor_edit, 'deleted' => $row->ar_deleted, - ) ); + ] ); $undelete = SpecialPage::getTitleFor( 'Undelete' ); @@ -259,11 +259,11 @@ class DeletedContribsPager extends IndexPager { $dellog = Linker::linkKnown( $logs, $this->messages['deletionlog'], - array(), - array( + [], + [ 'type' => 'delete', 'page' => $page->getPrefixedText() - ) + ] ); $reviewlink = Linker::linkKnown( @@ -277,12 +277,12 @@ class DeletedContribsPager extends IndexPager { $last = Linker::linkKnown( $undelete, $this->messages['diff'], - array(), - array( + [], + [ 'target' => $page->getPrefixedText(), 'timestamp' => $rev->getTimestamp(), 'diff' => 'prev' - ) + ] ); } else { $last = $this->messages['diff']; @@ -298,11 +298,11 @@ class DeletedContribsPager extends IndexPager { $link = Linker::linkKnown( $undelete, $date, - array( 'class' => 'mw-changeslist-date' ), - array( + [ 'class' => 'mw-changeslist-date' ], + [ 'target' => $page->getPrefixedText(), 'timestamp' => $rev->getTimestamp() - ) + ] ); } // Style deleted items @@ -313,7 +313,7 @@ class DeletedContribsPager extends IndexPager { $pagelink = Linker::link( $page, null, - array( 'class' => 'mw-changeslist-title' ) + [ 'class' => 'mw-changeslist-title' ] ); if ( $rev->isMinor() ) { @@ -330,9 +330,9 @@ class DeletedContribsPager extends IndexPager { $tools = Html::rawElement( 'span', - array( 'class' => 'mw-deletedcontribs-tools' ), + [ 'class' => 'mw-deletedcontribs-tools' ], $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( - array( $last, $dellog, $reviewlink ) ) )->escaped() + [ $last, $dellog, $reviewlink ] ) )->escaped() ); $separator = '. .'; @@ -384,7 +384,7 @@ class DeletedContributionsPage extends SpecialPage { $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'deletedcontributions-title' ) ); - $options = array(); + $options = []; if ( $par !== null ) { $target = $par; @@ -450,7 +450,7 @@ class DeletedContributionsPage extends SpecialPage { if ( !$this->msg( $message )->isDisabled() ) { $out->wrapWikiMsg( "", - array( $message, $target ) + [ $message, $target ] ); } } @@ -486,11 +486,11 @@ class DeletedContributionsPage extends SpecialPage { $tools[] = Linker::linkKnown( # Unblock link SpecialPage::getTitleFor( 'BlockList' ), $this->msg( 'unblocklink' )->escaped(), - array(), - array( + [], + [ 'action' => 'unblock', 'ip' => $nt->getDBkey() - ) + ] ); } else { # User is not blocked @@ -504,19 +504,19 @@ class DeletedContributionsPage extends SpecialPage { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'sp-contributions-blocklog' )->escaped(), - array(), - array( + [], + [ 'type' => 'block', 'page' => $nt->getPrefixedText() - ) + ] ); # Suppression log link (bug 59120) if ( $this->getUser()->isAllowed( 'suppressionlog' ) ) { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log', 'suppress' ), $this->msg( 'sp-contributions-suppresslog' )->escaped(), - array(), - array( 'offender' => $userObj->getName() ) + [], + [ 'offender' => $userObj->getName() ] ); } } @@ -531,8 +531,8 @@ class DeletedContributionsPage extends SpecialPage { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'sp-contributions-logs' )->escaped(), - array(), - array( 'user' => $nt->getText() ) + [], + [ 'user' => $nt->getText() ] ); # Link to contributions $tools[] = Linker::linkKnown( @@ -550,7 +550,7 @@ class DeletedContributionsPage extends SpecialPage { ); } - Hooks::run( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); + Hooks::run( 'ContributionsToolLinks', [ $id, $nt, &$tools ] ); $links = $this->getLanguage()->pipeList( $tools ); @@ -568,15 +568,15 @@ class DeletedContributionsPage extends SpecialPage { 'block', $nt, '', - array( + [ 'lim' => 1, 'showIfEmpty' => false, - 'msgKey' => array( + 'msgKey' => [ 'sp-contributions-blocked-notice', $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice' - ), + ], 'offset' => '' # don't use $this->getRequest() parameter offset - ) + ] ); } } @@ -609,10 +609,10 @@ class DeletedContributionsPage extends SpecialPage { $options['target'] = ''; } - $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ); + $f = Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ); foreach ( $options as $name => $value ) { - if ( in_array( $name, array( 'namespace', 'target', 'contribs' ) ) ) { + if ( in_array( $name, [ 'namespace', 'target', 'contribs' ] ) ) { continue; } $f .= "\t" . Html::hidden( $name, $value ) . "\n"; @@ -621,35 +621,35 @@ class DeletedContributionsPage extends SpecialPage { $this->getOutput()->addModules( 'mediawiki.userSuggest' ); $f .= Xml::openElement( 'fieldset' ); - $f .= Xml::element( 'legend', array(), $this->msg( 'sp-contributions-search' )->text() ); + $f .= Xml::element( 'legend', [], $this->msg( 'sp-contributions-search' )->text() ); $f .= Xml::tags( 'label', - array( 'for' => 'target' ), + [ 'for' => 'target' ], $this->msg( 'sp-contributions-username' )->parse() ) . ' '; $f .= Html::input( 'target', $options['target'], 'text', - array( + [ 'size' => '20', 'required' => '', - 'class' => array( + 'class' => [ 'mw-autocomplete-user', // used by mediawiki.userSuggest - ), - ) + ( $options['target'] ? array() : array( 'autofocus' ) ) + ], + ] + ( $options['target'] ? [] : [ 'autofocus' ] ) ) . ' '; $f .= Html::namespaceSelector( - array( + [ 'selected' => $options['namespace'], 'all' => '', 'label' => $this->msg( 'namespace' )->text() - ), - array( + ], + [ 'name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector', - ) + ] ) . ' '; $f .= Xml::submitButton( $this->msg( 'sp-contributions-submit' )->text() ); $f .= Xml::closeElement( 'fieldset' ); @@ -670,7 +670,7 @@ class DeletedContributionsPage extends SpecialPage { $user = User::newFromName( $search ); if ( !$user ) { // No prefix suggestion for invalid user - return array(); + return []; } // Autocomplete subpage as user list - public to allow caching return UserNamePrefixSearch::search( 'public', $search, $limit, $offset ); diff --git a/includes/specials/SpecialDiff.php b/includes/specials/SpecialDiff.php index 8b5d31a8fb..9804e777b1 100644 --- a/includes/specials/SpecialDiff.php +++ b/includes/specials/SpecialDiff.php @@ -39,7 +39,7 @@ class SpecialDiff extends RedirectSpecialPage { public function __construct() { parent::__construct( 'Diff' ); - $this->mAllowedRedirectParams = array(); + $this->mAllowedRedirectParams = []; } /** diff --git a/includes/specials/SpecialDoubleRedirects.php b/includes/specials/SpecialDoubleRedirects.php index c04582e5c4..7b00064997 100644 --- a/includes/specials/SpecialDoubleRedirects.php +++ b/includes/specials/SpecialDoubleRedirects.php @@ -51,14 +51,14 @@ class DoubleRedirectsPage extends QueryPage { function reallyGetQueryInfo( $namespace = null, $title = null ) { $limitToTitle = !( $namespace === null && $title === null ); $dbr = wfGetDB( DB_SLAVE ); - $retval = array( - 'tables' => array( + $retval = [ + 'tables' => [ 'ra' => 'redirect', 'rb' => 'redirect', 'pa' => 'page', 'pb' => 'page' - ), - 'fields' => array( + ], + 'fields' => [ 'namespace' => 'pa.page_namespace', 'title' => 'pa.page_title', 'value' => 'pa.page_title', @@ -71,8 +71,8 @@ class DoubleRedirectsPage extends QueryPage { 'nsc' => 'rb.rd_namespace', 'tc' => 'rb.rd_title', 'iwc' => 'rb.rd_interwiki', - ), - 'conds' => array( + ], + 'conds' => [ 'ra.rd_from = pa.page_id', // Filter out redirects where the target goes interwiki (bug 40353). @@ -88,8 +88,8 @@ class DoubleRedirectsPage extends QueryPage { 'pb.page_title = ra.rd_title', 'rb.rd_from = pb.page_id', - ) - ); + ] + ]; if ( $limitToTitle ) { $retval['conds']['pa.page_namespace'] = $namespace; @@ -104,7 +104,7 @@ class DoubleRedirectsPage extends QueryPage { } function getOrderFields() { - return array( 'ra.rd_namespace', 'ra.rd_title' ); + return [ 'ra.rd_namespace', 'ra.rd_title' ]; } /** @@ -138,7 +138,7 @@ class DoubleRedirectsPage extends QueryPage { } } if ( !$result ) { - return '' . Linker::link( $titleA, null, array(), array( 'redirect' => 'no' ) ) . ''; + return '' . Linker::link( $titleA, null, [], [ 'redirect' => 'no' ] ) . ''; } $titleB = Title::makeTitle( $result->nsb, $result->tb ); @@ -147,8 +147,8 @@ class DoubleRedirectsPage extends QueryPage { $linkA = Linker::linkKnown( $titleA, null, - array(), - array( 'redirect' => 'no' ) + [], + [ 'redirect' => 'no' ] ); // if the page is editable, add an edit link @@ -161,10 +161,10 @@ class DoubleRedirectsPage extends QueryPage { $edit = Linker::linkKnown( $titleA, $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(), - array(), - array( + [], + [ 'action' => 'edit' - ) + ] ); } else { $edit = ''; @@ -173,8 +173,8 @@ class DoubleRedirectsPage extends QueryPage { $linkB = Linker::linkKnown( $titleB, null, - array(), - array( 'redirect' => 'no' ) + [], + [ 'redirect' => 'no' ] ); $linkC = Linker::linkKnown( $titleC ); diff --git a/includes/specials/SpecialEditTags.php b/includes/specials/SpecialEditTags.php index 916ba6b7bb..252d07670e 100644 --- a/includes/specials/SpecialEditTags.php +++ b/includes/specials/SpecialEditTags.php @@ -75,8 +75,8 @@ class SpecialEditTags extends UnlistedSpecialPage { $this->setHeaders(); $this->outputHeader(); - $this->getOutput()->addModules( array( 'mediawiki.special.edittags', - 'mediawiki.special.edittags.styles' ) ); + $this->getOutput()->addModules( [ 'mediawiki.special.edittags', + 'mediawiki.special.edittags.styles' ] ); $this->submitClicked = $request->wasPosted() && $request->getBool( 'wpSubmit' ); @@ -87,7 +87,7 @@ class SpecialEditTags extends UnlistedSpecialPage { $this->ids = explode( ',', $ids ); } else { // Array input - $this->ids = array_keys( $request->getArray( 'ids', array() ) ); + $this->ids = array_keys( $request->getArray( 'ids', [] ) ); } $this->ids = array_unique( array_filter( $this->ids ) ); @@ -145,7 +145,7 @@ class SpecialEditTags extends UnlistedSpecialPage { 'tag', $this->targetObj, '', /* user */ - array( 'lim' => 25, 'conds' => array(), 'useMaster' => $this->wasSaved ) + [ 'lim' => 25, 'conds' => [], 'useMaster' => $this->wasSaved ] ); } @@ -158,23 +158,23 @@ class SpecialEditTags extends UnlistedSpecialPage { // Also set header tabs to be for the target. $this->getSkin()->setRelevantTitle( $this->targetObj ); - $links = array(); + $links = []; $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'viewpagelogs' )->escaped(), - array(), - array( + [], + [ 'page' => $this->targetObj->getPrefixedText(), 'hide_tag_log' => '0', - ) + ] ); if ( !$this->targetObj->isSpecialPage() ) { // Give a link to the page history $links[] = Linker::linkKnown( $this->targetObj, $this->msg( 'pagehist' )->escaped(), - array(), - array( 'action' => 'history' ) + [], + [ 'action' => 'history' ] ); } // Link to Special:Tags @@ -209,11 +209,11 @@ class SpecialEditTags extends UnlistedSpecialPage { $out = $this->getOutput(); // Messages: tags-edit-revision-selected, tags-edit-logentry-selected - $out->wrapWikiMsg( "$1", array( + $out->wrapWikiMsg( "$1", [ "tags-edit-{$this->typeName}-selected", $this->getLanguage()->formatNum( count( $this->ids ) ), $this->targetObj->getPrefixedText() - ) ); + ] ); $this->addHelpLink( 'Help:Tags' ); $out->addHTML( "