From 2898b317c49239f1a7c6b339cf56f62bbb559e06 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Nov 2013 11:49:55 +0100 Subject: [PATCH 1/3] Drop PHP 5.3 support --- .travis.yml | 1 - composer.json | 2 +- composer.lock | 33 +++++++++++-------- .../Setup/Requirements/SystemRequirements.php | 20 +---------- 4 files changed, 21 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe2367d976..2db6f4a00a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,6 @@ before_script: - echo "extension=imagick.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` php: - - 5.3 - 5.4 - 5.5 diff --git a/composer.json b/composer.json index 7fe9d435a6..eaec81f445 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "bin-dir" : "bin/" }, "require": { - "php" : ">=5.3.3", + "php" : ">=5.4", "alchemy/oauth2php" : "1.0.0", "alchemy/phlickr" : "0.2.7", "alchemy/task-manager" : "~1.0", diff --git a/composer.lock b/composer.lock index 8a3b5eae03..8ca6e4bc07 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "824ef5ec6611bd40f198e043c19d409e", + "hash": "9adc21c7c8c7337bf913c5c3f5ba65fb", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -1635,16 +1635,16 @@ }, { "name": "monolog/monolog", - "version": "1.6.0", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "f72392d0e6eb855118f5a84e89ac2d257c704abd" + "reference": "6225b22de9dcf36546be3a0b2fa8e3d986153f57" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f72392d0e6eb855118f5a84e89ac2d257c704abd", - "reference": "f72392d0e6eb855118f5a84e89ac2d257c704abd", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/6225b22de9dcf36546be3a0b2fa8e3d986153f57", + "reference": "6225b22de9dcf36546be3a0b2fa8e3d986153f57", "shasum": "" }, "require": { @@ -1652,21 +1652,26 @@ "psr/log": "~1.0" }, "require-dev": { + "aws/aws-sdk-php": "~2.4.8", "doctrine/couchdb": "dev-master", "mlehner/gelf-php": "1.0.*", - "raven/raven": "0.5.*" + "phpunit/phpunit": "~3.7.0", + "raven/raven": "0.5.*", + "ruflin/elastica": "0.90.*" }, "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", "doctrine/couchdb": "Allow sending log messages to a CouchDB server", "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", "ext-mongo": "Allow sending log messages to a MongoDB server", "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server", - "raven/raven": "Allow sending log messages to a Sentry server" + "raven/raven": "Allow sending log messages to a Sentry server", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -1693,7 +1698,7 @@ "logging", "psr-3" ], - "time": "2013-07-28 22:38:30" + "time": "2013-11-14 19:48:31" }, { "name": "mrclay/minify", @@ -2821,12 +2826,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "b76ac2f865bae2e2ca87302935f5d9a458f1401f" + "reference": "4e9332b6b66d52750142e5b32cc754620f875fe7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/b76ac2f865bae2e2ca87302935f5d9a458f1401f", - "reference": "b76ac2f865bae2e2ca87302935f5d9a458f1401f", + "url": "https://api.github.com/repos/symfony/symfony/zipball/4e9332b6b66d52750142e5b32cc754620f875fe7", + "reference": "4e9332b6b66d52750142e5b32cc754620f875fe7", "shasum": "" }, "require": { @@ -2926,7 +2931,7 @@ "keywords": [ "framework" ], - "time": "2013-11-09 16:01:15" + "time": "2013-11-17 08:45:14" }, { "name": "themattharris/tmhoauth", @@ -4103,7 +4108,7 @@ "behat/gherkin": 20 }, "platform": { - "php": ">=5.3.3" + "php": ">=5.4" }, "platform-dev": [ diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php index 44584c2c39..e7c84a4720 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php @@ -15,7 +15,7 @@ use Alchemy\Phrasea\Setup\RequirementCollection; class SystemRequirements extends RequirementCollection implements RequirementInterface { - const REQUIRED_PHP_VERSION = '5.3.3'; + const REQUIRED_PHP_VERSION = '5.4.0'; public function __construct() { @@ -34,12 +34,6 @@ class SystemRequirements extends RequirementCollection implements RequirementInt sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) ); - $this->addRequirement( - version_compare($installedPhpVersion, '5.3.16', '!='), - 'PHP version must not be 5.3.16 as Phraseanet won\'t work properly with it', - 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' - ); - $this->addRequirement( is_dir($baseDir.'/vendor/composer'), 'Vendor libraries must be installed', @@ -152,18 +146,6 @@ class SystemRequirements extends RequirementCollection implements RequirementInt 'Install the PCRE extension (version 8.0+).' ); - $this->addRecommendation( - version_compare($installedPhpVersion, '5.3.4', '>='), - 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', - 'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.3.8', '>='), - 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', - 'Install PHP 5.3.8 or newer if your project uses annotations.' - ); - $this->addRecommendation( version_compare($installedPhpVersion, '5.4.0', '!='), 'You should not use PHP 5.4.0 due to the PHP bug #61453', From 56b373ee6ec0700f3420ac4af4480d0c7dd74914 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Nov 2013 11:58:12 +0100 Subject: [PATCH 2/3] Use short array declaration --- bin/developer | 8 +- builder.php | 10 +- functionnal-tests/api/dailymotion.php | 6 +- launchpadToLocales.php | 4 +- lib/Alchemy/Phrasea/Application.php | 54 +- lib/Alchemy/Phrasea/Application/Api.php | 16 +- lib/Alchemy/Phrasea/Application/Root.php | 4 +- .../Phrasea/Authentication/ACLProvider.php | 4 +- .../Phrasea/Authentication/AccountCreator.php | 4 +- .../Phrasea/Authentication/Authenticator.php | 2 +- .../Phrasea/Authentication/Context.php | 2 +- .../PersistentCookie/Manager.php | 2 +- .../Phrasea/NativeAuthentication.php | 8 +- .../Provider/AbstractProvider.php | 2 +- .../Authentication/Provider/Facebook.php | 6 +- .../Authentication/Provider/Factory.php | 2 +- .../Authentication/Provider/Github.php | 12 +- .../Authentication/Provider/GooglePlus.php | 10 +- .../Authentication/Provider/Linkedin.php | 12 +- .../Provider/Token/Identity.php | 10 +- .../Authentication/Provider/Twitter.php | 14 +- .../Authentication/Provider/Viadeo.php | 12 +- .../Authentication/ProvidersCollection.php | 2 +- .../Authentication/SuggestionFinder.php | 2 +- .../Phrasea/Border/Attribute/MetaField.php | 4 +- .../Border/Checker/AbstractChecker.php | 10 +- .../Phrasea/Border/Checker/Filename.php | 2 +- lib/Alchemy/Phrasea/Border/File.php | 6 +- lib/Alchemy/Phrasea/Border/Manager.php | 26 +- lib/Alchemy/Phrasea/Border/MetaFieldsBag.php | 12 +- lib/Alchemy/Phrasea/Border/MetadataBag.php | 12 +- lib/Alchemy/Phrasea/Border/Visa.php | 2 +- .../Phrasea/Cache/ConnectionFactory.php | 14 +- lib/Alchemy/Phrasea/Cache/Manager.php | 10 +- lib/Alchemy/Phrasea/Cache/RedisCache.php | 4 +- .../Phrasea/Command/BuildMissingSubdefs.php | 4 +- lib/Alchemy/Phrasea/Command/CheckConfig.php | 4 +- .../Phrasea/Command/CreateCollection.php | 2 +- .../Developer/AbstractRoutesDumper.php | 6 +- .../Command/Developer/BowerInstall.php | 2 +- .../Command/Developer/ComposerInstall.php | 6 +- .../Phrasea/Command/Developer/Uninstaller.php | 8 +- .../Command/Developer/Utils/BowerDriver.php | 4 +- .../Developer/Utils/ComposerDriver.php | 4 +- .../Command/Developer/Utils/GruntDriver.php | 4 +- .../Command/Developer/Utils/RecessDriver.php | 4 +- .../Developer/Utils/UglifyJsDriver.php | 4 +- .../Command/Plugin/AbstractPluginCommand.php | 2 +- lib/Alchemy/Phrasea/Command/RecordAdd.php | 2 +- .../Phrasea/Command/RescanTechnicalDatas.php | 2 +- .../Command/Setup/CheckEnvironment.php | 4 +- lib/Alchemy/Phrasea/Command/Setup/Install.php | 18 +- .../Setup/XSendFileMappingGenerator.php | 16 +- .../Phrasea/Command/Task/SchedulerRun.php | 2 +- lib/Alchemy/Phrasea/Command/Task/TaskList.php | 6 +- .../Phrasea/Command/Upgrade/Step31.php | 4 +- .../Phrasea/Command/Upgrade/Step35.php | 14 +- .../Phrasea/Command/UpgradeDBDatas.php | 10 +- .../Phrasea/Controller/Admin/Collection.php | 222 ++++---- .../Controller/Admin/ConnectedUsers.php | 22 +- .../Phrasea/Controller/Admin/Dashboard.php | 14 +- .../Phrasea/Controller/Admin/Databox.php | 160 +++--- .../Phrasea/Controller/Admin/Databoxes.php | 62 +-- .../Phrasea/Controller/Admin/Fields.php | 40 +- .../Phrasea/Controller/Admin/Publications.php | 14 +- lib/Alchemy/Phrasea/Controller/Admin/Root.php | 108 ++-- .../Phrasea/Controller/Admin/Setup.php | 12 +- .../Phrasea/Controller/Admin/Subdefs.php | 18 +- .../Phrasea/Controller/Admin/TaskManager.php | 30 +- .../Phrasea/Controller/Admin/Users.php | 156 +++--- lib/Alchemy/Phrasea/Controller/Api/Oauth2.php | 12 +- lib/Alchemy/Phrasea/Controller/Api/V1.php | 10 +- .../Phrasea/Controller/Client/Baskets.php | 20 +- .../Phrasea/Controller/Client/Root.php | 76 +-- lib/Alchemy/Phrasea/Controller/Lightbox.php | 88 ++-- lib/Alchemy/Phrasea/Controller/Minifier.php | 2 +- lib/Alchemy/Phrasea/Controller/Permalink.php | 12 +- .../Controller/Prod/BasketController.php | 48 +- .../Phrasea/Controller/Prod/Bridge.php | 58 +-- .../Phrasea/Controller/Prod/DoDownload.php | 18 +- .../Phrasea/Controller/Prod/Download.php | 8 +- lib/Alchemy/Phrasea/Controller/Prod/Edit.php | 80 +-- .../Phrasea/Controller/Prod/Export.php | 42 +- lib/Alchemy/Phrasea/Controller/Prod/Feed.php | 42 +- .../Phrasea/Controller/Prod/Language.php | 2 +- .../Phrasea/Controller/Prod/Lazaret.php | 26 +- .../Controller/Prod/MoveCollection.php | 22 +- lib/Alchemy/Phrasea/Controller/Prod/Order.php | 60 +-- .../Phrasea/Controller/Prod/Printer.php | 4 +- .../Phrasea/Controller/Prod/Property.php | 44 +- lib/Alchemy/Phrasea/Controller/Prod/Push.php | 80 +-- lib/Alchemy/Phrasea/Controller/Prod/Query.php | 18 +- .../Phrasea/Controller/Prod/Records.php | 50 +- lib/Alchemy/Phrasea/Controller/Prod/Root.php | 18 +- lib/Alchemy/Phrasea/Controller/Prod/Share.php | 4 +- lib/Alchemy/Phrasea/Controller/Prod/Story.php | 46 +- lib/Alchemy/Phrasea/Controller/Prod/TOU.php | 12 +- lib/Alchemy/Phrasea/Controller/Prod/Tools.php | 28 +- .../Phrasea/Controller/Prod/Tooltip.php | 20 +- .../Phrasea/Controller/Prod/Upload.php | 34 +- .../Phrasea/Controller/Prod/UsrLists.php | 142 +++--- .../Phrasea/Controller/Prod/WorkZone.php | 20 +- .../Phrasea/Controller/RecordsRequest.php | 14 +- .../Phrasea/Controller/Report/Activity.php | 250 ++++----- .../Phrasea/Controller/Report/Export.php | 4 +- .../Controller/Report/Informations.php | 202 ++++---- .../Phrasea/Controller/Report/Root.php | 226 ++++----- .../Phrasea/Controller/Root/Account.php | 36 +- .../Phrasea/Controller/Root/Developers.php | 26 +- lib/Alchemy/Phrasea/Controller/Root/Login.php | 84 ++-- .../Phrasea/Controller/Root/RSSFeeds.php | 2 +- lib/Alchemy/Phrasea/Controller/Root/Root.php | 2 +- .../Phrasea/Controller/Root/Session.php | 16 +- lib/Alchemy/Phrasea/Controller/Setup.php | 46 +- .../Controller/Thesaurus/Thesaurus.php | 324 ++++++------ .../Phrasea/Controller/Thesaurus/Xmlhttp.php | 180 +++---- .../Phrasea/Controller/User/Notifications.php | 4 +- .../Phrasea/Controller/User/Preferences.php | 4 +- .../Controller/Utils/ConnectionTest.php | 8 +- .../Phrasea/Controller/Utils/PathFileTest.php | 6 +- .../CLIProvider/CLIDriversServiceProvider.php | 12 +- .../LessBuilderServiceProvider.php | 10 +- .../CLIProvider/PluginServiceProvider.php | 4 +- .../TaskManagerServiceProvider.php | 4 +- .../Core/Configuration/Configuration.php | 8 +- .../ApiExceptionHandlerSubscriber.php | 8 +- .../Subscriber/ApiOauth2ErrorsSubscriber.php | 10 +- .../Subscriber/BridgeExceptionSubscriber.php | 28 +- .../Subscriber/CookiesDisablerSubscriber.php | 8 +- .../Event/Subscriber/DebuggerSubscriber.php | 16 +- .../Event/Subscriber/FirewallSubscriber.php | 10 +- .../Subscriber/JsonRequestSubscriber.php | 8 +- .../Event/Subscriber/LogoutSubscriber.php | 4 +- .../Subscriber/MaintenanceSubscriber.php | 8 +- .../Subscriber/PersistentCookieSubscriber.php | 6 +- .../PhraseaExceptionHandlerSubscriber.php | 2 +- .../Subscriber/PhraseaLocaleSubscriber.php | 26 +- .../Subscriber/TrustedProxySubscriber.php | 8 +- .../Event/Subscriber/XSendFileSubscriber.php | 6 +- .../Provider/BorderManagerServiceProvider.php | 8 +- .../Core/Provider/LocaleServiceProvider.php | 4 +- .../Core/Provider/ORMServiceProvider.php | 6 +- .../Core/Provider/PluginServiceProvider.php | 2 +- .../Provider/RegistrationServiceProvider.php | 102 ++-- .../Core/Provider/TasksServiceProvider.php | 10 +- lib/Alchemy/Phrasea/Feed/Aggregate.php | 10 +- .../Phrasea/Feed/Formatter/AtomFormatter.php | 2 +- .../Feed/Formatter/CoolirisFormatter.php | 4 +- .../Feed/Formatter/FeedFormatterAbstract.php | 2 +- .../Phrasea/Feed/Formatter/RssFormatter.php | 2 +- .../Feed/Link/AggregateLinkGenerator.php | 14 +- .../Phrasea/Feed/Link/FeedLinkGenerator.php | 18 +- .../Feed/Link/LinkGeneratorCollection.php | 2 +- .../Form/Login/PhraseaAuthenticationForm.php | 28 +- .../Form/Login/PhraseaForgotPasswordForm.php | 8 +- .../Form/Login/PhraseaRecoverPasswordForm.php | 22 +- .../Form/Login/PhraseaRegisterForm.php | 56 +-- .../Form/Login/PhraseaRenewPasswordForm.php | 22 +- lib/Alchemy/Phrasea/Form/TaskForm.php | 30 +- lib/Alchemy/Phrasea/Helper/Prod.php | 32 +- lib/Alchemy/Phrasea/Helper/Record/Helper.php | 6 +- lib/Alchemy/Phrasea/Helper/Record/Push.php | 2 +- lib/Alchemy/Phrasea/Helper/User/Edit.php | 88 ++-- lib/Alchemy/Phrasea/Helper/User/Manage.php | 22 +- lib/Alchemy/Phrasea/Helper/WorkZone.php | 4 +- .../Phrasea/Http/ServeFileResponseFactory.php | 2 +- .../Http/XSendFile/AbstractXSendFileMode.php | 2 +- .../Phrasea/Http/XSendFile/ApacheMode.php | 10 +- .../Phrasea/Http/XSendFile/NginxMode.php | 12 +- .../Http/XSendFile/XSendFileFactory.php | 2 +- lib/Alchemy/Phrasea/Media/Subdef/Audio.php | 6 +- .../Phrasea/Media/Subdef/FlexPaper.php | 2 +- lib/Alchemy/Phrasea/Media/Subdef/Image.php | 2 +- .../Phrasea/Media/Subdef/OptionType/Multi.php | 4 +- lib/Alchemy/Phrasea/Media/Subdef/Provider.php | 2 +- lib/Alchemy/Phrasea/Media/Subdef/Video.php | 6 +- lib/Alchemy/Phrasea/Metadata/TagProvider.php | 88 ++-- .../Phrasea/Model/Entities/LazaretFile.php | 2 +- lib/Alchemy/Phrasea/Model/Entities/Task.php | 2 +- lib/Alchemy/Phrasea/Model/Entities/User.php | 10 +- .../Phrasea/Model/Entities/UsrListOwner.php | 2 +- .../Phrasea/Model/Manager/UserManager.php | 16 +- .../Model/Manipulator/ACLManipulator.php | 10 +- .../Model/Manipulator/UserManipulator.php | 2 +- .../Phrasea/Model/MonologSQLLogger.php | 2 +- .../Repositories/AuthFailureRepository.php | 6 +- .../Repositories/BasketElementRepository.php | 20 +- .../Model/Repositories/BasketRepository.php | 36 +- .../Model/Repositories/FeedItemRepository.php | 4 +- .../Repositories/FtpExportRepository.php | 2 +- .../Model/Repositories/OrderRepository.php | 4 +- .../Model/Repositories/StoryWZRepository.php | 16 +- .../Model/Repositories/UserRepository.php | 2 +- .../UsrAuthProviderRepository.php | 4 +- .../Repositories/UsrListEntryRepository.php | 8 +- .../Repositories/UsrListOwnerRepository.php | 4 +- .../Model/Repositories/UsrListRepository.php | 8 +- .../Phrasea/Notification/Deliverer.php | 2 +- .../Notification/Mail/AbstractMail.php | 4 +- .../Mail/MailInfoSomebodyAutoregistered.php | 2 +- .../Mail/MailInfoUserRegistered.php | 2 +- lib/Alchemy/Phrasea/Out/Module/PDF.php | 6 +- .../Exception/JsonValidationException.php | 2 +- .../Plugin/Management/ComposerInstaller.php | 6 +- .../Phrasea/Plugin/Schema/Manifest.php | 6 +- .../Plugin/Schema/ManifestValidator.php | 4 +- .../Phrasea/Plugin/Schema/PluginValidator.php | 2 +- .../AbstractConfigurationPanel.php | 2 +- .../Phrasea/ConfigurationPanel.php | 14 +- .../SearchEngine/Phrasea/PhraseaEngine.php | 62 +-- .../Phrasea/PhraseaEngineQueryParser.php | 260 +++++----- .../SearchEngine/SearchEngineInterface.php | 2 +- .../SearchEngine/SearchEngineLogger.php | 4 +- .../SearchEngine/SearchEngineOptions.php | 40 +- .../SearchEngine/SearchEngineSuggestion.php | 4 +- .../SphinxSearch/ConfigurationPanel.php | 26 +- .../SphinxSearch/SphinxSearchEngine.php | 110 ++-- lib/Alchemy/Phrasea/Security/Firewall.php | 14 +- .../Phrasea/Setup/ConfigurationTester.php | 10 +- lib/Alchemy/Phrasea/Setup/Installer.php | 16 +- .../Phrasea/Setup/Probe/BinariesProbe.php | 4 +- .../Phrasea/Setup/Probe/FilesystemProbe.php | 6 +- .../Phrasea/Setup/Probe/PhraseaProbe.php | 4 +- .../Phrasea/Setup/RequirementCollection.php | 12 +- .../Requirements/BinariesRequirements.php | 2 +- .../Requirements/FilesystemRequirements.php | 4 +- .../Requirements/PhraseaRequirements.php | 2 +- .../Setup/Requirements/SystemRequirements.php | 2 +- .../Phrasea/Setup/Version/MailChecker.php | 8 +- .../Setup/Version/Migration/Migration31.php | 12 +- .../Setup/Version/Migration/Migration35.php | 8 +- .../Setup/Version/Migration/Migration38.php | 8 +- .../PreSchemaUpgradeCollection.php | 2 +- .../TaskManager/Editor/AbstractEditor.php | 2 +- .../TaskManager/Editor/ArchiveEditor.php | 4 +- .../TaskManager/Editor/DefaultEditor.php | 2 +- .../Phrasea/TaskManager/Editor/FtpEditor.php | 4 +- .../TaskManager/Editor/FtpPullEditor.php | 4 +- .../Editor/PhraseanetIndexerEditor.php | 4 +- .../TaskManager/Editor/RecordMoverEditor.php | 4 +- .../TaskManager/Editor/SubdefsEditor.php | 4 +- .../Editor/WriteMetadataEditor.php | 4 +- .../Event/FinishedJobRemoverSubscriber.php | 6 +- .../PhraseanetIndexerStopperSubscriber.php | 6 +- .../Phrasea/TaskManager/Job/ArchiveJob.php | 40 +- .../Phrasea/TaskManager/Job/BridgeJob.php | 12 +- .../Phrasea/TaskManager/Job/FtpJob.php | 12 +- .../Phrasea/TaskManager/Job/FtpPullJob.php | 4 +- .../TaskManager/Job/PhraseanetIndexerJob.php | 2 +- .../TaskManager/Job/RecordMoverJob.php | 54 +- .../Phrasea/TaskManager/Job/SubdefsJob.php | 4 +- .../TaskManager/Job/WriteMetadataJob.php | 8 +- .../Phrasea/TaskManager/LiveInformation.php | 10 +- lib/Alchemy/Phrasea/TaskManager/Notifier.php | 2 +- lib/Alchemy/Phrasea/TaskManager/TaskList.php | 4 +- .../Phrasea/TaskManager/TaskManagerStatus.php | 4 +- lib/Alchemy/Phrasea/Twig/BytesConverter.php | 8 +- lib/Alchemy/Phrasea/Twig/Camelize.php | 4 +- lib/Alchemy/Phrasea/Twig/JSUniqueID.php | 6 +- .../Phrasea/Utilities/ComposerSetup.php | 2 +- .../Phrasea/Utilities/Less/Compiler.php | 2 +- .../ControlProvider/UserProvider.php | 2 +- lib/Alchemy/Phrasea/Vocabulary/Controller.php | 4 +- lib/classes/ACL.php | 156 +++--- lib/classes/API/OAuth2/Account.php | 16 +- lib/classes/API/OAuth2/Adapter.php | 94 ++-- lib/classes/API/OAuth2/Application.php | 68 +-- lib/classes/API/OAuth2/AuthCode.php | 16 +- lib/classes/API/OAuth2/Form/DevAppDesktop.php | 4 +- .../API/OAuth2/Form/DevAppInternet.php | 4 +- lib/classes/API/OAuth2/RefreshToken.php | 12 +- lib/classes/API/OAuth2/Token.php | 30 +- lib/classes/API/V1/Log.php | 42 +- lib/classes/API/V1/Timer.php | 4 +- lib/classes/API/V1/adapter.php | 420 ++++++++-------- lib/classes/API/V1/result.php | 14 +- lib/classes/Bridge/Account.php | 28 +- lib/classes/Bridge/AccountSettings.php | 8 +- lib/classes/Bridge/Api.php | 20 +- lib/classes/Bridge/Api/Abstract.php | 2 +- lib/classes/Bridge/Api/AbstractCollection.php | 2 +- lib/classes/Bridge/Api/Auth/Flickr.php | 10 +- lib/classes/Bridge/Api/Auth/Interface.php | 2 +- lib/classes/Bridge/Api/Auth/OAuth2.php | 24 +- lib/classes/Bridge/Api/Auth/Youtube.php | 6 +- lib/classes/Bridge/Api/Dailymotion.php | 102 ++-- .../Bridge/Api/Dailymotion/Element.php | 2 +- lib/classes/Bridge/Api/Flickr.php | 76 +-- lib/classes/Bridge/Api/Flickr/Element.php | 4 +- lib/classes/Bridge/Api/Interface.php | 2 +- lib/classes/Bridge/Api/Youtube.php | 60 +-- lib/classes/Bridge/Element.php | 38 +- lib/classes/Browser.php | 12 +- lib/classes/DailymotionWithoutOauth2.php | 13 +- lib/classes/Session/Logger.php | 32 +- lib/classes/Setup/Upgrade.php | 12 +- lib/classes/User/Adapter.php | 130 ++--- lib/classes/User/Query.php | 42 +- lib/classes/appbox.php | 32 +- lib/classes/appbox/register.php | 8 +- lib/classes/base.php | 82 +-- lib/classes/cache/databox.php | 20 +- lib/classes/caption/Field/Value.php | 38 +- lib/classes/caption/field.php | 32 +- lib/classes/caption/record.php | 28 +- lib/classes/collection.php | 80 +-- lib/classes/connection.php | 12 +- lib/classes/connection/abstract.php | 4 +- lib/classes/connection/interface.php | 2 +- lib/classes/connection/pdo.php | 4 +- .../connection/pdoStatementDebugger.php | 8 +- lib/classes/databox.php | 124 ++--- lib/classes/databox/cgu.php | 4 +- lib/classes/databox/descriptionStructure.php | 4 +- lib/classes/databox/field.php | 32 +- lib/classes/databox/status.php | 34 +- lib/classes/databox/subdef.php | 24 +- lib/classes/databox/subdefsStructure.php | 18 +- lib/classes/deprecated/countries.php | 8 +- lib/classes/deprecated/inscript.api.php | 6 +- lib/classes/eventsmanager/broker.php | 66 +-- lib/classes/eventsmanager/event/test.php | 2 +- lib/classes/eventsmanager/eventAbstract.php | 2 +- .../eventsmanager/notify/autoregister.php | 18 +- .../eventsmanager/notify/bridgeuploadfail.php | 12 +- .../eventsmanager/notify/downloadmailfail.php | 10 +- lib/classes/eventsmanager/notify/feed.php | 20 +- lib/classes/eventsmanager/notify/order.php | 22 +- .../eventsmanager/notify/orderdeliver.php | 18 +- .../notify/ordernotdelivered.php | 12 +- lib/classes/eventsmanager/notify/push.php | 12 +- lib/classes/eventsmanager/notify/register.php | 20 +- .../eventsmanager/notify/uploadquarantine.php | 10 +- lib/classes/eventsmanager/notify/validate.php | 14 +- .../eventsmanager/notify/validationdone.php | 14 +- .../notify/validationreminder.php | 12 +- lib/classes/eventsmanager/notifyAbstract.php | 2 +- lib/classes/format.php | 8 +- lib/classes/ftpclient.php | 8 +- lib/classes/media/Permalink/Adapter.php | 30 +- lib/classes/media/subdef.php | 38 +- lib/classes/module/console/checkExtension.php | 18 +- lib/classes/module/console/fieldsMerge.php | 12 +- lib/classes/module/console/fieldsRename.php | 2 +- .../console/sphinxGenerateSuggestion.php | 4 +- .../module/console/systemClearCache.php | 4 +- lib/classes/module/console/systemExport.php | 10 +- .../module/console/systemMailCheck.php | 4 +- .../console/systemTemplateGenerator.php | 8 +- lib/classes/module/console/systemUpgrade.php | 2 +- lib/classes/module/report.php | 52 +- lib/classes/module/report/activity.php | 92 ++-- lib/classes/module/report/add.php | 8 +- lib/classes/module/report/connexion.php | 12 +- lib/classes/module/report/dashboard.php | 22 +- lib/classes/module/report/dashboard/feed.php | 6 +- lib/classes/module/report/dashboard/group.php | 4 +- lib/classes/module/report/dashboard/merge.php | 4 +- lib/classes/module/report/dashboard/sort.php | 12 +- lib/classes/module/report/download.php | 20 +- lib/classes/module/report/edit.php | 8 +- lib/classes/module/report/filter.php | 14 +- lib/classes/module/report/nav.php | 50 +- lib/classes/module/report/push.php | 8 +- lib/classes/module/report/question.php | 8 +- lib/classes/module/report/sent.php | 8 +- lib/classes/module/report/sql.php | 2 +- lib/classes/module/report/sqlaction.php | 18 +- lib/classes/module/report/sqlconnexion.php | 10 +- lib/classes/module/report/sqldownload.php | 16 +- lib/classes/module/report/sqlfilter.php | 46 +- lib/classes/module/report/sqlquestion.php | 10 +- lib/classes/module/report/validate.php | 8 +- lib/classes/p4string.php | 24 +- lib/classes/patch/320alpha1a.php | 2 +- lib/classes/patch/320alpha1b.php | 2 +- lib/classes/patch/320alpha2a.php | 8 +- lib/classes/patch/320alpha3a.php | 2 +- lib/classes/patch/320alpha4a.php | 6 +- lib/classes/patch/320alpha4b.php | 10 +- lib/classes/patch/320alpha5a.php | 6 +- lib/classes/patch/320alpha6a.php | 2 +- lib/classes/patch/320alpha8a.php | 2 +- lib/classes/patch/360alpha1a.php | 24 +- lib/classes/patch/360alpha1b.php | 2 +- lib/classes/patch/360alpha2a.php | 2 +- lib/classes/patch/360alpha2b.php | 10 +- lib/classes/patch/361alpha1a.php | 4 +- lib/classes/patch/370alpha1a.php | 4 +- lib/classes/patch/370alpha3a.php | 2 +- lib/classes/patch/370alpha4a.php | 10 +- lib/classes/patch/370alpha5a.php | 10 +- lib/classes/patch/370alpha6a.php | 42 +- lib/classes/patch/370alpha7a.php | 2 +- lib/classes/patch/370alpha8a.php | 12 +- lib/classes/patch/370alpha9a.php | 2 +- lib/classes/patch/3715alpha1a.php | 2 +- lib/classes/patch/371alpha1a.php | 2 +- lib/classes/patch/373alpha1a.php | 20 +- lib/classes/patch/379alpha1a.php | 2 +- lib/classes/patch/380alpha10a.php | 6 +- lib/classes/patch/380alpha11a.php | 2 +- lib/classes/patch/380alpha13a.php | 12 +- lib/classes/patch/380alpha14a.php | 2 +- lib/classes/patch/380alpha15a.php | 2 +- lib/classes/patch/380alpha16a.php | 12 +- lib/classes/patch/380alpha17a.php | 2 +- lib/classes/patch/380alpha18a.php | 2 +- lib/classes/patch/380alpha2a.php | 2 +- lib/classes/patch/380alpha2b.php | 2 +- lib/classes/patch/380alpha3a.php | 2 +- lib/classes/patch/380alpha3b.php | 2 +- lib/classes/patch/380alpha4a.php | 2 +- lib/classes/patch/380alpha6a.php | 2 +- lib/classes/patch/380alpha8a.php | 2 +- lib/classes/patch/380alpha9a.php | 2 +- lib/classes/patch/381alpha1a.php | 12 +- lib/classes/patch/381alpha1b.php | 2 +- lib/classes/patch/381alpha2a.php | 2 +- lib/classes/patch/381alpha3a.php | 4 +- lib/classes/patch/381alpha4a.php | 4 +- lib/classes/patch/390alpha1a.php | 2 +- lib/classes/patch/390alpha1b.php | 6 +- lib/classes/patch/390alpha2a.php | 2 +- lib/classes/patch/390alpha3a.php | 2 +- lib/classes/patch/390alpha4a.php | 2 +- lib/classes/patch/390alpha5a.php | 2 +- lib/classes/patch/390alpha6a.php | 4 +- lib/classes/patch/390alpha7a.php | 10 +- lib/classes/patch/390alpha8a.php | 2 +- lib/classes/patchthesaurus/100.php | 4 +- lib/classes/patchthesaurus/202.php | 2 +- lib/classes/patchthesaurus/203.php | 8 +- lib/classes/patchthesaurus/204.php | 8 +- lib/classes/phrasea.php | 26 +- lib/classes/phraseadate.php | 14 +- lib/classes/queries.php | 8 +- lib/classes/random.php | 22 +- lib/classes/record/adapter.php | 146 +++--- lib/classes/record/exportElement.php | 46 +- lib/classes/record/preview.php | 34 +- lib/classes/recordutils/image.php | 50 +- lib/classes/registry.php | 8 +- lib/classes/set/abstract.php | 4 +- lib/classes/set/export.php | 94 ++-- lib/classes/set/selection.php | 10 +- lib/classes/setup.php | 58 +-- lib/classes/thesaurus.php | 2 +- lib/classes/thesaurus/xpath.php | 2 +- lib/classes/unicode.php | 22 +- lib/classes/uuid.php | 4 +- .../Basket/LoadOneBasketEnv.php | 4 +- lib/conf.d/_GV_template.inc | 474 +++++++++--------- lib/conf.d/minifyGroupsConfig.php | 48 +- lib/conf.d/plugins/twig-paths.php | 3 +- localesToLaunchPad.php | 4 +- .../Tests/Phrasea/Application/ApiAbstract.php | 360 ++++++------- .../Phrasea/Application/ApiJSONPTest.php | 2 +- .../Tests/Phrasea/Application/ApiJsonTest.php | 2 +- .../Tests/Phrasea/Application/ApiYamlTest.php | 2 +- .../Phrasea/Application/ConsoleAPITest.php | 10 +- .../Phrasea/Application/LightboxTest.php | 4 +- .../Tests/Phrasea/Application/OAuth2Test.php | 24 +- .../Phrasea/Application/OverviewTest.php | 30 +- .../Application/RootApplicationTest.php | 10 +- .../Alchemy/Tests/Phrasea/ApplicationTest.php | 36 +- .../Authentication/AccountCreatorTest.php | 22 +- .../Authentication/AuthenticatorTest.php | 6 +- .../Phrasea/Authentication/ManagerTest.php | 2 +- .../PersistentCookie/ManagerTest.php | 6 +- .../Phrasea/FailureManagerTest.php | 8 +- .../Phrasea/NativeAuthenticationTest.php | 36 +- .../Phrasea/OldPasswordEncoderTest.php | 12 +- .../Phrasea/PasswordEncoderTest.php | 22 +- .../Authentication/Provider/FacebookTest.php | 32 +- .../Authentication/Provider/FactoryTest.php | 14 +- .../Authentication/Provider/GithubTest.php | 30 +- .../Provider/GooglePlusTest.php | 44 +- .../Authentication/Provider/LinkedinTest.php | 48 +- .../Provider/ProviderTestCase.php | 2 +- .../Provider/Token/IdentityTest.php | 14 +- .../Provider/Token/TokenTest.php | 2 +- .../Authentication/Provider/TwitterTest.php | 74 +-- .../Authentication/Provider/ViadeoTest.php | 42 +- .../ProvidersCollectionTest.php | 2 +- .../Authentication/SuggestionFinderTest.php | 2 +- .../Phrasea/Border/Attribute/FactoryTest.php | 2 +- .../Border/Attribute/MetaFieldTest.php | 8 +- .../Phrasea/Border/Attribute/StatusTest.php | 26 +- .../Border/Checker/AbstractCheckerTest.php | 34 +- .../Phrasea/Border/Checker/ColorspaceTest.php | 4 +- .../Phrasea/Border/Checker/DimensionTest.php | 38 +- .../Phrasea/Border/Checker/ExtensionTest.php | 10 +- .../Phrasea/Border/Checker/FilenameTest.php | 6 +- .../Phrasea/Border/Checker/MediaTypeTest.php | 6 +- .../Phrasea/Border/Checker/ResponseTest.php | 2 +- .../Phrasea/Border/Checker/Sha256Test.php | 4 +- .../Tests/Phrasea/Border/Checker/UUIDTest.php | 2 +- .../Alchemy/Tests/Phrasea/Border/FileTest.php | 8 +- .../Tests/Phrasea/Border/ManagerTest.php | 76 +-- .../Phrasea/Border/MetaFieldsBagTest.php | 20 +- .../Tests/Phrasea/Border/MetadataBagTest.php | 18 +- .../Alchemy/Tests/Phrasea/Border/VisaTest.php | 4 +- .../Phrasea/Cache/ConnectionFactoryTest.php | 6 +- .../Tests/Phrasea/Cache/FactoryTest.php | 34 +- .../Tests/Phrasea/Cache/ManagerTest.php | 22 +- .../Command/Developper/BowerInstallTest.php | 2 +- .../Developper/ComposerInstallTest.php | 2 +- .../Command/Developper/InstallAllTest.php | 6 +- .../Developper/Utils/BowerDriverTest.php | 2 +- .../Developper/Utils/ComposerDriverTest.php | 2 +- .../Developper/Utils/GruntDriverTest.php | 2 +- .../Developper/Utils/UglifyJsDriverTest.php | 2 +- .../Phrasea/Command/Plugin/AddPluginTest.php | 4 +- .../Setup/XSendFileMappingGeneratorTest.php | 8 +- .../Phrasea/Command/UpgradeDBDatasTest.php | 14 +- .../Controller/Admin/AdminCollectionTest.php | 80 +-- .../Controller/Admin/AdminDashboardTest.php | 16 +- .../Phrasea/Controller/Admin/DataboxTest.php | 54 +- .../Controller/Admin/DataboxesTest.php | 46 +- .../Phrasea/Controller/Admin/FieldsTest.php | 30 +- .../Controller/Admin/PublicationTest.php | 38 +- .../Phrasea/Controller/Admin/RootTest.php | 2 +- .../Controller/Admin/SearchEngineTest.php | 8 +- .../Phrasea/Controller/Admin/SubdefsTest.php | 14 +- .../Controller/Admin/TaskManagerTest.php | 20 +- .../Phrasea/Controller/Admin/UsersTest.php | 70 +-- .../Phrasea/Controller/Client/BasketsTest.php | 14 +- .../Phrasea/Controller/Client/RootTest.php | 8 +- .../Tests/Phrasea/Controller/MinifierTest.php | 8 +- .../Phrasea/Controller/Prod/BasketTest.php | 88 ++-- .../Phrasea/Controller/Prod/BridgeTest.php | 58 +-- .../Controller/Prod/DoDownloadTest.php | 132 ++--- .../Phrasea/Controller/Prod/DownloadTest.php | 26 +- .../Phrasea/Controller/Prod/EditTest.php | 10 +- .../Phrasea/Controller/Prod/ExportTest.php | 42 +- .../Phrasea/Controller/Prod/FeedTest.php | 46 +- .../Phrasea/Controller/Prod/LazaretTest.php | 110 ++-- .../Controller/Prod/MoveCollectionTest.php | 4 +- .../Phrasea/Controller/Prod/OrderTest.php | 46 +- .../Phrasea/Controller/Prod/PrinterTest.php | 18 +- .../Phrasea/Controller/Prod/PropertyTest.php | 32 +- .../Phrasea/Controller/Prod/PushTest.php | 40 +- .../Phrasea/Controller/Prod/QueryTest.php | 8 +- .../Phrasea/Controller/Prod/RecordsTest.php | 22 +- .../Phrasea/Controller/Prod/StoryTest.php | 40 +- .../Tests/Phrasea/Controller/Prod/TOUTest.php | 2 +- .../Phrasea/Controller/Prod/ToolsTest.php | 12 +- .../Phrasea/Controller/Prod/TooltipTest.php | 14 +- .../Phrasea/Controller/Prod/UploadTest.php | 140 +++--- .../Phrasea/Controller/Prod/UsrListsTest.php | 24 +- .../Phrasea/Controller/Prod/WorkZoneTest.php | 24 +- .../Phrasea/Controller/RecordsRequestTest.php | 66 +-- .../Controller/Report/ActivityTest.php | 144 +++--- .../Phrasea/Controller/Report/ExportTest.php | 4 +- .../Controller/Report/InformationsTest.php | 72 +-- .../Phrasea/Controller/Report/RootTest.php | 110 ++-- .../Phrasea/Controller/Root/AccountTest.php | 88 ++-- .../Controller/Root/DevelopersTest.php | 28 +- .../Phrasea/Controller/Root/LoginTest.php | 470 ++++++++--------- .../Phrasea/Controller/Root/RSSFeedTest.php | 92 ++-- .../Phrasea/Controller/Root/RootTest.php | 4 +- .../Phrasea/Controller/Root/SessionTest.php | 20 +- .../Tests/Phrasea/Controller/SetupTest.php | 8 +- .../Controller/User/NotificationsTest.php | 6 +- .../Controller/User/PreferencesTest.php | 10 +- .../Controller/Utils/ConnectionTestTest.php | 12 +- .../Controller/Utils/PathFileTestTest.php | 4 +- .../CLISDriversServiceProviderTest.php | 24 +- .../ComposerSetupServiceProviderTest.php | 8 +- .../LessBuilderServiceProviderTest.php | 12 +- .../CLIProvider/PluginServiceProviderTest.php | 48 +- .../SignalHandlerServiceProviderTest.php | 8 +- .../TaskManagerServiceProviderTest.php | 16 +- .../Core/Configuration/CompilerTest.php | 20 +- .../Core/Configuration/ConfigurationTest.php | 14 +- .../ApiExceptionHandlerSubscriberTest.php | 20 +- .../ApiOauth2ErrorsSubscriberTest.php | 10 +- .../CookiesDisablerSubscriberTest.php | 28 +- .../Subscriber/DebuggerSubscriberTest.php | 22 +- .../Subscriber/FirewallSubscriberTest.php | 2 +- .../Subscriber/JsonRequestSubscriberTest.php | 26 +- .../Subscriber/MaintenanceSubscriberTest.php | 2 +- .../PhraseaLocaleSubscriberTest.php | 18 +- .../Subscriber/TrustedProxySubscriberTest.php | 6 +- .../BasketMiddlewareProviderTest.php | 16 +- .../Core/Provider/ACLServiceProviderTest.php | 8 +- ...thenticationManagerServiceProviderTest.php | 76 +-- .../BorderManagerServiceProviderTest.php | 28 +- .../Provider/BrowserServiceProviderTest.php | 6 +- .../CacheConnectionServiceProviderTest.php | 8 +- .../Provider/CacheServiceProviderTest.php | 16 +- .../ConfigurationServiceProviderTest.php | 16 +- ...ConfigurationTesterServiceProviderTest.php | 6 +- .../Provider/ConvertersServiceProvider.php | 12 +- .../Core/Provider/FeedServiceProviderTest.php | 12 +- .../Provider/FileServeServiceProviderTest.php | 12 +- .../JMSSerializerServiceProviderTest.php | 6 +- .../Provider/LocaleServiceProviderTest.php | 6 +- .../ManipulatorServiceProviderTest.php | 12 +- ...tificationDelivererServiceProviderTest.php | 26 +- .../Core/Provider/ORMServiceProviderTest.php | 14 +- .../PhraseaVersionServiceProviderTest.php | 6 +- .../PhraseanetServiceProviderTest.php | 24 +- .../RegistrationServiceProviderTest.php | 6 +- .../SearchEngineServiceProviderTest.php | 6 +- .../Provider/TasksServiceProviderTest.php | 24 +- ...TemporaryFilesystemServiceProviderTest.php | 6 +- .../Provider/TokensServiceProviderTest.php | 6 +- .../Provider/UnicodeServiceProviderTest.php | 6 +- .../Feed/AggregateLinkGeneratorTest.php | 64 +-- .../Phrasea/Feed/FeedLinkGeneratorTest.php | 62 +-- .../Phrasea/Form/Constraint/GeonameTest.php | 2 +- .../Form/Constraint/GeonameValidatorTest.php | 8 +- .../Form/Constraint/NewEmailValidatorTest.php | 12 +- .../Form/Constraint/NewLoginValidatorTest.php | 12 +- .../Form/Constraint/PasswordTokenTest.php | 6 +- .../Constraint/PasswordTokenValidatorTest.php | 8 +- .../Tests/Phrasea/Form/FormTestCase.php | 2 +- .../Form/Login/PhraseaRegisterFormTest.php | 60 +-- .../Http/ServeFileResponseFactoryTest.php | 24 +- .../Phrasea/Http/XSendFile/ApacheModeTest.php | 16 +- .../Phrasea/Http/XSendFile/NginxModeTest.php | 36 +- .../Http/XSendFile/XSendFileFactoryTest.php | 36 +- .../Media/Subdef/OptionType/EnumTest.php | 4 +- .../Media/Subdef/OptionType/MultiTest.php | 10 +- .../Tests/Phrasea/Model/Entities/UserTest.php | 24 +- .../Model/Manipulator/ACLManipulatorTest.php | 8 +- .../Model/Manipulator/TaskManipulatorTest.php | 8 +- .../Model/Manipulator/UserManipulatorTest.php | 6 +- .../Model/Repositories/TaskRepositoryTest.php | 4 +- .../Phrasea/Notification/DelivererTest.php | 8 +- .../vendor/composer/ClassLoader.php | 10 +- .../vendor/composer/autoload_classmap.php | 4 +- .../vendor/composer/autoload_namespaces.php | 6 +- .../vendor/composer/autoload_real.php | 4 +- .../Fixtures/vendor/composer/ClassLoader.php | 10 +- .../vendor/composer/autoload_classmap.php | 4 +- .../vendor/composer/autoload_namespaces.php | 4 +- .../vendor/composer/autoload_real.php | 4 +- .../Plugin/Importer/ImportStrategyTest.php | 16 +- .../Phrasea/Plugin/Importer/ImporterTest.php | 4 +- .../Management/AutoloaderGeneratorTest.php | 10 +- .../Management/ComposerInstallerTest.php | 2 +- .../Plugin/Management/PluginsExplorerTest.php | 4 +- .../Phrasea/Plugin/Schema/ManifestTest.php | 14 +- .../Plugin/Schema/ManifestValidatorTest.php | 30 +- .../Plugin/Schema/PluginValidatorTest.php | 26 +- .../SearchEngine/PhraseaEngineTest.php | 6 +- .../SearchEngine/SearchEngineAbstractTest.php | 68 +-- .../SearchEngine/SearchEngineLoggerTest.php | 2 +- .../SearchEngine/SearchEngineOptionsTest.php | 44 +- .../SearchEngine/SearchEngineResultTest.php | 16 +- .../SearchEngineSuggestionTest.php | 4 +- .../SearchEngine/SphinxSearchEngineTest.php | 14 +- .../Phrasea/Setup/AbstractSetupTester.php | 2 +- .../Version/Migration/Migration38Test.php | 220 ++++---- .../TaskManager/Editor/ArchiveEditorTest.php | 24 +- .../TaskManager/Editor/DefaultEditorTest.php | 16 +- .../TaskManager/Editor/EditorTestCase.php | 4 +- .../TaskManager/Editor/FtpEditorTest.php | 22 +- .../TaskManager/Editor/FtpPullEditorTest.php | 22 +- .../Editor/PhraseanetIndexerEditorTest.php | 24 +- .../Editor/RecordMoverEditorTest.php | 28 +- .../TaskManager/Editor/SubdefsEditorTest.php | 22 +- .../Editor/WriteMetadataEditorTest.php | 22 +- .../Phrasea/TaskManager/Job/FactoryTest.php | 20 +- .../TaskManager/LiveInformationTest.php | 40 +- .../Phrasea/TaskManager/NotifierTest.php | 18 +- .../TaskManager/TaskManagerStatusTest.php | 28 +- .../Tests/Phrasea/Twig/BytesConverterTest.php | 20 +- .../Phrasea/Utilities/ComposerSetupTest.php | 2 +- .../Phrasea/Utilities/Less/BuilderTest.php | 2 +- .../Utilities/String/CamelizerTest.php | 12 +- tests/classes/ACLTest.php | 114 ++--- .../Api/Auth/Bridge_Api_Auth_AbstractTest.php | 2 +- .../Api/Auth/Bridge_Api_Auth_FlickrTest.php | 24 +- .../Api/Auth/Bridge_Api_Auth_OAuth2Test.php | 16 +- .../Api/Bridge_Api_AbstractCollectionTest.php | 2 +- .../Bridge/Api/Bridge_Api_AbstractTest.php | 8 +- .../Api/Bridge_Api_ElementCollectionTest.php | 2 +- .../Bridge_Api_Dailymotion_ContainerTest.php | 4 +- .../Bridge_Api_Dailymotion_ElementTest.php | 4 +- .../Bridge_Api_Youtube_ContainerTest.php | 2 +- .../Bridge_Api_Youtube_ElementTest.php | 6 +- .../ValidationParticipantRepositoryTest.php | 4 +- tests/classes/PhraseanetPHPUnitAbstract.php | 46 +- tests/classes/PhraseanetPHPUnitListener.php | 4 +- ...seanetWebTestCaseAuthenticatedAbstract.php | 28 +- tests/classes/Session/Session_LoggerTest.php | 8 +- .../oauthv2/api_oauthv2_ApplicationTest.php | 2 +- tests/classes/api/v1/api_v1_adapterTest.php | 90 ++-- tests/classes/api/v1/api_v1_resultTest.php | 72 +-- tests/classes/caption/caption_fieldTest.php | 22 +- tests/classes/caption/caption_recordTest.php | 16 +- .../databox_descriptionStructureTest.php | 4 +- tests/classes/databox/databox_fieldTest.php | 14 +- tests/classes/databox/databox_subdefTest.php | 10 +- tests/classes/media/media_subdefTest.php | 6 +- .../module_console_aboutAuthorsTest.php | 2 +- .../module_console_aboutLicenseTest.php | 2 +- ...le_console_systemTemplateGeneratorTest.php | 2 +- tests/classes/p4stringTest.php | 8 +- tests/classes/record/adapterTest.php | 52 +- tests/classes/registryTest.php | 26 +- tests/classes/report/activityTest.php | 20 +- tests/classes/report/addTest.php | 18 +- tests/classes/report/connexionReportTest.php | 24 +- tests/classes/report/dashboardTest.php | 6 +- tests/classes/report/downloadReportTest.php | 28 +- tests/classes/report/editTest.php | 20 +- tests/classes/report/filterTest.php | 28 +- tests/classes/report/pushTest.php | 20 +- tests/classes/report/questionReportTest.php | 22 +- tests/classes/report/reportTest.php | 16 +- tests/classes/report/sentTest.php | 20 +- tests/classes/report/sqlActionTest.php | 2 +- tests/classes/report/sqlFilterTest.php | 6 +- tests/classes/report/sqlTest.php | 6 +- tests/classes/system/system_serverTest.php | 2 +- tests/classes/unitTestsTest.php | 4 +- tests/classes/userTest.php | 4 +- tests/classes/uuidTest.php | 6 +- 723 files changed, 8350 insertions(+), 8352 deletions(-) diff --git a/bin/developer b/bin/developer index ac7088e183..6326046041 100755 --- a/bin/developer +++ b/bin/developer @@ -57,10 +57,10 @@ $cli = new CLI(" . ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber()); if ($cli['configuration']->isSetup()) { - $helpers = array( + $helpers = [ 'db' => new ConnectionHelper($cli['EM']->getConnection()), 'em' => new EntityManagerHelper($cli['EM']) - ); + ]; $helperSet = $cli['console']->getHelperSet(); foreach ($helpers as $name => $helper) { @@ -80,7 +80,7 @@ $cli->command(new Uninstaller()); $cli->command(new \module_console_systemTemplateGenerator('system:generate-templates')); -$cli['console']->addCommands(array( +$cli['console']->addCommands([ // DBAL Commands new RunSqlCommand(), new ImportCommand(), @@ -99,6 +99,6 @@ $cli['console']->addCommands(array( new ConvertMappingCommand(), new RunDqlCommand(), new ValidateSchemaCommand(), -)); +]); exit($cli->runCLI()); diff --git a/builder.php b/builder.php index 3c6ca744c8..78767e1b3d 100755 --- a/builder.php +++ b/builder.php @@ -48,20 +48,20 @@ $finder ->ignoreVCS(false) ->in(__DIR__); -$files = array(); +$files = []; foreach ($finder as $file) { $files[$file->getRealpath()] = $file->getRealpath(); } -foreach (array( +foreach ([ __DIR__ . '/bin/behat', __DIR__ . '/bin/developer', __DIR__ . '/bin/doctrine.php', __DIR__ . '/bin/doctrine', __DIR__ . '/bin/phpunit', __DIR__ . '/bin/validate-json', -) as $binary) { +] as $binary) { if (is_file($binary)) { $files[$binary] = $binary; } @@ -71,7 +71,7 @@ $finder = new Finder(); $finder ->ignoreDotFiles(false) ->ignoreVCS(false) - ->in(array('logs')); + ->in(['logs']); foreach ($finder as $file) { $files[$file->getRealpath()] = $file->getRealpath(); @@ -118,7 +118,7 @@ $finder ->in(__DIR__); -$dirs = array(); +$dirs = []; foreach ($finder as $dir) { $dirs[] = $dir->getRealpath(); diff --git a/functionnal-tests/api/dailymotion.php b/functionnal-tests/api/dailymotion.php index 084c46eb2d..c287c1a55b 100644 --- a/functionnal-tests/api/dailymotion.php +++ b/functionnal-tests/api/dailymotion.php @@ -49,13 +49,13 @@ $console $bridge->set_oauth_token($configuration['dailymotion']['dev_token']); - $options = array(); - $samples = array( + $options = []; + $samples = [ 'title' => $record->get_title(), 'description' => 'Upload functionnal test', 'tags' => 'phraseanet upload test dm api', 'private' => true, - ); + ]; foreach($bridge->get_fields() as $field) { $options[$field['name']] = isset($samples[$field['name']]) ? $samples[$field['name']] : uniqid('test_upload'); diff --git a/launchpadToLocales.php b/launchpadToLocales.php index 87070a8486..3583ef2771 100755 --- a/launchpadToLocales.php +++ b/launchpadToLocales.php @@ -29,9 +29,9 @@ $finder ->files() ->name('phraseanet-*.po') ->in( - array( + [ __DIR__ . '/' . $argv[1], - ) + ] ) ; diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 732d03ed5f..1085b8d590 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -152,13 +152,13 @@ use Symfony\Component\Form\Exception\FormException; class Application extends SilexApplication { - private static $availableLanguages = array( + private static $availableLanguages = [ 'de_DE' => 'Deutsch', 'en_GB' => 'English', 'fr_FR' => 'Français', 'nl_NL' => 'Dutch', - ); - private static $flashTypes = array('warning', 'info', 'success', 'error'); + ]; + private static $flashTypes = ['warning', 'info', 'success', 'error']; private $environment; const ENV_DEV = 'dev'; @@ -222,9 +222,9 @@ class Application extends SilexApplication $this->register(new MediaAlchemystServiceProvider()); $this['media-alchemyst.configuration'] = $this->share(function (Application $app) { - $configuration = array(); + $configuration = []; - foreach (array( + foreach ([ 'swftools.pdf2swf.binaries' => 'pdf2swf_binary', 'swftools.swfrender.binaries' => 'swf_render_binary', 'swftools.swfextract.binaries' => 'swf_extract_binary', @@ -239,7 +239,7 @@ class Application extends SilexApplication 'mp4box.timeout' => 'mp4box_timeout', 'swftools.timeout' => 'swftools_timeout', 'unoconv.timeout' => 'unoconv_timeout', - ) as $parameter => $key) { + ] as $parameter => $key) { if (isset($this['configuration']['binaries'][$key])) { $configuration[$parameter] = $this['configuration']['binaries'][$key]; } @@ -284,20 +284,20 @@ class Application extends SilexApplication }); $this->register(new SearchEngineServiceProvider()); - $this->register(new SessionServiceProvider(), array( + $this->register(new SessionServiceProvider(), [ 'session.test' => $this->getEnvironment() === static::ENV_TEST - )); + ]); $this->register(new ServiceControllerServiceProvider()); $this->register(new SwiftmailerServiceProvider()); $this->register(new TasksServiceProvider()); $this->register(new TemporaryFilesystemServiceProvider()); $this->register(new TokensServiceProvider()); - $this->register(new TwigServiceProvider(), array( - 'twig.options' => array( + $this->register(new TwigServiceProvider(), [ + 'twig.options' => [ 'cache' => $this['root.path'] . '/tmp/cache_twig/', - ), - 'twig.form.templates' => array('login/common/form_div_layout.html.twig') - )); + ], + 'twig.form.templates' => ['login/common/form_div_layout.html.twig'] + ]); $this->register(new FormServiceProvider()); $this->setupTwig(); @@ -319,24 +319,24 @@ class Application extends SilexApplication if ($app['phraseanet.registry']->get('GV_smtp')) { $transport = new \Swift_Transport_EsmtpTransport( $app['swiftmailer.transport.buffer'], - array($app['swiftmailer.transport.authhandler']), + [$app['swiftmailer.transport.authhandler']], $app['swiftmailer.transport.eventdispatcher'] ); $encryption = null; - if (in_array($app['phraseanet.registry']->get('GV_smtp_secure'), array('ssl', 'tls'))) { + if (in_array($app['phraseanet.registry']->get('GV_smtp_secure'), ['ssl', 'tls'])) { $encryption = $app['phraseanet.registry']->get('GV_smtp_secure'); } - $options = $app['swiftmailer.options'] = array_replace(array( + $options = $app['swiftmailer.options'] = array_replace([ 'host' => $app['phraseanet.registry']->get('GV_smtp_host'), 'port' => $app['phraseanet.registry']->get('GV_smtp_port'), 'username' => $app['phraseanet.registry']->get('GV_smtp_user'), 'password' => $app['phraseanet.registry']->get('GV_smtp_password'), 'encryption' => $encryption, 'auth_mode' => null, - ), $app['swiftmailer.options']); + ], $app['swiftmailer.options']); $transport->setHost($options['host']); $transport->setPort($options['port']); @@ -400,8 +400,8 @@ class Application extends SilexApplication $this['dispatcher'] = $this->share( $this->extend('dispatcher', function ($dispatcher, Application $app) { - $dispatcher->addListener(KernelEvents::REQUEST, array($app, 'initSession'), 254); - $dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128); + $dispatcher->addListener(KernelEvents::REQUEST, [$app, 'initSession'], 254); + $dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128); $dispatcher->addSubscriber(new LogoutSubscriber()); $dispatcher->addSubscriber(new PhraseaLocaleSubscriber($app)); $dispatcher->addSubscriber(new MaintenanceSubscriber($app)); @@ -411,7 +411,7 @@ class Application extends SilexApplication }) ); - $this['log.channels'] = array('monolog', 'task-manager.logger'); + $this['log.channels'] = ['monolog', 'task-manager.logger']; $this->register(new LocaleServiceProvider()); @@ -462,7 +462,7 @@ class Application extends SilexApplication * * @throws FormException if any given option is not applicable to the given type */ - public function form($type = 'form', $data = null, array $options = array(), FormBuilderInterface $parent = null) + public function form($type = 'form', $data = null, array $options = [], FormBuilderInterface $parent = null) { return $this['form.factory']->create($type, $data, $options, $parent); } @@ -475,7 +475,7 @@ class Application extends SilexApplication * * @return string The generated path */ - public function path($route, $parameters = array()) + public function path($route, $parameters = []) { return $this['url_generator']->generate($route, $parameters, UrlGenerator::ABSOLUTE_PATH); } @@ -488,7 +488,7 @@ class Application extends SilexApplication * * @return RedirectResponse */ - public function redirectPath($route, $parameters = array()) + public function redirectPath($route, $parameters = []) { return $this->redirect($this->path($route, $parameters)); } @@ -501,7 +501,7 @@ class Application extends SilexApplication * * @return string The generated URL */ - public function url($route, $parameters = array()) + public function url($route, $parameters = []) { return $this['url_generator']->generate($route, $parameters, UrlGenerator::ABSOLUTE_URL); } @@ -514,7 +514,7 @@ class Application extends SilexApplication * * @return RedirectResponse */ - public function redirectUrl($route, $parameters = array()) + public function redirectUrl($route, $parameters = []) { return $this->redirect($this->url($route, $parameters)); } @@ -671,7 +671,7 @@ class Application extends SilexApplication * * @return array */ - public function getFlash($type, array $default = array()) + public function getFlash($type, array $default = []) { return $this['session']->getFlashBag()->get($type, $default); } @@ -763,7 +763,7 @@ class Application extends SilexApplication */ public function getOpenCollections() { - return array(); + return []; } public function bindRoutes() diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 55c33d3cd3..7e88af31cb 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -39,24 +39,24 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { $result = new \API_V1_result($app, $request, $apiAdapter); - return $result->set_datas(array( + return $result->set_datas([ 'name' => $app['phraseanet.registry']->get('GV_homeTitle'), 'type' => 'phraseanet', 'description' => $app['phraseanet.registry']->get('GV_metaDescription'), 'documentation' => 'https://docs.phraseanet.com/Devel', - 'versions' => array( - '1' => array( + 'versions' => [ + '1' => [ 'number' => $apiAdapter->get_version(), 'uri' => '/api/v1/', 'authenticationProtocol' => 'OAuth2', 'authenticationVersion' => 'draft#v9', - 'authenticationEndPoints' => array( + 'authenticationEndPoints' => [ 'authorization_token' => '/api/oauthv2/authorize', 'access_token' => '/api/oauthv2/token' - ) - ) - ) - ))->get_response(); + ] + ] + ] + ])->get_response(); }); $app->mount('/api/oauthv2', new Oauth2()); diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php index e6470185d9..cf48540fae 100644 --- a/lib/Alchemy/Phrasea/Application/Root.php +++ b/lib/Alchemy/Phrasea/Application/Root.php @@ -50,9 +50,9 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { $app->bindRoutes(); if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) { - $app->register($p = new WebProfilerServiceProvider(), array( + $app->register($p = new WebProfilerServiceProvider(), [ 'profiler.cache_dir' => $app['root.path'] . '/tmp/cache/profiler', - )); + ]); $app->mount('/_profiler', $p); } diff --git a/lib/Alchemy/Phrasea/Authentication/ACLProvider.php b/lib/Alchemy/Phrasea/Authentication/ACLProvider.php index 420a290155..61d1bd1a4d 100644 --- a/lib/Alchemy/Phrasea/Authentication/ACLProvider.php +++ b/lib/Alchemy/Phrasea/Authentication/ACLProvider.php @@ -21,7 +21,7 @@ class ACLProvider * * @var array */ - private static $cache = array(); + private static $cache = []; private $app; @@ -51,7 +51,7 @@ class ACLProvider */ public function purge() { - self::$cache = array(); + self::$cache = []; } /** diff --git a/lib/Alchemy/Phrasea/Authentication/AccountCreator.php b/lib/Alchemy/Phrasea/Authentication/AccountCreator.php index bee068c7ee..8ce723e9de 100644 --- a/lib/Alchemy/Phrasea/Authentication/AccountCreator.php +++ b/lib/Alchemy/Phrasea/Authentication/AccountCreator.php @@ -61,7 +61,7 @@ class AccountCreator * @throws RuntimeException In case the AccountCreator is disabled * @throws InvalidArgumentException In case a user with the same email already exists */ - public function create(Application $app, $id, $email = null, array $templates = array()) + public function create(Application $app, $id, $email = null, array $templates = []) { if (!$this->enabled) { throw new RuntimeException('Account creator is disabled'); @@ -81,7 +81,7 @@ class AccountCreator $user = \User_Adapter::create($app, $login, $this->random->generatePassword(), $email, false, false); - $base_ids = array(); + $base_ids = []; foreach ($this->appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_ids[] = $collection->get_base_id(); diff --git a/lib/Alchemy/Phrasea/Authentication/Authenticator.php b/lib/Alchemy/Phrasea/Authentication/Authenticator.php index b9d1c39abd..3256087a15 100644 --- a/lib/Alchemy/Phrasea/Authentication/Authenticator.php +++ b/lib/Alchemy/Phrasea/Authentication/Authenticator.php @@ -88,7 +88,7 @@ class Authenticator public function refreshAccount(Session $session) { - if (!$this->em->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findOneBy(array('id' => $session->getId()))) { + if (!$this->em->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findOneBy(['id' => $session->getId()])) { throw new RuntimeException('Unable to refresh the session, it does not exist anymore'); } diff --git a/lib/Alchemy/Phrasea/Authentication/Context.php b/lib/Alchemy/Phrasea/Authentication/Context.php index 95e8bcd37e..dd039366ac 100644 --- a/lib/Alchemy/Phrasea/Authentication/Context.php +++ b/lib/Alchemy/Phrasea/Authentication/Context.php @@ -34,7 +34,7 @@ class Context public function setContext($context) { - if (false === in_array($context, array(static::CONTEXT_OAUTH2_NATIVE, static::CONTEXT_OAUTH2_TOKEN, static::CONTEXT_NATIVE, static::CONTEXT_GUEST), true)) { + if (false === in_array($context, [static::CONTEXT_OAUTH2_NATIVE, static::CONTEXT_OAUTH2_TOKEN, static::CONTEXT_NATIVE, static::CONTEXT_GUEST], true)) { throw new InvalidArgumentException(sprintf('`%s` is not a valid context', $context)); } diff --git a/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php b/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php index 5b52ff66d4..c1b4b02fde 100644 --- a/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php +++ b/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php @@ -39,7 +39,7 @@ class Manager { $session = $this->em ->getRepository('Alchemy\Phrasea\Model\Entities\Session') - ->findOneBy(array('token' => $cookieValue)); + ->findOneBy(['token' => $cookieValue]); if (!$session) { return false; diff --git a/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php b/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php index 9614db60e5..50df717c01 100644 --- a/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php +++ b/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php @@ -36,7 +36,7 @@ class NativeAuthentication implements PasswordAuthenticationInterface */ public function getUsrId($username, $password, Request $request) { - if (in_array($username, array('invite', 'autoregister'))) { + if (in_array($username, ['invite', 'autoregister'])) { return null; } @@ -48,7 +48,7 @@ class NativeAuthentication implements PasswordAuthenticationInterface LIMIT 0, 1'; $stmt = $this->conn->prepare($sql); - $stmt->execute(array(':login' => $username)); + $stmt->execute([':login' => $username]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -71,11 +71,11 @@ class NativeAuthentication implements PasswordAuthenticationInterface $sql = 'UPDATE usr SET usr_password = :password, nonce = :nonce WHERE usr_id = :usr_id'; $stmt = $this->conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':password' => $row['usr_password'], ':nonce' => $row['nonce'], ':usr_id' => $row['usr_id'], - )); + ]); $stmt->closeCursor(); } } diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php b/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php index 72f71c1627..91c8210b9b 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php @@ -57,7 +57,7 @@ abstract class AbstractProvider implements ProviderInterface */ public function getTemplates(Identity $identity) { - return array(); + return []; } /** diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php b/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php index db18c3911b..7a27383d34 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php @@ -51,14 +51,14 @@ class Facebook extends AbstractProvider */ public function authenticate() { - return new RedirectResponse($this->facebook->getLoginUrl(array( + return new RedirectResponse($this->facebook->getLoginUrl([ 'scope' => 'email', 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ) - ))); + ])); } /** diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php b/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php index bd868e3586..918f75f098 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php @@ -26,7 +26,7 @@ class Factory $this->session = $session; } - public function build($name, array $options = array()) + public function build($name, array $options = []) { $name = implode('', array_map(function ($chunk) { return ucfirst(strtolower($chunk)); diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Github.php b/lib/Alchemy/Phrasea/Authentication/Provider/Github.php index c14f3fefc2..4f3988eb96 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Github.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Github.php @@ -84,16 +84,16 @@ class Github extends AbstractProvider $this->session->set('github.provider.state', $state); - return new RedirectResponse('https://github.com/login/oauth/authorize?' . http_build_query(array( + return new RedirectResponse('https://github.com/login/oauth/authorize?' . http_build_query([ 'client_id' => $this->key, 'scope' => 'user,user:email', 'state' => $state, 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), - ), '', '&')); + ], '', '&')); } /** @@ -120,16 +120,16 @@ class Github extends AbstractProvider try { $guzzleRequest = $this->client->post('access_token'); - $guzzleRequest->addPostFields(array( + $guzzleRequest->addPostFields([ 'code' => $request->query->get('code'), 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), 'client_id' => $this->key, 'client_secret' => $this->secret, - )); + ]); $guzzleRequest->setHeader('Accept', 'application/json'); $response = $guzzleRequest->send(); } catch (GuzzleException $e) { diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php b/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php index 6087eb0fa0..203c028f39 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php @@ -38,16 +38,16 @@ class GooglePlus extends AbstractProvider $this->plus = new \Google_PlusService($this->client); - $this->client->setScopes(array( + $this->client->setScopes([ 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/userinfo.email', - )); + ]); $this->client->setRedirectUri( $this->generator->generate( - 'login_authentication_provider_callback', array( + 'login_authentication_provider_callback', [ 'providerId' => $this->getId(), - ), UrlGenerator::ABSOLUTE_URL + ], UrlGenerator::ABSOLUTE_URL ) ); @@ -218,7 +218,7 @@ class GooglePlus extends AbstractProvider try { $request = $this->guzzle->get(sprintf( 'https://www.googleapis.com/oauth2/v1/tokeninfo?%s', - http_build_query(array('access_token' => $token['access_token']), '', '&') + http_build_query(['access_token' => $token['access_token']], '', '&') )); $response = $request->send(); } catch (GuzzleException $e) { diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php b/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php index d05ab8460c..e8016475b0 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php @@ -84,17 +84,17 @@ class Linkedin extends AbstractProvider $this->session->set('linkedin.provider.state', $state); - return new RedirectResponse('https://www.linkedin.com/uas/oauth2/authorization?' . http_build_query(array( + return new RedirectResponse('https://www.linkedin.com/uas/oauth2/authorization?' . http_build_query([ 'response_type' => 'code', 'client_id' => $this->key, 'scope' => 'r_basicprofile r_emailaddress', 'state' => $state, 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), - ), '', '&')); + ], '', '&')); } /** @@ -119,17 +119,17 @@ class Linkedin extends AbstractProvider } try { - $guzzleRequest = $this->client->post('https://www.linkedin.com/uas/oauth2/accessToken?' . http_build_query(array( + $guzzleRequest = $this->client->post('https://www.linkedin.com/uas/oauth2/accessToken?' . http_build_query([ 'grant_type' => 'authorization_code', 'code' => $request->query->get('code'), 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), 'client_id' => $this->key, 'client_secret' => $this->secret, - ), '', '&')); + ], '', '&')); $response = $guzzleRequest->send(); } catch (GuzzleException $e) { throw new NotAuthenticatedException('Unable to query LinkedIn access token', $e->getCode(), $e); diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php b/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php index ddf6e0eba2..55f9144516 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php @@ -23,7 +23,7 @@ class Identity const PROPERTY_USERNAME = 'username'; const PROPERTY_COMPANY = 'company'; - private $data = array( + private $data = [ self::PROPERTY_ID => null, self::PROPERTY_IMAGEURL => null, self::PROPERTY_EMAIL => null, @@ -31,9 +31,9 @@ class Identity self::PROPERTY_LASTNAME => null, self::PROPERTY_USERNAME => null, self::PROPERTY_COMPANY => null, - ); + ]; - public function __construct(array $data = array()) + public function __construct(array $data = []) { $this->data = array_merge($this->data, $data); } @@ -55,10 +55,10 @@ class Identity */ public function getDisplayName() { - $data = array_filter(array( + $data = array_filter([ $this->get(self::PROPERTY_FIRSTNAME), $this->get(self::PROPERTY_LASTNAME), - )); + ]); return implode(' ', $data); } diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php b/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php index d7d3144c76..26dda5c1da 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php @@ -74,11 +74,11 @@ class Twitter extends AbstractProvider $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/request_token', ''), - array('oauth_callback' => $this->generator->generate( + ['oauth_callback' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL - )) + )] ); if ($code != 200) { @@ -92,7 +92,7 @@ class Twitter extends AbstractProvider return new RedirectResponse(sprintf( '%s?%s', $this->twitter->url("oauth/authenticate", ''), - http_build_query(array('oauth_token' => $oauth['oauth_token']), '', '&') + http_build_query(['oauth_token' => $oauth['oauth_token']], '', '&') )); } @@ -117,7 +117,7 @@ class Twitter extends AbstractProvider $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/access_token', ''), - array('oauth_verifier' => $request->query->get('oauth_verifier')) + ['oauth_verifier' => $request->query->get('oauth_verifier')] ); if ($code != 200) { @@ -248,11 +248,11 @@ class Twitter extends AbstractProvider */ public static function create(UrlGenerator $generator, SessionInterface $session, array $options) { - $twitter = new \tmhOAuth(array( + $twitter = new \tmhOAuth([ 'consumer_key' => $options['consumer-key'], 'consumer_secret' => $options['consumer-secret'], 'timezone' => date_default_timezone_get(), - )); + ]); return new Twitter($generator, $session, $twitter); } diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php b/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php index 9922c70b79..d7d4e1caff 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php @@ -85,16 +85,16 @@ class Viadeo extends AbstractProvider $this->session->set('viadeo.provider.state', $state); - return new RedirectResponse('https://secure.viadeo.com/oauth-provider/authorize2?' . http_build_query(array( + return new RedirectResponse('https://secure.viadeo.com/oauth-provider/authorize2?' . http_build_query([ 'client_id' => $this->key, 'state' => $state, 'response_type' => 'code', 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), - ))); + ])); } /** @@ -138,13 +138,13 @@ class Viadeo extends AbstractProvider try { $guzzleRequest = $this->client->post('https://secure.viadeo.com/oauth-provider/access_token2'); - $guzzleRequest->addPostFields(array( + $guzzleRequest->addPostFields([ 'grant_type' => 'authorization_code', 'code' => $request->query->get('code'), - 'redirect_uri' => $this->generator->generate('login_authentication_provider_callback', array('providerId' => $this->getId()), UrlGenerator::ABSOLUTE_URL), + 'redirect_uri' => $this->generator->generate('login_authentication_provider_callback', ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL), 'client_id' => $this->key, 'client_secret' => $this->secret, - )); + ]); $guzzleRequest->setHeader('Accept', 'application/json'); $response = $guzzleRequest->send(); } catch (GuzzleException $e) { diff --git a/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php b/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php index 65467fbf50..5bdc9736cb 100644 --- a/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php +++ b/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php @@ -16,7 +16,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; class ProvidersCollection implements \Countable, \IteratorAggregate { - private $providers = array(); + private $providers = []; public function getIterator() { diff --git a/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php b/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php index e92ee6c360..a813f1d936 100644 --- a/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php +++ b/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php @@ -42,7 +42,7 @@ class SuggestionFinder $sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':email' => $infos->get(Identity::PROPERTY_EMAIL))); + $stmt->execute([':email' => $infos->get(Identity::PROPERTY_EMAIL)]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php b/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php index ee6eba475d..496a9f6dc7 100644 --- a/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php +++ b/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php @@ -87,11 +87,11 @@ class MetaField implements AttributeInterface */ public function asString() { - return serialize(array( + return serialize([ 'id' => $this->databox_field->get_id(), 'sbas_id' => $this->databox_field->get_databox()->get_sbas_id(), 'value' => $this->value - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php b/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php index 1c0d1b277e..a37ef77626 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php +++ b/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php @@ -20,8 +20,8 @@ use Alchemy\Phrasea\Border\File; abstract class AbstractChecker implements CheckerInterface { protected $app; - protected $databoxes = array(); - protected $collections = array(); + protected $databoxes = []; + protected $collections = []; public function __construct(Application $app) { @@ -44,7 +44,7 @@ abstract class AbstractChecker implements CheckerInterface throw new \LogicException('You can not restrict on databoxes and collections simultanously'); } - $this->databoxes = array(); + $this->databoxes = []; foreach ($this->toIterator($databoxes) as $databox) { if (! $databox instanceof \databox) { @@ -72,7 +72,7 @@ abstract class AbstractChecker implements CheckerInterface throw new \LogicException('You can not restrict on databoxes and collections simultanously'); } - $this->collections = array(); + $this->collections = []; foreach ($this->toIterator($collections) as $collection) { if (! $collection instanceof \collection) { @@ -122,6 +122,6 @@ abstract class AbstractChecker implements CheckerInterface */ protected function toIterator($data) { - return new \ArrayObject(is_array($data) ? $data : array($data)); + return new \ArrayObject(is_array($data) ? $data : [$data]); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Filename.php b/lib/Alchemy/Phrasea/Border/Checker/Filename.php index 78d208172f..372b66ae08 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Filename.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Filename.php @@ -28,7 +28,7 @@ class Filename extends AbstractChecker * @param Application $app * @param array $options An array of options. available : 'sensitive' (false by default) */ - public function __construct(Application $app, array $options = array()) + public function __construct(Application $app, array $options = []) { if ( ! isset($options['sensitive'])) { $options['sensitive'] = false; diff --git a/lib/Alchemy/Phrasea/Border/File.php b/lib/Alchemy/Phrasea/Border/File.php index d3f9eac215..02c6c4fc50 100644 --- a/lib/Alchemy/Phrasea/Border/File.php +++ b/lib/Alchemy/Phrasea/Border/File.php @@ -65,7 +65,7 @@ class File $this->app = $app; $this->media = $media; $this->collection = $collection; - $this->attributes = array(); + $this->attributes = []; $this->originalName = $originalName ? : pathinfo($this->media->getFile()->getPathname(), PATHINFO_BASENAME); } @@ -96,13 +96,13 @@ class File return $this->uuid; } - $availableUUIDs = array( + $availableUUIDs = [ 'XMP-exif:ImageUniqueID', 'SigmaRaw:ImageUniqueID', 'IPTC:UniqueDocumentID', 'ExifIFD:ImageUniqueID', 'Canon:ImageUniqueID', - ); + ]; if (! $this->uuid) { $metadatas = $this->media->getMetadatas(); diff --git a/lib/Alchemy/Phrasea/Border/Manager.php b/lib/Alchemy/Phrasea/Border/Manager.php index 1c1ad8da42..1e80ceadb1 100644 --- a/lib/Alchemy/Phrasea/Border/Manager.php +++ b/lib/Alchemy/Phrasea/Border/Manager.php @@ -49,7 +49,7 @@ use XPDF\PdfToText; */ class Manager { - protected $checkers = array(); + protected $checkers = []; protected $app; protected $filesystem; protected $pdfToText; @@ -279,12 +279,12 @@ class Manager ) ); - $metadatas = array(); + $metadatas = []; /** * @todo $key is not tagname but fieldname */ - $fieldToKeyMap = array(); + $fieldToKeyMap = []; if (! $fieldToKeyMap) { foreach ($file->getCollection()->get_databox()->get_meta_structure() as $databox_field) { @@ -292,7 +292,7 @@ class Manager $tagname = $databox_field->get_tag()->getTagname(); if ( ! isset($fieldToKeyMap[$tagname])) { - $fieldToKeyMap[$tagname] = array(); + $fieldToKeyMap[$tagname] = []; } $fieldToKeyMap[$tagname][] = $databox_field->get_name(); @@ -309,7 +309,7 @@ class Manager foreach ($fieldToKeyMap[$key] as $k) { if ( ! isset($metadatas[$k])) { - $metadatas[$k] = array(); + $metadatas[$k] = []; } $metadatas[$k] = array_merge($metadatas[$k], $metadata->getValue()->asArray()); @@ -328,7 +328,7 @@ class Manager $key = $attribute->getField()->get_name(); if ( ! isset($metadatas[$key])) { - $metadatas[$key] = array(); + $metadatas[$key] = []; } $metadatas[$key] = array_merge($metadatas[$key], $attribute->getValue()); @@ -344,7 +344,7 @@ class Manager foreach ($fieldToKeyMap[$key] as $k) { if ( ! isset($metadatas[$k])) { - $metadatas[$k] = array(); + $metadatas[$k] = []; } $metadatas[$k] = array_merge($metadatas[$k], $attribute->getValue()->getValue()->asArray()); @@ -368,7 +368,7 @@ class Manager $databox = $element->get_databox(); - $metas = array(); + $metas = []; foreach ($metadatas as $fieldname => $values) { foreach ($databox->get_meta_structure()->get_elements() as $databox_field) { @@ -377,7 +377,7 @@ class Manager if ($databox_field->is_multi()) { - $tmpValues = array(); + $tmpValues = []; foreach ($values as $value) { $tmpValues = array_merge($tmpValues, \caption_field::get_multi_values($value, $databox_field->get_separator())); } @@ -388,11 +388,11 @@ class Manager if ( ! trim($value)) { continue; } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'meta_id' => null, 'value' => $value, - ); + ]; } } else { @@ -402,11 +402,11 @@ class Manager continue; } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'meta_id' => null, 'value' => $value, - ); + ]; } } } diff --git a/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php b/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php index 303bbb5029..0fee025c3e 100644 --- a/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php +++ b/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php @@ -25,7 +25,7 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface */ public function toMetadataArray(\databox_descriptionStructure $metadatasStructure) { - $metas = array(); + $metas = []; $unicode = new \unicode(); foreach ($metadatasStructure as $databox_field) { @@ -34,7 +34,7 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface $values = $this->get($databox_field->get_name())->getValue(); - $tmp = array(); + $tmp = []; foreach ($values as $value) { foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) { @@ -52,11 +52,11 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } else { @@ -69,11 +69,11 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } } diff --git a/lib/Alchemy/Phrasea/Border/MetadataBag.php b/lib/Alchemy/Phrasea/Border/MetadataBag.php index 07528a9ad0..6cffd252d7 100644 --- a/lib/Alchemy/Phrasea/Border/MetadataBag.php +++ b/lib/Alchemy/Phrasea/Border/MetadataBag.php @@ -26,7 +26,7 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface */ public function toMetadataArray(\databox_descriptionStructure $metadatasStructure) { - $metas = array(); + $metas = []; $unicode = new \unicode(); foreach ($metadatasStructure as $databox_field) { @@ -42,7 +42,7 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface $values = $this->get($databox_field->get_tag()->getTagname())->getValue()->asArray(); - $tmp = array(); + $tmp = []; foreach ($values as $value) { foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) { @@ -60,11 +60,11 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } else { $value = $this->get($databox_field->get_tag()->getTagname())->getValue()->asString(); @@ -75,11 +75,11 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } } diff --git a/lib/Alchemy/Phrasea/Border/Visa.php b/lib/Alchemy/Phrasea/Border/Visa.php index b4bde581a7..671e7d60a9 100644 --- a/lib/Alchemy/Phrasea/Border/Visa.php +++ b/lib/Alchemy/Phrasea/Border/Visa.php @@ -33,7 +33,7 @@ class Visa */ public function __construct() { - $this->responses = array(); + $this->responses = []; } /** diff --git a/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php b/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php index 2ec5f41e1f..39be32c34d 100644 --- a/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php +++ b/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php @@ -15,7 +15,7 @@ use Alchemy\Phrasea\Exception\RuntimeException; class ConnectionFactory { - private $connections = array(); + private $connections = []; /** * Returns a Redis connection. @@ -26,9 +26,9 @@ class ConnectionFactory * * @throws RuntimeException */ - public function getRedisConnection(array $options = array()) + public function getRedisConnection(array $options = []) { - $options = array_replace(array('host' => 'localhost', 'port' => 6379), $options); + $options = array_replace(['host' => 'localhost', 'port' => 6379], $options); if (null !== $cache = $this->getConnection('redis', $options)) { return $cache; } @@ -58,9 +58,9 @@ class ConnectionFactory * * @throws RuntimeException */ - public function getMemcacheConnection(array $options = array()) + public function getMemcacheConnection(array $options = []) { - $options = array_replace(array('host' => 'localhost', 'port' => 11211), $options); + $options = array_replace(['host' => 'localhost', 'port' => 11211], $options); if (null !== $cache = $this->getConnection('memcache', $options)) { return $cache; } @@ -91,9 +91,9 @@ class ConnectionFactory * * @throws RuntimeException */ - public function getMemcachedConnection(array $options = array()) + public function getMemcachedConnection(array $options = []) { - $options = array_replace(array('host' => 'localhost', 'port' => 11211), $options); + $options = array_replace(['host' => 'localhost', 'port' => 11211], $options); if (null !== $cache = $this->getConnection('memcached', $options)) { return $cache; } diff --git a/lib/Alchemy/Phrasea/Cache/Manager.php b/lib/Alchemy/Phrasea/Cache/Manager.php index 0ed4ead53d..3a2f830c53 100644 --- a/lib/Alchemy/Phrasea/Cache/Manager.php +++ b/lib/Alchemy/Phrasea/Cache/Manager.php @@ -22,8 +22,8 @@ class Manager private $file; /** @var Compiler */ private $compiler; - private $registry = array(); - private $drivers = array(); + private $registry = []; + private $drivers = []; /** @var Logger */ private $logger; /** @var Factory */ @@ -37,7 +37,7 @@ class Manager $this->factory = $factory; if (!is_file($file)) { - $this->registry = array(); + $this->registry = []; $this->save(); } else { $this->registry = require $file; @@ -55,7 +55,7 @@ class Manager $driver->flushAll(); } - $this->registry = array(); + $this->registry = []; $this->save(); return $this; @@ -78,7 +78,7 @@ class Manager $cache = $this->factory->create($name, $options); } catch (RuntimeException $e) { $this->logger->error($e->getMessage()); - $cache = $this->factory->create('array', array()); + $cache = $this->factory->create('array', []); } $cache->setNamespace(md5(__DIR__)); diff --git a/lib/Alchemy/Phrasea/Cache/RedisCache.php b/lib/Alchemy/Phrasea/Cache/RedisCache.php index 58efb346de..e2ecc934e9 100644 --- a/lib/Alchemy/Phrasea/Cache/RedisCache.php +++ b/lib/Alchemy/Phrasea/Cache/RedisCache.php @@ -96,13 +96,13 @@ class RedisCache extends CacheProvider implements Cache { $stats = $this->_redis->info(); - return array( + return [ Cache::STATS_HITS => false, Cache::STATS_MISSES => false, Cache::STATS_UPTIME => $stats['uptime_in_seconds'], Cache::STATS_MEMORY_USAGE => $stats['used_memory'], Cache::STATS_MEMORY_AVAILIABLE => false, - ); + ]; } /** diff --git a/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php b/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php index 094bdf0c92..939512694c 100644 --- a/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php +++ b/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php @@ -73,7 +73,7 @@ class BuildMissingSubdefs extends Command if ( ! $record->has_subdef($subdef->get_name())) { $todo = true; } - if (in_array($subdef->get_name(), array('preview', 'thumbnail', 'thumbnailgif'))) { + if (in_array($subdef->get_name(), ['preview', 'thumbnail', 'thumbnailgif'])) { try { $sub = $record->get_subdef($subdef->get_name()); if ( ! $sub->is_physically_present()) { @@ -85,7 +85,7 @@ class BuildMissingSubdefs extends Command } if ($todo) { - $record->generate_subdefs($databox, $this->container, array($subdef->get_name())); + $record->generate_subdefs($databox, $this->container, [$subdef->get_name()]); $this->container['monolog']->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id()); $n ++; } diff --git a/lib/Alchemy/Phrasea/Command/CheckConfig.php b/lib/Alchemy/Phrasea/Command/CheckConfig.php index 964c67e048..041356868d 100644 --- a/lib/Alchemy/Phrasea/Command/CheckConfig.php +++ b/lib/Alchemy/Phrasea/Command/CheckConfig.php @@ -40,7 +40,7 @@ class CheckConfig extends AbstractCheckCommand protected function provideRequirements() { - return array( + return [ BinariesProbe::create($this->container), CacheServerProbe::create($this->container), DataboxStructureProbe::create($this->container), @@ -52,6 +52,6 @@ class CheckConfig extends AbstractCheckCommand SearchEngineProbe::create($this->container), SubdefsPathsProbe::create($this->container), SystemProbe::create($this->container), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Command/CreateCollection.php b/lib/Alchemy/Phrasea/Command/CreateCollection.php index 76533e12ff..b2d78c3f33 100644 --- a/lib/Alchemy/Phrasea/Command/CreateCollection.php +++ b/lib/Alchemy/Phrasea/Command/CreateCollection.php @@ -52,7 +52,7 @@ class CreateCollection extends Command if ($new_collection && $input->getOption('base_id_rights')) { $query = new \User_Query($this->container); - $total = $query->on_base_ids(array($input->getOption('base_id_rights')))->get_total(); + $total = $query->on_base_ids([$input->getOption('base_id_rights')])->get_total(); $n = 0; while ($n < $total) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php b/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php index a252d03c17..788bf40f94 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php +++ b/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php @@ -25,7 +25,7 @@ abstract class AbstractRoutesDumper extends Command $maxNameLength = 0; $maxMethodsLength = 0; - $data = array(); + $data = []; foreach ($routes as $name => $route) { $methods = implode('|', $route->getMethods()); @@ -40,12 +40,12 @@ abstract class AbstractRoutesDumper extends Command $warning = true; } - $data[] = array( + $data[] = [ 'name' => $name, 'methods' => $methods ?: 'ALL', 'pattern' => $pattern, 'warning' => $warning - ); + ]; } foreach ($data as $route) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php index c684b1034d..95afa2df82 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php @@ -59,7 +59,7 @@ class BowerInstall extends Command if ($input->getOption('clear-cache')) { $output->write("Cleaning bower cache... "); - $bower->command(array('cache', 'clean')); + $bower->command(['cache', 'clean']); $output->writeln("OK"); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php index 2442e6daa9..08180dc20b 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php @@ -42,7 +42,7 @@ class ComposerInstall extends Command $output->writeln("ERROR Failed to update composer, bypassing"); } - $commands = array('install', '--optimize-autoloader', '--quiet', '--no-interaction'); + $commands = ['install', '--optimize-autoloader', '--quiet', '--no-interaction']; if ($input->getOption('prefer-source')) { $commands[] = '--prefer-source'; } @@ -50,11 +50,11 @@ class ComposerInstall extends Command try { if ($input->getOption('no-dev')) { $output->write("Installing dependencies without developer packages "); - $composer->command(array_merge($commands, array('--no-dev'))); + $composer->command(array_merge($commands, ['--no-dev'])); $output->writeln("OK"); } else { $output->write("Installing dependencies with developer packages "); - $composer->command(array_merge($commands, array('--dev'))); + $composer->command(array_merge($commands, ['--dev'])); $output->writeln("OK"); } } catch (ExecutionFailureException $e) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php b/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php index 47e9fdab94..f67595f2b3 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php @@ -32,7 +32,7 @@ class Uninstaller extends Command { $root = $this->container['root.path']; - foreach (array( + foreach ([ $root.'/tmp/configuration-compiled.php', $root.'/config/configuration.yml', $root.'/config/services.yml', @@ -44,20 +44,20 @@ class Uninstaller extends Command $root.'/config/_GV.php.old', $root.'/tmp/cache_registry.php', $root.'/tmp/cache_registry.yml', - ) as $file) { + ] as $file) { if (is_file($file)) { unlink($file); } } - foreach (array( + foreach ([ $root.'/tmp/serializer', $root.'/tmp/cache_twig', $root.'/tmp/cache_minify', $root.'/tmp/download', $root.'/tmp/locks', $root.'/tmp/cache', - ) as $dir) { + ] as $dir) { if (is_dir($dir)) { $finder = new Finder(); foreach ($finder->files()->in($dir) as $file) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php index f196e12a56..f118881108 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php @@ -32,13 +32,13 @@ class BowerDriver extends AbstractBinary * * @return BowerDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('bower.binaries', array('bower')); + $binaries = $conf->get('bower.binaries', ['bower']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php index 1d1b1db75f..a6cfed4fd9 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php @@ -32,13 +32,13 @@ class ComposerDriver extends AbstractBinary * * @return ComposerDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('composer.binaries', array('composer')); + $binaries = $conf->get('composer.binaries', ['composer']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php index ce6837b955..61ca237e88 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php @@ -32,13 +32,13 @@ class GruntDriver extends AbstractBinary * * @return GruntDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('grunt.binaries', array('grunt')); + $binaries = $conf->get('grunt.binaries', ['grunt']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php index edf71cecc7..f8c2cf0b40 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php @@ -32,13 +32,13 @@ class RecessDriver extends AbstractBinary * * @return RecessDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('recess.binaries', array('recess')); + $binaries = $conf->get('recess.binaries', ['recess']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php index e3b106d60d..f12677a0e3 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php @@ -32,13 +32,13 @@ class UglifyJsDriver extends AbstractBinary * * @return UglifyJsDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('uglifyjs.binaries', array('uglifyjs')); + $binaries = $conf->get('uglifyjs.binaries', ['uglifyjs']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php index 5831d03a65..59aeafc93c 100644 --- a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php +++ b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php @@ -19,7 +19,7 @@ abstract class AbstractPluginCommand extends Command { protected function validatePlugins(InputInterface $input, OutputInterface $output) { - $manifests = array(); + $manifests = []; $output->write("Validating plugins..."); foreach ($this->container['plugins.explorer'] as $directory) { diff --git a/lib/Alchemy/Phrasea/Command/RecordAdd.php b/lib/Alchemy/Phrasea/Command/RecordAdd.php index a56af11811..e1cad50439 100644 --- a/lib/Alchemy/Phrasea/Command/RecordAdd.php +++ b/lib/Alchemy/Phrasea/Command/RecordAdd.php @@ -68,7 +68,7 @@ class RecordAdd extends Command if (!$input->getOption('yes')) { do { $continue = strtolower($dialog->ask($output, sprintf("Will add record %s (%s) on collection %s\nContinue ? (y/N)", $file, $media->getType(), $collection->get_label($this->container['locale.I18n'])), 'N')); - } while ( ! in_array($continue, array('y', 'n'))); + } while ( ! in_array($continue, ['y', 'n'])); if (strtolower($continue) !== 'y') { $output->writeln('Aborted !'); diff --git a/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php b/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php index e0ecddf7b2..4552a20cb8 100644 --- a/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php +++ b/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php @@ -55,7 +55,7 @@ class RescanTechnicalDatas extends Command $dialog = $this->getHelperSet()->get('dialog'); do { $continue = mb_strtolower($dialog->ask($output, sprintf('Estimated duration is %s, continue ? (y/N)', $duration), 'N')); - } while ( ! in_array($continue, array('y', 'n'))); + } while ( ! in_array($continue, ['y', 'n'])); if (strtolower($continue) !== 'y') { $output->writeln('Aborting !'); diff --git a/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php b/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php index b2f884812d..5637fd5466 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php +++ b/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php @@ -41,7 +41,7 @@ class CheckEnvironment extends AbstractCheckCommand */ protected function provideRequirements() { - return array( + return [ new BinariesRequirements(), new CacheServerRequirement(), new FilesystemRequirements(), @@ -50,6 +50,6 @@ class CheckEnvironment extends AbstractCheckCommand new PhraseaRequirements(), new PhpRequirements(), new SystemRequirements(), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Command/Setup/Install.php b/lib/Alchemy/Phrasea/Command/Setup/Install.php index 3c32f0cbad..81994eea1d 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/Install.php +++ b/lib/Alchemy/Phrasea/Command/Setup/Install.php @@ -129,14 +129,14 @@ class Install extends Command $abName = $dialog->ask($output, "DB name (phraseanet) : ", 'phraseanet'); try { - $abConn = new \connection_pdo('appbox', $hostname, $port, $dbUser, $dbPassword, $abName, array(), $this->container['debug']); + $abConn = new \connection_pdo('appbox', $hostname, $port, $dbUser, $dbPassword, $abName, [], $this->container['debug']); $output->writeln("\n\tApplication-Box : Connection successful !\n"); } catch (\Exception $e) { $output->writeln("\n\tInvalid connection parameters\n"); } } while (!$abConn); } else { - $abConn = new \connection_pdo('appbox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('appbox'), array(), $this->container['debug']); + $abConn = new \connection_pdo('appbox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('appbox'), [], $this->container['debug']); $output->writeln("\n\tApplication-Box : Connection successful !\n"); } @@ -155,12 +155,12 @@ class Install extends Command if ($dbName) { try { - $dbConn = new \connection_pdo('databox', $credentials['hostname'], $credentials['port'], $credentials['user'], $credentials['password'], $dbName, array(), $this->container['debug']); + $dbConn = new \connection_pdo('databox', $credentials['hostname'], $credentials['port'], $credentials['user'], $credentials['password'], $dbName, [], $this->container['debug']); $output->writeln("\n\tData-Box : Connection successful !\n"); do { $template = $dialog->ask($output, 'Choose a language template for metadata structure, available are fr (french) and en (english) (en) : ', 'en'); - } while (!in_array($template, array('en', 'fr'))); + } while (!in_array($template, ['en', 'fr'])); $output->writeln("\n\tLanguage selected is '$template'\n"); } catch (\Exception $e) { @@ -171,12 +171,12 @@ class Install extends Command } } while ($retry); } else { - $dbConn = new \connection_pdo('databox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('databox'), array(), $this->container['debug']); + $dbConn = new \connection_pdo('databox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('databox'), [], $this->container['debug']); $output->writeln("\n\tData-Box : Connection successful !\n"); $template = $input->getOption('db-template') ? : 'en'; } - return array($dbConn, $template); + return [$dbConn, $template]; } private function getCredentials(InputInterface $input, OutputInterface $output, DialogHelper $dialog) @@ -205,7 +205,7 @@ class Install extends Command throw new \RuntimeException('You have to provide both email and password'); } - return array($email, $password); + return [$email, $password]; } private function getDataPath(InputInterface $input, OutputInterface $output, DialogHelper $dialog) @@ -259,7 +259,7 @@ class Install extends Command private function detectBinaries() { - return array( + return [ 'php_binary' => $this->executableFinder->find('php'), 'phraseanet_indexer' => $this->executableFinder->find('phraseanet_indexer'), 'pdf2swf_binary' => $this->executableFinder->find('pdf2swf'), @@ -272,6 +272,6 @@ class Install extends Command 'pdftotext_binary' => $this->executableFinder->find('pdftotext'), 'ghostscript_binary' => $this->executableFinder->find('gs'), 'recess_binary' => $this->executableFinder->find('recess'), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php b/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php index 4a43efcaa4..b190011e22 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php +++ b/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php @@ -45,11 +45,11 @@ class XSendFileMappingGenerator extends Command $factory = new XSendFileFactory($this->container['monolog'], true, $type, $this->computeMapping($paths)); $mode = $factory->getMode(true); - $conf = array( + $conf = [ 'enabled' => $enabled, 'type' => $type, 'mapping' => $mode->getMapping(), - ); + ]; if ($input->getOption('write')) { $output->write("Writing configuration ..."); @@ -60,7 +60,7 @@ class XSendFileMappingGenerator extends Command } else { $output->writeln("Configuration will not be written, use --write option to write it"); $output->writeln(""); - $output->writeln(Yaml::dump(array('xsendfile' => $conf), 4)); + $output->writeln(Yaml::dump(['xsendfile' => $conf], 4)); } return 0; @@ -68,10 +68,10 @@ class XSendFileMappingGenerator extends Command private function computeMapping($paths) { - return array_merge(array( - array('mount-point' => 'protected_lazaret', 'directory' => $this->container['root.path'] . '/tmp/lazaret'), - array('mount-point' => 'protected_download', 'directory' => $this->container['root.path'] . '/tmp/download'), - ), array_map(array($this, 'pathsToConf'), array_unique($paths))); + return array_merge([ + ['mount-point' => 'protected_lazaret', 'directory' => $this->container['root.path'] . '/tmp/lazaret'], + ['mount-point' => 'protected_download', 'directory' => $this->container['root.path'] . '/tmp/download'], + ], array_map([$this, 'pathsToConf'], array_unique($paths))); } private function pathsToConf($path) @@ -79,7 +79,7 @@ class XSendFileMappingGenerator extends Command static $n = 0; $n++; - return array('mount-point' => 'protected_dir_'.$n, 'directory' => $path); + return ['mount-point' => 'protected_dir_'.$n, 'directory' => $path]; } private function extractPath(\appbox $appbox) diff --git a/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php b/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php index d47135f9b9..7d68b9bab9 100644 --- a/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php +++ b/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php @@ -38,7 +38,7 @@ class SchedulerRun extends Command protected function doExecute(InputInterface $input, OutputInterface $output) { declare(ticks=1); - $this->container['signal-handler']->register(array(SIGINT, SIGTERM), array($this, 'signalHandler')); + $this->container['signal-handler']->register([SIGINT, SIGTERM], [$this, 'signalHandler']); $this->container['task-manager']->addSubscriber(new LockFileSubscriber($this->container['task-manager.logger'], $this->container['root.path'].'/tmp/locks')); $this->container['task-manager']->start(); } diff --git a/lib/Alchemy/Phrasea/Command/Task/TaskList.php b/lib/Alchemy/Phrasea/Command/Task/TaskList.php index 5bcf634ca8..d6cf8782f3 100644 --- a/lib/Alchemy/Phrasea/Command/Task/TaskList.php +++ b/lib/Alchemy/Phrasea/Command/Task/TaskList.php @@ -36,18 +36,18 @@ class TaskList extends Command $errors ++; } - return array( + return [ $task->getId(), $task->getName(), $task->getStatus() !== 'started' ? $task->getStatus() . " (warning)" : $task->getStatus(), $error ? $info['actual'] . " (error)" : $info['actual'], $info['process-id'], - ); + ]; }, $this->container['manipulator.task']->getRepository()->findAll()); $this ->getHelperSet()->get('table') - ->setHeaders(array('Id', 'Name', 'Status', 'Actual', 'Process Id')) + ->setHeaders(['Id', 'Name', 'Status', 'Actual', 'Process Id']) ->setRows($rows) ->render($output); diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php index 5aea327d52..a018ea112a 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php @@ -137,11 +137,11 @@ class Step31 implements DatasUpgraderInterface $sql = 'UPDATE record SET uuid = :uuid, sha256 = :sha256 WHERE record_id = :record_id'; - $params = array( + $params = [ ':uuid' => $uuid, 'sha256' => $sha256, ':record_id' => $record['record_id'], - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php index cc428cfabc..3bdd33b52a 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php @@ -73,7 +73,7 @@ class Step35 implements DatasUpgraderInterface $stmt = $databox->get_connection()->prepare($sql); foreach ($rs as $row) { - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); try { $record = new \record_adapter($this->app, $databox->get_sbas_id(), $row['record_id']); @@ -138,7 +138,7 @@ class Step35 implements DatasUpgraderInterface { $metas = $record->get_databox()->get_meta_structure(); - $datas = $metadatas = array(); + $datas = $metadatas = []; if (false !== $sxe = simplexml_load_string($xml)) { $fields = $sxe->xpath('/record/description'); @@ -176,18 +176,18 @@ class Step35 implements DatasUpgraderInterface foreach ($datas as $meta_struct_id => $values) { if (is_array($values)) { foreach ($values as $value) { - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $value - ); + ]; } } else { - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $values - ); + ]; } } @@ -222,7 +222,7 @@ class Step35 implements DatasUpgraderInterface } } - $stmt[$databox->get_sbas_id()]->execute(array(':originalname' => $original, ':record_id' => $record['record_id'])); + $stmt[$databox->get_sbas_id()]->execute([':originalname' => $original, ':record_id' => $record['record_id']]); } /** diff --git a/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php b/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php index aa0f49532c..3ac72c1105 100644 --- a/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php +++ b/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php @@ -26,7 +26,7 @@ use vierbergenlars\SemVer\version; */ class UpgradeDBDatas extends Command { - protected $upgrades = array(); + protected $upgrades = []; /** * Constructor @@ -63,10 +63,10 @@ EOF throw new \Exception('You CAN NOT provide a `from` AND `at-version` option at the same time'); } - $versions = array( + $versions = [ 'Upgrade\\Step31' => '3.1', 'Upgrade\\Step35' => '3.5', - ); + ]; if (null !== $input->getOption('from')) { foreach ($versions as $classname => $version) { @@ -91,7 +91,7 @@ EOF public function setUpgrades(array $upgrades) { - $this->upgrades = array(); + $this->upgrades = []; foreach ($upgrades as $upgrade) { $this->addUpgrade($upgrade); @@ -131,7 +131,7 @@ EOF do { $continue = strtolower($dialog->ask($output, $question . 'Continue ? (Y/n)', 'Y')); - } while ( ! in_array($continue, array('y', 'n'))); + } while ( ! in_array($continue, ['y', 'n'])); if (strtolower($continue) !== 'y') { $output->writeln('Aborting !'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index 274cacc22c..36f45b36d9 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -130,12 +130,12 @@ class Collection implements ControllerProviderInterface { $collection = \collection::get_from_base_id($app, $bas_id); - $admins = array(); + $admins = []; if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($bas_id, 'manage')) { $query = new \User_Query($app); - $admins = $query->on_base_ids(array($bas_id)) - ->who_have_right(array('order_master')) + $admins = $query->on_base_ids([$bas_id]) + ->who_have_right(['order_master']) ->execute() ->get_results(); } @@ -155,12 +155,12 @@ class Collection implements ControllerProviderInterface break; } - return $app['twig']->render('admin/collection/collection.html.twig', array( + return $app['twig']->render('admin/collection/collection.html.twig', [ 'collection' => $collection, 'admins' => $admins, 'errorMsg' => $errorMsg, 'reloadTree' => $request->query->get('reload-tree') === '1' - )); + ]); } /** @@ -175,8 +175,8 @@ class Collection implements ControllerProviderInterface { $success = false; - if (count($admins = $request->request->get('admins', array())) > 0) { - $newAdmins = array(); + if (count($admins = $request->request->get('admins', [])) > 0) { + $newAdmins = []; foreach ($admins as $admin) { $newAdmins[] = $admin; @@ -189,17 +189,17 @@ class Collection implements ControllerProviderInterface try { $userQuery = new \User_Query($app); - $result = $userQuery->on_base_ids(array($bas_id)) - ->who_have_right(array('order_master')) + $result = $userQuery->on_base_ids([$bas_id]) + ->who_have_right(['order_master']) ->execute()->get_results(); foreach ($result as $user) { - $app['acl']->get($user)->update_rights_to_base($bas_id, array('order_master' => false)); + $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => false]); } foreach (array_filter($newAdmins) as $admin) { $user = \User_Adapter::getInstance($admin, $app); - $app['acl']->get($user)->update_rights_to_base($bas_id, array('order_master' => true)); + $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => true]); } $conn->commit(); @@ -210,10 +210,10 @@ class Collection implements ControllerProviderInterface } } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => (int) $success, - )); + ]); } /** @@ -246,17 +246,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -281,17 +281,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -316,17 +316,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -351,17 +351,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -387,17 +387,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -415,19 +415,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 1024 * 1024) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -437,17 +437,17 @@ class Collection implements ControllerProviderInterface $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -465,19 +465,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 1024 * 1024) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -487,17 +487,17 @@ class Collection implements ControllerProviderInterface $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -515,19 +515,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 65535) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -536,17 +536,17 @@ class Collection implements ControllerProviderInterface $app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_WM); $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -564,19 +564,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 65535) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -585,17 +585,17 @@ class Collection implements ControllerProviderInterface $app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_LOGO); $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -627,32 +627,32 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg - )); + ]); } if ($collection->get_record_amount() > 0) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => 0, 'error' => 'collection-not-empty', - )); + ]); } if ($success) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => 1, 'reload-tree' => 1, - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => 0, - )); + ]); } /** @@ -677,16 +677,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('The publication has been stopped') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -715,17 +715,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, 'reload-tree' => 1, - )); + ]); } public function labels(Application $app, Request $request, $bas_id) @@ -753,17 +753,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, 'reload-tree' => 1, - )); + ]); } /** @@ -792,16 +792,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -826,16 +826,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -860,16 +860,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -883,7 +883,7 @@ class Collection implements ControllerProviderInterface { $databox = $app['phraseanet.appbox']->get_databox(\phrasea::sbasFromBas($app, $bas_id)); $collection = \collection::get_from_base_id($app, $bas_id); - $structFields = $suggestedValues = $basePrefs = array(); + $structFields = $suggestedValues = $basePrefs = []; foreach ($databox->get_meta_structure() as $meta) { if ($meta->is_readonly()) { @@ -900,9 +900,9 @@ class Collection implements ControllerProviderInterface foreach ($z[0] as $ki => $vi) { if ($vi && isset($structFields[$ki])) { foreach ($vi->value as $oneValue) { - $suggestedValues[] = array( + $suggestedValues[] = [ 'key' => $ki, 'value' => $f, 'name' => (string) $oneValue - ); + ]; $f++; } } @@ -912,7 +912,7 @@ class Collection implements ControllerProviderInterface $z = $sxe->xpath('/baseprefs'); if ($z && is_array($z)) { foreach ($z[0] as $ki => $vi) { - $pref = array('status' => null, 'xml' => null); + $pref = ['status' => null, 'xml' => null]; if ($ki == 'status') { $pref['status'] = $vi; @@ -925,13 +925,13 @@ class Collection implements ControllerProviderInterface } } - return $app['twig']->render('admin/collection/suggested_value.html.twig', array( + return $app['twig']->render('admin/collection/suggested_value.html.twig', [ 'collection' => $collection, 'databox' => $databox, 'suggestedValues' => $suggestedValues, 'structFields' => $structFields, 'basePrefs' => $basePrefs, - )); + ]); } /** @@ -959,17 +959,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_collection_display_suggested_values', array( + return $app->redirectPath('admin_collection_display_suggested_values', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -984,12 +984,12 @@ class Collection implements ControllerProviderInterface { $collection = \collection::get_from_base_id($app, $bas_id); - $out = array('total' => array('totobj' => 0, 'totsiz' => 0, 'mega' => '0', 'giga' => '0'), 'result' => array()); + $out = ['total' => ['totobj' => 0, 'totsiz' => 0, 'mega' => '0', 'giga' => '0'], 'result' => []]; foreach ($collection->get_record_details() as $vrow) { $last_k1 = $last_k2 = null; - $outRow = array('midobj' => 0, 'midsiz' => 0); + $outRow = ['midobj' => 0, 'midsiz' => 0]; if ($vrow['amount'] > 0 || $last_k1 !== $vrow['coll_id']) { @@ -1059,9 +1059,9 @@ class Collection implements ControllerProviderInterface $out['total']['giga'] = $out['total']['totsiz'] / (1024 * 1024 * 1024); } - return $app['twig']->render('admin/collection/details.html.twig', array( + return $app['twig']->render('admin/collection/details.html.twig', [ 'collection' => $collection, 'table' => $out, - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php index d3217d5aab..942a7f47ec 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php @@ -42,13 +42,13 @@ class ConnectedUsers implements ControllerProviderInterface ORDER BY s.updated DESC'; $date = new \DateTime('-2 hours'); - $params = array('date' => $date->format('Y-m-d h:i:s')); + $params = ['date' => $date->format('Y-m-d h:i:s')]; $query = $app['EM']->createQuery($dql); $query->setParameters($params); $sessions = $query->getResult(); - $result = array(); + $result = []; foreach ($sessions as $session) { $info = ''; @@ -76,15 +76,15 @@ class ConnectedUsers implements ControllerProviderInterface )); } - $result[] = array( + $result[] = [ 'session' => $session, 'info' => $info, - ); + ]; } - $ret = array( + $ret = [ 'sessions' => $result, - 'applications' => array( + 'applications' => [ '0' => 0, '1' => 0, '2' => 0, @@ -94,8 +94,8 @@ class ConnectedUsers implements ControllerProviderInterface '6' => 0, '7' => 0, '8' => 0, - ) - ); + ] + ]; foreach ($result as $session) { foreach ($session['session']->getModules() as $module) { @@ -105,7 +105,7 @@ class ConnectedUsers implements ControllerProviderInterface } } - return $app['twig']->render('admin/connected-users.html.twig', array('data' => $ret)); + return $app['twig']->render('admin/connected-users.html.twig', ['data' => $ret]); } /** @@ -117,7 +117,7 @@ class ConnectedUsers implements ControllerProviderInterface */ public static function appName($appId) { - $appRef = array( + $appRef = [ '0' => _('admin::monitor: module inconnu'), '1' => _('admin::monitor: module production'), '2' => _('admin::monitor: module client'), @@ -127,7 +127,7 @@ class ConnectedUsers implements ControllerProviderInterface '6' => _('admin::monitor: module comparateur'), '7' => _('admin::monitor: module validation'), '8' => _('admin::monitor: module upload'), - ); + ]; return isset($appRef[$appId]) ? $appRef[$appId] : null; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index 8e4ad84ec0..efd5988fbf 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -72,11 +72,11 @@ class Dashboard implements ControllerProviderInterface break; } - $parameters = array( + $parameters = [ 'cache_flushed' => $request->query->get('flush_cache') === 'ok', 'admins' => \User_Adapter::get_sys_admins($app), 'email_status' => $emailStatus, - ); + ]; return $app['twig']->render('admin/dashboard.html.twig', $parameters); } @@ -91,10 +91,10 @@ class Dashboard implements ControllerProviderInterface public function flush(Application $app, Request $request) { if ($app['phraseanet.cache-service']->flushAll()) { - return $app->redirectPath('admin_dashbord', array('flush_cache' => 'ok')); + return $app->redirectPath('admin_dashbord', ['flush_cache' => 'ok']); } - return $app->redirectPath('admin_dashbord', array('flush_cache' => 'ko')); + return $app->redirectPath('admin_dashbord', ['flush_cache' => 'ko']); } /** @@ -117,7 +117,7 @@ class Dashboard implements ControllerProviderInterface try { $receiver = new Receiver(null, $mail); } catch (InvalidArgumentException $e) { - return $app->redirectPath('admin_dashbord', array('email' => 'not-sent')); + return $app->redirectPath('admin_dashbord', ['email' => 'not-sent']); } $mail = MailTest::create($app, $receiver); @@ -125,7 +125,7 @@ class Dashboard implements ControllerProviderInterface $app['notification.deliverer']->deliver($mail); $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']); - return $app->redirectPath('admin_dashbord', array('email' => 'sent')); + return $app->redirectPath('admin_dashbord', ['email' => 'sent']); } /** @@ -153,7 +153,7 @@ class Dashboard implements ControllerProviderInterface */ public function addAdmins(Application $app, Request $request) { - if (count($admins = $request->request->get('admins', array())) > 0) { + if (count($admins = $request->request->get('admins', [])) > 0) { if (!in_array($app['authentication']->getUser()->get_id(), $admins)) { $admins[] = $app['authentication']->getUser()->get_id(); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index 22ccf964fb..3a1a5e295a 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -181,12 +181,12 @@ class Databox implements ControllerProviderInterface break; } - return $app['twig']->render('admin/databox/databox.html.twig', array( + return $app['twig']->render('admin/databox/databox.html.twig', [ 'databox' => $databox, 'showDetail' => (int) $request->query->get("sta") < 1, 'errorMsg' => $errorMsg, 'reloadTree' => $request->query->get('reload-tree') === '1' - )); + ]); } /** @@ -199,11 +199,11 @@ class Databox implements ControllerProviderInterface */ public function getDatabaseCGU(Application $app, Request $request, $databox_id) { - return $app['twig']->render('admin/databox/cgus.html.twig', array( + return $app['twig']->render('admin/databox/cgus.html.twig', [ 'languages' => $app['locales.available'], 'cgus' => $app['phraseanet.appbox']->get_databox($databox_id)->get_cgus(), 'current_locale' => $app['locale'] - )); + ]); } /** @@ -235,17 +235,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, 'sbas_id' => $databox->get_sbas_id() - )); + ]); } - $params = array( + $params = [ 'databox_id' => $databox->get_sbas_id(), 'success' => (int) $success, - ); + ]; if ($databox->get_record_amount() > 0) { $params['error'] = 'databox-not-empty'; @@ -279,10 +279,10 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } return $app->redirect('/admin/databox/' . $databox->get_sbas_id() . '/?success=' . (int) $success . '&reload-tree=1'); @@ -308,17 +308,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => (int) $success, - )); + ]); } /** @@ -341,17 +341,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => (int) $success, - )); + ]); } /** @@ -367,20 +367,20 @@ class Databox implements ControllerProviderInterface $databox = $app['phraseanet.appbox']->get_databox($databox_id); try { - foreach ($request->request->get('TOU', array()) as $loc => $terms) { + foreach ($request->request->get('TOU', []) as $loc => $terms) { $databox->update_cgus($loc, $terms, !!$request->request->get('valid', false)); } } catch (\Exception $e) { - return $app->redirectPath('admin_database_display_cgus', array( + return $app->redirectPath('admin_database_display_cgus', [ 'databox_id' => $databox_id, 'success' => 0, - )); + ]); } - return $app->redirectPath('admin_database_display_cgus', array( + return $app->redirectPath('admin_database_display_cgus', [ 'databox_id' => $databox_id, 'success' => 1, - )); + ]); } /** @@ -405,7 +405,7 @@ class Databox implements ControllerProviderInterface $query = new \User_Query($app); $n = 0; - while ($n < $query->on_base_ids(array($othCollSel))->get_total()) { + while ($n < $query->on_base_ids([$othCollSel])->get_total()) { $results = $query->limit($n, 50)->execute()->get_results(); foreach ($results as $user) { @@ -417,17 +417,17 @@ class Databox implements ControllerProviderInterface $app['phraseanet.appbox']->get_connection()->commit(); - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'mount' => 'ok', - )); + ]); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'mount' => 'ko', - )); + ]); } } @@ -449,30 +449,30 @@ class Databox implements ControllerProviderInterface $app['phraseanet.appbox']->write_databox_pic($app['media-alchemyst'], $app['filesystem'], $databox, $file, \databox::PIC_PDF); unlink($file->getPathname()); - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '1', - )); + ]); } else { - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '0', 'error' => 'file-too-big', - )); + ]); } } else { - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '0', 'error' => 'file-invalid', - )); + ]); } } catch (\Exception $e) { - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '0', 'error' => 'file-error', - )); + ]); } } @@ -496,17 +496,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -529,17 +529,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -566,17 +566,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -601,16 +601,16 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('The publication has been stopped') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_databases', array( + return $app->redirectPath('admin_databases', [ 'reload-tree' => 1, - )); + ]); } /** @@ -649,17 +649,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -678,7 +678,7 @@ class Databox implements ControllerProviderInterface $app['phraseanet.appbox'] = $app['phraseanet.appbox']; - $ret = array( + $ret = [ 'success' => false, 'msg' => _('An error occured'), 'sbas_id' => null, @@ -688,7 +688,7 @@ class Databox implements ControllerProviderInterface 'thesaurus_indexed' => 0, 'viewname' => null, 'printLogoURL' => null - ); + ]; try { $databox = $app['phraseanet.appbox']->get_databox($databox_id); @@ -724,9 +724,9 @@ class Databox implements ControllerProviderInterface */ public function getReorder(Application $app, Request $request, $databox_id) { - return $app['twig']->render('admin/collection/reorder.html.twig', array( - 'collections' => $app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox_id)), - )); + return $app['twig']->render('admin/collection/reorder.html.twig', [ + 'collections' => $app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox_id]), + ]); } /** @@ -740,7 +740,7 @@ class Databox implements ControllerProviderInterface public function setReorder(Application $app, Request $request, $databox_id) { try { - foreach ($request->request->get('order', array()) as $data) { + foreach ($request->request->get('order', []) as $data) { $collection = \collection::get_from_base_id($app, $data['id']); $collection->set_ord($data['offset']); } @@ -750,17 +750,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database_display_collections_order', array( + return $app->redirectPath('admin_database_display_collections_order', [ 'databox_id' => $databox_id, 'success' => (int) $success, - )); + ]); } /** @@ -787,10 +787,10 @@ class Databox implements ControllerProviderInterface public function createCollection(Application $app, Request $request, $databox_id) { if (($name = trim($request->request->get('name', ''))) === '') { - return $app->redirectPath('admin_database_display_new_collection_form', array( + return $app->redirectPath('admin_database_display_new_collection_form', [ 'databox_id' => $databox_id, 'error' => 'name', - )); + ]); } try { @@ -800,7 +800,7 @@ class Databox implements ControllerProviderInterface if (($request->request->get('ccusrothercoll') === "on") && (null !== $othcollsel = $request->request->get('othcollsel'))) { $query = new \User_Query($app); - $total = $query->on_base_ids(array($othcollsel))->get_total(); + $total = $query->on_base_ids([$othcollsel])->get_total(); $n = 0; while ($n < $total) { $results = $query->limit($n, 20)->execute()->get_results(); @@ -811,9 +811,9 @@ class Databox implements ControllerProviderInterface } } - return $app->redirectPath('admin_display_collection', array('bas_id' => $collection->get_base_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_display_collection', ['bas_id' => $collection->get_base_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { - return $app->redirectPath('admin_database_submit_collection', array('databox_id' => $databox_id, 'error' => 'error')); + return $app->redirectPath('admin_database_submit_collection', ['databox_id' => $databox_id, 'error' => 'error']); } } @@ -829,15 +829,15 @@ class Databox implements ControllerProviderInterface { $databox = $app['phraseanet.appbox']->get_databox($databox_id); - $details = array(); - $total = array('total_subdefs' => 0, 'total_size' => 0); + $details = []; + $total = ['total_subdefs' => 0, 'total_size' => 0]; foreach ($databox->get_record_details($request->query->get('sort')) as $collName => $colDetails) { - $details[$collName] = array( + $details[$collName] = [ 'total_subdefs' => 0, 'total_size' => 0, - 'medias' => array() - ); + 'medias' => [] + ]; foreach ($colDetails as $subdefName => $subdefDetails) { $details[$collName]['total_subdefs'] += $subdefDetails['n']; @@ -845,18 +845,18 @@ class Databox implements ControllerProviderInterface $details[$collName]['total_size'] += $subdefDetails['siz']; $total['total_size'] += $subdefDetails['siz']; - $details[$collName]['medias'][] = array ( + $details[$collName]['medias'][] = [ 'subdef_name' => $subdefName, 'total_subdefs' => $subdefDetails['n'], 'total_size' => $subdefDetails['siz'], - ); + ]; } } - return $app['twig']->render('admin/databox/details.html.twig', array( + return $app['twig']->render('admin/databox/details.html.twig', [ 'databox' => $databox, 'table' => $details, 'total' => $total - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php index 6d48ed2294..8cf8a48b20 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php @@ -69,28 +69,28 @@ class Databoxes implements ControllerProviderInterface public function getDatabases(Application $app, Request $request) { $sbasIds = array_merge( - array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(array('bas_manage'))) - , array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(array('bas_modify_struct'))) + array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(['bas_manage'])) + , array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(['bas_modify_struct'])) ); - $sbas = array(); + $sbas = []; foreach ($sbasIds as $sbasId) { - $sbas[$sbasId] = array( + $sbas[$sbasId] = [ 'version' => 'unknown', 'image' => '/skins/icons/db-remove.png', 'server_info' => '', 'name' => _('Unreachable server') - ); + ]; try { $databox = $app['phraseanet.appbox']->get_databox($sbasId); - $sbas[$sbasId] = array( + $sbas[$sbasId] = [ 'version' => $databox->get_version(), 'image' => '/skins/icons/foldph20close_0.gif', 'server_info' => $databox->get_connection()->server_info(), 'name' => \phrasea::sbas_labels($sbasId, $app) - ); + ]; } catch (\Exception $e) { } @@ -128,14 +128,14 @@ class Databoxes implements ControllerProviderInterface $upgrader = new \Setup_Upgrade($app); - return $app['twig']->render('admin/databases.html.twig', array( + return $app['twig']->render('admin/databases.html.twig', [ 'files' => new \DirectoryIterator($app['root.path'] . '/lib/conf.d/data_templates'), 'sbas' => $sbas, 'error_msg' => $errorMsg, 'recommendations' => $upgrader->getRecommendations(), - 'advices' => $request->query->get('advices', array()), + 'advices' => $request->query->get('advices', []), 'reloadTree' => (Boolean) $request->query->get('reload-tree'), - )); + ]); } /** @@ -149,11 +149,11 @@ class Databoxes implements ControllerProviderInterface public function createDatabase(Application $app, Request $request) { if ('' === $dbName = $request->request->get('new_dbname', '')) { - return $app->redirectPath('admin_databases', array('error' => 'no-empty')); + return $app->redirectPath('admin_databases', ['error' => 'no-empty']); } if (\p4string::hasAccent($dbName)) { - return $app->redirectPath('admin_databases', array('error' => 'special-chars')); + return $app->redirectPath('admin_databases', ['error' => 'special-chars']); } if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) { @@ -169,9 +169,9 @@ class Databoxes implements ControllerProviderInterface $dataTemplate = new \SplFileInfo($app['root.path'] . '/lib/conf.d/data_templates/' . $dataTemplate . '.xml'); try { - $connbas = new \connection_pdo('databox_creation', $hostname, $port, $user, $password, $dbName, array(), $app['debug']); + $connbas = new \connection_pdo('databox_creation', $hostname, $port, $user, $password, $dbName, [], $app['debug']); } catch (\PDOException $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'database-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'database-failed']); } try { @@ -179,9 +179,9 @@ class Databoxes implements ControllerProviderInterface $base->registerAdmin($app['authentication']->getUser()); $app['acl']->get($app['authentication']->getUser())->delete_data_from_cache(); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'base-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'base-failed']); } } @@ -195,17 +195,17 @@ class Databoxes implements ControllerProviderInterface try { $data_template = new \SplFileInfo($app['root.path'] . '/lib/conf.d/data_templates/' . $dataTemplate . '.xml'); - $connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $app['debug']); + $connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, [], $app['debug']); try { $base = \databox::create($app, $connbas, $data_template, $app['phraseanet.registry']); $base->registerAdmin($app['authentication']->getUser()); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'base-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'base-failed']); } } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'database-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'database-failed']); } } } @@ -220,11 +220,11 @@ class Databoxes implements ControllerProviderInterface public function databaseMount(Application $app, Request $request) { if ('' === $dbName = trim($request->request->get('new_dbname', ''))) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'no-empty')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'no-empty']); } if (\p4string::hasAccent($dbName)) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'special-chars')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'special-chars']); } if ((null === $request->request->get('new_settings'))) { @@ -242,11 +242,11 @@ class Databoxes implements ControllerProviderInterface $base->registerAdmin($app['authentication']->getUser()); $app['phraseanet.appbox']->get_connection()->commit(); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'mount-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'mount-failed']); } } @@ -263,11 +263,11 @@ class Databoxes implements ControllerProviderInterface $base->registerAdmin($app['authentication']->getUser()); $app['phraseanet.appbox']->get_connection()->commit(); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'mount-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'mount-failed']); } } } @@ -283,20 +283,20 @@ class Databoxes implements ControllerProviderInterface { $info = $app['task-manager.live-information']->getManager(); if (TaskManagerStatus::STATUS_STARTED === $info['actual']) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'scheduler-started')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'scheduler-started']); } try { $upgrader = new \Setup_Upgrade($app); $advices = $app['phraseanet.appbox']->forceUpgrade($upgrader, $app); - return $app->redirectPath('admin_databases', array('success' => 1, 'notice' => 'restart', 'advices' => $advices)); + return $app->redirectPath('admin_databases', ['success' => 1, 'notice' => 'restart', 'advices' => $advices]); } catch (\Exception_Setup_UpgradeAlreadyStarted $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'already-started')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'already-started']); } catch (\Exception_Setup_FixBadEmailAddresses $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'bad-email')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'bad-email']); } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'unknow')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'unknow']); } } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php index 90d0889e4a..ee4478999a 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php @@ -90,7 +90,7 @@ class Fields implements ControllerProviderInterface public function updateFields(Application $app, Request $request, $sbas_id) { - $fields = array(); + $fields = []; $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $metaStructure = $databox->get_meta_structure(); $connection = $databox->get_connection(); @@ -125,7 +125,7 @@ class Fields implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { - return $app->json(array( + return $app->json([ 'something_wrong' => _('Something wrong happened, please try again or contact an admin.'), 'created_success' => _('%s field has been created with success.'), 'deleted_success' => _('%s field has been deleted with success.'), @@ -136,29 +136,29 @@ class Fields implements ControllerProviderInterface 'validation_tag_invalid' => _('Field source is not valid.'), 'field_error' => _('Field %s contains errors.'), 'fields_save' => _('Your configuration has been successfuly saved.'), - )); + ]); } public function displayApp(Application $app, Request $request, $sbas_id) { - $languages = array(); + $languages = []; foreach ($app['locales.available'] as $code => $language) { $data = explode('_', $code); $languages[$data[0]] = $language; } - return $app['twig']->render('/admin/fields/index.html.twig', array( + return $app['twig']->render('/admin/fields/index.html.twig', [ 'sbas_id' => $sbas_id, 'languages' => $languages, - )); + ]); } public function listDcFields(Application $app, Request $request) { $data = $app['serializer']->serialize(array_values(\databox::get_available_dcfields()), 'json'); - return new Response($data, 200, array('content-type' => 'application/json')); + return new Response($data, 200, ['content-type' => 'application/json']); } public function listVocabularies(Application $app, Request $request) @@ -166,10 +166,10 @@ class Fields implements ControllerProviderInterface $vocabularies = VocabularyController::getAvailable($app); return $app->json(array_map(function ($vocabulary) { - return array( + return [ 'type' => $vocabulary->getType(), 'name' => $vocabulary->getName(), - ); + ]; }, $vocabularies)); } @@ -177,16 +177,16 @@ class Fields implements ControllerProviderInterface { $vocabulary = VocabularyController::get($app, $type); - return $app->json(array( + return $app->json([ 'type' => $vocabulary->getType(), 'name' => $vocabulary->getName(), - )); + ]); } public function searchTag(Application $app, Request $request) { $term = trim(strtolower($request->query->get('term'))); - $res = array(); + $res = []; if ($term) { $provider = new TagProvider(); @@ -199,11 +199,11 @@ class Fields implements ControllerProviderInterface continue; } - $res[] = array( + $res[] = [ 'id' => $namespace . '/' . $tagname, 'label' => $datas['namespace'] . ' / ' . $datas['tagname'], 'value' => $datas['namespace'] . ':' . $datas['tagname'], - ); + ]; } } } @@ -216,7 +216,7 @@ class Fields implements ControllerProviderInterface $tag = \databox_field::loadClassFromTagName($tagname); $json = $app['serializer']->serialize($tag, 'json'); - return new Response($json, 200, array('Content-Type' => 'application/json')); + return new Response($json, 200, ['Content-Type' => 'application/json']); } public function createField(Application $app, Request $request, $sbas_id) @@ -236,11 +236,11 @@ class Fields implements ControllerProviderInterface $app->abort(500, _(sprintf('Field %s could not be created, please try again or contact an admin.', $data['name']))); } - return $app->json($field->toArray(), 201, array( - 'location' => $app->path('admin_fields_show_field', array( + return $app->json($field->toArray(), 201, [ + 'location' => $app->path('admin_fields_show_field', [ 'sbas_id' => $sbas_id, 'id' => $field->get_id() - )))); + ])]); } public function listFields(Application $app, $sbas_id) @@ -361,11 +361,11 @@ class Fields implements ControllerProviderInterface private function getMandatoryFieldProperties() { - return array( + return [ 'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'required', 'separator', 'readonly', 'type', 'tbranch', 'report', 'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels' - ); + ]; } private function validateNameField(\databox_descriptionStructure $metaStructure, array $field) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index dc1fbd8f77..476a8034b9 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -42,7 +42,7 @@ class Publications implements ControllerProviderInterface ); return $app['twig'] - ->render('admin/publications/list.html.twig', array('feeds' => $feeds)); + ->render('admin/publications/list.html.twig', ['feeds' => $feeds]); })->bind('admin_feeds_list'); $controllers->post('/create/', function (PhraseaApplication $app, Request $request) { @@ -82,7 +82,7 @@ class Publications implements ControllerProviderInterface $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id); return $app['twig'] - ->render('admin/publications/fiche.html.twig', array('feed' => $feed, 'error' => $app['request']->query->get('error'))); + ->render('admin/publications/fiche.html.twig', ['feed' => $feed, 'error' => $app['request']->query->get('error')]); }) ->bind('admin_feeds_feed') ->assert('id', '\d+'); @@ -112,17 +112,17 @@ class Publications implements ControllerProviderInterface $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $request->attributes->get('id')); if (!$feed->isOwner($app['authentication']->getUser())) { - return $app->redirectPath('admin_feeds_feed', array('id' => $request->attributes->get('id'), 'error' => _('You are not the owner of this feed, you can not edit it'))); + return $app->redirectPath('admin_feeds_feed', ['id' => $request->attributes->get('id'), 'error' => _('You are not the owner of this feed, you can not edit it')]); } }) ->bind('admin_feeds_feed_update') ->assert('id', '\d+'); $controllers->post('/feed/{id}/iconupload/', function (PhraseaApplication $app, Request $request, $id) { - $datas = array( + $datas = [ 'success' => false, 'message' => '', - ); + ]; $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id); if (null === $feed) { @@ -213,7 +213,7 @@ class Publications implements ControllerProviderInterface $error = "An error occured"; } - return $app->redirectPath('admin_feeds_feed', array('id' => $id, 'error' => $error)); + return $app->redirectPath('admin_feeds_feed', ['id' => $id, 'error' => $error]); }) ->bind('admin_feeds_feed_add_publisher') ->assert('id', '\d+'); @@ -240,7 +240,7 @@ class Publications implements ControllerProviderInterface $error = "An error occured"; } - return $app->redirectPath('admin_feeds_feed', array('id' => $id, 'error' => $error)); + return $app->redirectPath('admin_feeds_feed', ['id' => $id, 'error' => $error]); }) ->bind('admin_feeds_feed_remove_publisher') ->assert('id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index 51e1dd9e0e..5abe74203d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -43,7 +43,7 @@ class Root implements ControllerProviderInterface $section = $request->query->get('section', false); - $available = array( + $available = [ 'connected', 'registrations', 'taskmanager', @@ -52,7 +52,7 @@ class Root implements ControllerProviderInterface 'collection', 'user', 'users' - ); + ]; $feature = 'connected'; $featured = false; @@ -67,7 +67,7 @@ class Root implements ControllerProviderInterface } } - $databoxes = $off_databoxes = array(); + $databoxes = $off_databoxes = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) { @@ -82,14 +82,14 @@ class Root implements ControllerProviderInterface $databoxes[] = $databox; } - $params = array( + $params = [ 'feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes - ); + ]; - return $app['twig']->render('admin/index.html.twig', array( + return $app['twig']->render('admin/index.html.twig', [ 'module' => 'admin', 'events' => $app['events-manager'], 'module_name' => 'Admin', @@ -99,7 +99,7 @@ class Root implements ControllerProviderInterface 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes, 'tree' => $app['twig']->render('admin/tree.html.twig', $params), - )); + ]); })->bind('admin'); $controllers->get('/tree/', function (Application $app, Request $request) { @@ -111,7 +111,7 @@ class Root implements ControllerProviderInterface $section = $request->query->get('section', false); - $available = array( + $available = [ 'connected', 'registrations', 'taskmanager', @@ -120,7 +120,7 @@ class Root implements ControllerProviderInterface 'collection', 'user', 'users' - ); + ]; $feature = 'connected'; $featured = false; @@ -136,7 +136,7 @@ class Root implements ControllerProviderInterface } } - $databoxes = $off_databoxes = array(); + $databoxes = $off_databoxes = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) { @@ -152,12 +152,12 @@ class Root implements ControllerProviderInterface $databoxes[] = $databox; } - $params = array( + $params = [ 'feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes - ); + ]; return $app['twig']->render('admin/tree.html.twig', $params); })->bind('admin_display_tree'); @@ -168,7 +168,7 @@ class Root implements ControllerProviderInterface $app->abort(400, _('Bad request format, only JSON is allowed')); } - if (0 !== count($tests = $request->query->get('tests', array()))) { + if (0 !== count($tests = $request->query->get('tests', []))) { $app->abort(400, _('Missing tests parameter')); } @@ -192,7 +192,7 @@ class Root implements ControllerProviderInterface } } - return $app->json(array('results' => $result)); + return $app->json(['results' => $result]); }) ->bind('admin_test_paths'); @@ -213,13 +213,13 @@ class Root implements ControllerProviderInterface $errorsStructure = true; } - return $app['twig']->render('admin/structure.html.twig', array( + return $app['twig']->render('admin/structure.html.twig', [ 'databox' => $databox, 'errors' => $errors, 'structure' => $structure, 'errorsStructure' => $errorsStructure, 'updateOk' => $updateOk - )); + ]); })->assert('databox_id', '\d+') ->bind('database_display_stucture'); @@ -242,9 +242,9 @@ class Root implements ControllerProviderInterface $databox = $app['phraseanet.appbox']->get_databox($databox_id); $databox->saveStructure($domst); - return $app->redirectPath('database_display_stucture', array('databox_id' => $databox_id, 'success' => 1)); + return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 1]); } else { - return $app->redirectPath('database_display_stucture', array('databox_id' => $databox_id, 'success' => 0, 'error' => 'struct')); + return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 0, 'error' => 'struct']); } })->assert('databox_id', '\d+') ->bind('database_submit_stucture'); @@ -254,9 +254,9 @@ class Root implements ControllerProviderInterface $app->abort(403); } - return $app['twig']->render('admin/statusbit.html.twig', array( + return $app['twig']->render('admin/statusbit.html.twig', [ 'databox' => $app['phraseanet.appbox']->get_databox($databox_id), - )); + ]); })->assert('databox_id', '\d+') ->bind('database_display_statusbit'); @@ -290,7 +290,7 @@ class Root implements ControllerProviderInterface if (isset($status[$bit])) { $status = $status[$bit]; } else { - $status = array( + $status = [ "labeloff" => '', "labelon" => '', "img_off" => '', @@ -299,7 +299,7 @@ class Root implements ControllerProviderInterface "path_on" => '', "searchable" => false, "printable" => false, - ); + ]; foreach ($app['locales.I18n.available'] as $code => $language) { $status['labels_on'][$code] = null; @@ -307,10 +307,10 @@ class Root implements ControllerProviderInterface } } - return $app['twig']->render('admin/statusbit/edit.html.twig', array( + return $app['twig']->render('admin/statusbit/edit.html.twig', [ 'status' => $status, 'errorMsg' => $errorMsg - )); + ]); })->assert('databox_id', '\d+') ->assert('bit', '\d+') ->bind('database_display_statusbit_form'); @@ -332,7 +332,7 @@ class Root implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); }) ->bind('admin_statusbit_delete') ->assert('databox_id', '\d+') @@ -343,15 +343,15 @@ class Root implements ControllerProviderInterface $app->abort(403); } - $properties = array( + $properties = [ 'searchable' => $request->request->get('searchable') ? '1' : '0', 'printable' => $request->request->get('printable') ? '1' : '0', 'name' => $request->request->get('name', ''), 'labelon' => $request->request->get('label_on', ''), 'labeloff' => $request->request->get('label_off', ''), - 'labels_on' => $request->request->get('labels_on', array()), - 'labels_off' => $request->request->get('labels_off', array()), - ); + 'labels_on' => $request->request->get('labels_on', []), + 'labels_off' => $request->request->get('labels_off', []), + ]; \databox_status::updateStatus($app, $databox_id, $bit, $properties); @@ -363,41 +363,41 @@ class Root implements ControllerProviderInterface try { \databox_status::updateIcon($app, $databox_id, $bit, 'off', $file); } catch (AccessDeniedHttpException $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights', - )); + ]); } catch (\Exception_InvalidArgument $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } catch (\Exception_Upload_FileTooBig $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big', - )); + ]); } catch (\Exception_Upload_Error $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error', - )); + ]); } catch (\Exception_Upload_CannotWriteFile $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error', - )); + ]); } catch (\Exception $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } } @@ -409,45 +409,45 @@ class Root implements ControllerProviderInterface try { \databox_status::updateIcon($app, $databox_id, $bit, 'on', $file); } catch (AccessDeniedHttpException $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights', - )); + ]); } catch (\Exception_InvalidArgument $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } catch (\Exception_Upload_FileTooBig $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big', - )); + ]); } catch (\Exception_Upload_Error $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error', - )); + ]); } catch (\Exception_Upload_CannotWriteFile $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error', - )); + ]); } catch (\Exception $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } } - return $app->redirectPath('database_display_statusbit', array('databox_id' => $databox_id, 'success' => 1)); + return $app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]); })->assert('databox_id', '\d+') ->assert('bit', '\d+') ->bind('database_submit_statusbit'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php index 29351a180a..dacbb807d4 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php @@ -68,11 +68,11 @@ class Setup implements ControllerProviderInterface } } - return $app['twig']->render('admin/setup.html.twig', array( + return $app['twig']->render('admin/setup.html.twig', [ 'GV' => $GV, 'update_post_datas' => $update, 'listTimeZone' => \DateTimeZone::listAbbreviations() - )); + ]); } /** @@ -85,13 +85,13 @@ class Setup implements ControllerProviderInterface public function postGlobals(Application $app, Request $request) { if (\setup::create_global_values($app, $request->request->all())) { - return $app->redirectPath('setup_display_globals', array( + return $app->redirectPath('setup_display_globals', [ 'success' => 1 - )); + ]); } - return $app->redirectPath('setup_display_globals', array( + return $app->redirectPath('setup_display_globals', [ 'success' => 0 - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php b/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php index 32db55af72..89fb639388 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php @@ -36,10 +36,10 @@ class Subdefs implements ControllerProviderInterface $controllers->get('/{sbas_id}/', function (Application $app, $sbas_id) { $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - return $app['twig']->render('admin/subdefs.html.twig', array( + return $app['twig']->render('admin/subdefs.html.twig', [ 'databox' => $databox, 'subdefs' => $databox->get_subdef_structure() - )); + ]); }) ->bind('admin_subdefs_subdef') ->assert('sbas_id', '\d+'); @@ -47,11 +47,11 @@ class Subdefs implements ControllerProviderInterface $controllers->post('/{sbas_id}/', function (Application $app, Request $request, $sbas_id) { $delete_subdef = $request->request->get('delete_subdef'); $toadd_subdef = $request->request->get('add_subdef'); - $Parmsubdefs = $request->request->get('subdefs', array()); + $Parmsubdefs = $request->request->get('subdefs', []); $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - $add_subdef = array('class' => null, 'name' => null, 'group' => null); + $add_subdef = ['class' => null, 'name' => null, 'group' => null]; foreach ($add_subdef as $k => $v) { if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') unset($add_subdef[$k]); @@ -81,7 +81,7 @@ class Subdefs implements ControllerProviderInterface foreach ($Parmsubdefs as $post_sub) { - $options = array(); + $options = []; $post_sub_ex = explode('_', $post_sub); @@ -91,7 +91,7 @@ class Subdefs implements ControllerProviderInterface $class = $request->request->get($post_sub . '_class'); $downloadable = $request->request->get($post_sub . '_downloadable'); - $defaults = array('path', 'meta', 'mediatype'); + $defaults = ['path', 'meta', 'mediatype']; foreach ($defaults as $def) { $parm_loc = $request->request->get($post_sub . '_' . $def); @@ -104,7 +104,7 @@ class Subdefs implements ControllerProviderInterface } $mediatype = $request->request->get($post_sub . '_mediatype'); - $media = $request->request->get($post_sub . '_' . $mediatype, array()); + $media = $request->request->get($post_sub . '_' . $mediatype, []); foreach ($media as $option => $value) { @@ -115,13 +115,13 @@ class Subdefs implements ControllerProviderInterface $options[$option] = $value; } - $labels = $request->request->get($post_sub . '_label', array()); + $labels = $request->request->get($post_sub . '_label', []); $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels); } } - return $app->redirectPath('admin_subdefs_subdef', array('sbas_id' => $databox->get_sbas_id())); + return $app->redirectPath('admin_subdefs_subdef', ['sbas_id' => $databox->get_sbas_id()]); }) ->bind('admin_subdefs_subdef_update') ->assert('sbas_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php index 22f75dcd2c..223d0dfbd0 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php @@ -122,10 +122,10 @@ class TaskManager implements ControllerProviderInterface public function getTasks(Application $app, Request $request) { - return $app['twig']->render('admin/task-manager/list.html.twig', array( + return $app['twig']->render('admin/task-manager/list.html.twig', [ 'available_jobs' => $app['task-manager.available-jobs'], 'tasks' => $app['manipulator.task']->getRepository()->findAll(), - )); + ]); } public function postCreateTask(Application $app, Request $request) @@ -143,7 +143,7 @@ class TaskManager implements ControllerProviderInterface $job->getEditor()->getDefaultPeriod() ); - return $app->redirectPath('admin_tasks_task_show', array('task' => $task->getId())); + return $app->redirectPath('admin_tasks_task_show', ['task' => $task->getId()]); } public function getSchedulerLog(Application $app, Request $request) @@ -153,10 +153,10 @@ class TaskManager implements ControllerProviderInterface $logFile->clear(); } - return $app['twig']->render('admin/task-manager/log.html.twig', array( + return $app['twig']->render('admin/task-manager/log.html.twig', [ 'logfile' => $logFile, 'logname' => 'Scheduler', - )); + ]); } public function getTaskLog(Application $app, Request $request, Task $task) @@ -166,10 +166,10 @@ class TaskManager implements ControllerProviderInterface $logFile->clear(); } - return $app['twig']->render('admin/task-manager/log.html.twig', array( + return $app['twig']->render('admin/task-manager/log.html.twig', [ 'logfile' => $logFile, 'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()), - )); + ]); } public function postTaskDelete(Application $app, Request $request, Task $task) @@ -197,13 +197,13 @@ class TaskManager implements ControllerProviderInterface { $app['manipulator.task']->resetCrashes($task); - return $app->json(array('success' => true)); + return $app->json(['success' => true]); } public function postSaveTask(Application $app, Request $request, Task $task) { if (!$this->doValidateXML($request->request->get('settings'))) { - return $app->json(array('success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml')))); + return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]); } $form = $app->form(new TaskForm()); @@ -212,13 +212,13 @@ class TaskManager implements ControllerProviderInterface if ($form->isValid()) { $app['manipulator.task']->update($task); - return $app->json(array('success' => true)); + return $app->json(['success' => true]); } - return $app->json(array( + return $app->json([ 'success' => false, 'message' => implode("\n", $form->getErrors()) - )); + ]); } public function postTaskFacility(Application $app, Request $request, Task $task) @@ -246,16 +246,16 @@ class TaskManager implements ControllerProviderInterface $form = $app->form(new TaskForm()); $form->setData($task); - return $app['twig']->render($editor->getTemplatePath(), array( + return $app['twig']->render($editor->getTemplatePath(), [ 'task' => $task, 'form' => $form->createView(), 'view' => 'XML', - )); + ]); } public function validateXML(Application $app, Request $request) { - return $app->json(array('success' => $this->doValidateXML($request->getContent()))); + return $app->json(['success' => $this->doValidateXML($request->getContent())]); } private function doValidateXML($string) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index d54e3b58b9..5867f2b758 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -50,7 +50,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/reset/', function (Application $app, Request $request) { try { - $datas = array('error' => false); + $datas = ['error' => false]; $helper = new UserHelper\Edit($app, $request); $helper->resetRights(); @@ -70,7 +70,7 @@ class Users implements ControllerProviderInterface }); $controllers->post('/rights/apply/', function (Application $app) { - $datas = array('error' => true); + $datas = ['error' => true]; try { $rights = new UserHelper\Edit($app, $app['request']); @@ -88,7 +88,7 @@ class Users implements ControllerProviderInterface $rights->apply_infos(); - $datas = array('error' => false); + $datas = ['error' => false]; } catch (\Exception $e) { $datas['message'] = $e->getMessage(); } @@ -106,7 +106,7 @@ class Users implements ControllerProviderInterface $rights = new UserHelper\Edit($app, $app['request']); $rights->apply_quotas(); - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); }); $controllers->post('/rights/time/', function (Application $app) { @@ -125,7 +125,7 @@ class Users implements ControllerProviderInterface $rights = new UserHelper\Edit($app, $app['request']); $rights->apply_time(); - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); }); $controllers->post('/rights/masks/', function (Application $app) { @@ -138,7 +138,7 @@ class Users implements ControllerProviderInterface $rights = new UserHelper\Edit($app, $app['request']); $rights->apply_masks(); - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); }); $controllers->match('/search/', function (Application $app) { @@ -152,8 +152,8 @@ class Users implements ControllerProviderInterface $users = new UserHelper\Manage($app, $app['request']); - $userTable = array( - array( + $userTable = [ + [ 'ID', 'Login', 'Last Name', @@ -170,12 +170,12 @@ class Users implements ControllerProviderInterface 'Job', 'Company', 'Position' - ) - ); + ] + ]; foreach ($users->export() as $user) { /* @var $user \User_Adapter */ - $userTable[] = array( + $userTable[] = [ $user->get_id(), $user->get_login(), $user->get_lastname(), @@ -192,12 +192,12 @@ class Users implements ControllerProviderInterface $user->get_job(), $user->get_company(), $user->get_position() - ); + ]; } $CSVDatas = \format::arr_to_csv($userTable); - $response = new Response($CSVDatas, 200, array('Content-Type' => 'text/csv')); + $response = new Response($CSVDatas, 200, ['Content-Type' => 'text/csv']); $response->headers->set('Content-Disposition', 'attachment; filename=export.csv'); return $response; @@ -220,10 +220,10 @@ class Users implements ControllerProviderInterface $user_query = new \User_Query($app); $like_value = $request->query->get('term'); - $rights = $request->query->get('filter_rights') ? : array(); - $have_right = $request->query->get('have_right') ? : array(); - $have_not_right = $request->query->get('have_not_right') ? : array(); - $on_base = $request->query->get('on_base') ? : array(); + $rights = $request->query->get('filter_rights') ? : []; + $have_right = $request->query->get('have_right') ? : []; + $have_not_right = $request->query->get('have_not_right') ? : []; + $on_base = $request->query->get('on_base') ? : []; $elligible_users = $user_query ->on_sbas_where_i_am($app['acl']->get($app['authentication']->getUser()), $rights) @@ -238,15 +238,15 @@ class Users implements ControllerProviderInterface ->execute() ->get_results(); - $datas = array(); + $datas = []; foreach ($elligible_users as $user) { - $datas[] = array( + $datas[] = [ 'email' => $user->get_email() ? : '' , 'login' => $user->get_login() ? : '' , 'name' => $user->get_display_name() ? : '' , 'id' => $user->get_id() - ); + ]; } return $app->json($datas); @@ -254,7 +254,7 @@ class Users implements ControllerProviderInterface $controllers->post('/create/', function (Application $app) { - $datas = array('error' => false, 'message' => '', 'data' => null); + $datas = ['error' => false, 'message' => '', 'data' => null]; try { $request = $app['request']; $module = new UserHelper\Manage($app, $app['request']); @@ -284,15 +284,15 @@ class Users implements ControllerProviderInterface $on_base = $request->request->get('base_id') ? : null; $on_sbas = $request->request->get('sbas_id') ? : null; - $elligible_users = $user_query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canadmin')) + $elligible_users = $user_query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canadmin']) ->like($like_field, $like_value) ->on_base_ids($on_base) ->on_sbas_ids($on_sbas); $offset = 0; - $buffer = array(); + $buffer = []; - $buffer[] = array( + $buffer[] = [ 'ID' , 'Login' , _('admin::compte-utilisateur nom') @@ -309,7 +309,7 @@ class Users implements ControllerProviderInterface , _('admin::compte-utilisateur poste') , _('admin::compte-utilisateur societe') , _('admin::compte-utilisateur activite') - ); + ]; do { $elligible_users->limit($offset, 20); $offset += 20; @@ -317,7 +317,7 @@ class Users implements ControllerProviderInterface $results = $elligible_users->execute()->get_results(); foreach ($results as $user) { - $buffer[] = array( + $buffer[] = [ $user->get_id() , $user->get_login() , $user->get_lastname() @@ -334,16 +334,16 @@ class Users implements ControllerProviderInterface , $user->get_job() , $user->get_company() , $user->get_position() - ); + ]; } } while (count($results) > 0); $out = \format::arr_to_csv($buffer); - $response = new Response($out, 200, array( + $response = new Response($out, 200, [ 'Content-type' => 'text/csv', 'Content-Disposition' => 'attachment; filename=export.csv', - )); + ]); $response->setCharset('UTF-8'); @@ -355,15 +355,15 @@ class Users implements ControllerProviderInterface $lastMonth = time() - (3 * 4 * 7 * 24 * 60 * 60); $sql = "DELETE FROM demand WHERE date_modif < :date"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':date' => date('Y-m-d', $lastMonth))); + $stmt->execute([':date' => date('Y-m-d', $lastMonth)]); $stmt->closeCursor(); - $baslist = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $baslist = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canadmin'])); $sql = 'SELECT usr_id, usr_login FROM usr WHERE model_of = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -381,7 +381,7 @@ class Users implements ControllerProviderInterface $stmt->closeCursor(); $currentUsr = null; - $table = array('user' => array(), 'coll' => array()); + $table = ['user' => [], 'coll' => []]; foreach ($rs as $row) { if ($row['usr_id'] != $currentUsr) { @@ -391,7 +391,7 @@ class Users implements ControllerProviderInterface } if (!isset($table['coll'][$row['usr_id']])) { - $table['coll'][$row['usr_id']] = array(); + $table['coll'][$row['usr_id']] = []; } if (!in_array($row['base_id'], $table['coll'][$row['usr_id']])) { @@ -401,17 +401,17 @@ class Users implements ControllerProviderInterface $stmt->closeCursor(); - return $app['twig']->render('admin/user/demand.html.twig', array( + return $app['twig']->render('admin/user/demand.html.twig', [ 'table' => $table, 'models' => $models, - )); + ]); })->bind('users_display_demands'); $controllers->post('/demands/', function (Application $app, Request $request) { - $templates = $deny = $accept = $options = array(); + $templates = $deny = $accept = $options = []; - foreach ($request->request->get('template', array()) as $tmp) { + foreach ($request->request->get('template', []) as $tmp) { if (trim($tmp) != '') { $tmp = explode('_', $tmp); @@ -421,29 +421,29 @@ class Users implements ControllerProviderInterface } } - foreach ($request->request->get('deny', array()) as $den) { + foreach ($request->request->get('deny', []) as $den) { $den = explode('_', $den); if (count($den) == 2 && !isset($templates[$den[0]])) { $deny[$den[0]][$den[1]] = $den[1]; } } - foreach ($request->request->get('accept', array()) as $acc) { + foreach ($request->request->get('accept', []) as $acc) { $acc = explode('_', $acc); if (count($acc) == 2 && !isset($templates[$acc[0]])) { $accept[$acc[0]][$acc[1]] = $acc[1]; - $options[$acc[0]][$acc[1]] = array('HD' => false, 'WM' => false); + $options[$acc[0]][$acc[1]] = ['HD' => false, 'WM' => false]; } } - foreach ($request->request->get('accept_hd', array()) as $accHD) { + foreach ($request->request->get('accept_hd', []) as $accHD) { $accHD = explode('_', $accHD); if (count($accHD) == 2 && isset($accept[$accHD[0]]) && isset($options[$accHD[0]][$accHD[1]])) { $options[$accHD[0]][$accHD[1]]['HD'] = true; } } - foreach ($request->request->get('watermark', array()) as $wm) { + foreach ($request->request->get('watermark', []) as $wm) { $wm = explode('_', $wm); if (count($wm) == 2 && isset($accept[$wm[0]]) && isset($options[$wm[0]][$wm[1]])) { $options[$wm[0]][$wm[1]]['WM'] = true; @@ -451,8 +451,8 @@ class Users implements ControllerProviderInterface } if (count($templates) > 0 || count($deny) > 0 || count($accept) > 0) { - $done = array(); - $cache_to_update = array(); + $done = []; + $cache_to_update = []; foreach ($templates as $usr => $template_id) { $user = \User_Adapter::getInstance($usr, $app); @@ -464,7 +464,7 @@ class Users implements ControllerProviderInterface $app['acl']->get($user)->apply_model($user_template, $base_ids); if (!isset($done[$usr])) { - $done[$usr] = array(); + $done[$usr] = []; } foreach ($base_ids as $base_id) { @@ -477,7 +477,7 @@ class Users implements ControllerProviderInterface AND (base_id = " . implode(' OR base_id = ', $base_ids) . ")"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr)); + $stmt->execute([':usr_id' => $usr]); $stmt->closeCursor(); } @@ -491,10 +491,10 @@ class Users implements ControllerProviderInterface foreach ($deny as $usr => $bases) { $cache_to_update[$usr] = true; foreach ($bases as $bas) { - $stmt->execute(array(':usr_id' => $usr, ':base_id' => $bas)); + $stmt->execute([':usr_id' => $usr, ':base_id' => $bas]); if (!isset($done[$usr])) { - $done[$usr] = array(); + $done[$usr] = []; } $done[$usr][$bas] = false; @@ -508,28 +508,28 @@ class Users implements ControllerProviderInterface $cache_to_update[$usr] = true; foreach ($bases as $bas) { - $app['acl']->get($user)->give_access_to_sbas(array(\phrasea::sbasFromBas($app, $bas))); + $app['acl']->get($user)->give_access_to_sbas([\phrasea::sbasFromBas($app, $bas)]); - $rights = array( + $rights = [ 'canputinalbum' => '1' , 'candwnldhd' => ($options[$usr][$bas]['HD'] ? '1' : '0') , 'nowatermark' => ($options[$usr][$bas]['WM'] ? '0' : '1') , 'candwnldpreview' => '1' , 'actif' => '1' - ); + ]; - $app['acl']->get($user)->give_access_to_base(array($bas)); + $app['acl']->get($user)->give_access_to_base([$bas]); $app['acl']->get($user)->update_rights_to_base($bas, $rights); if (!isset($done[$usr])) { - $done[$usr] = array(); + $done[$usr] = []; } $done[$usr][$bas] = true; $sql = "DELETE FROM demand WHERE usr_id = :usr_id AND base_id = :base_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr, ':base_id' => $bas)); + $stmt->execute([':usr_id' => $usr, ':base_id' => $bas]); $stmt->closeCursor(); } } @@ -544,7 +544,7 @@ class Users implements ControllerProviderInterface $sql = 'SELECT usr_mail FROM usr WHERE usr_id = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr)); + $stmt->execute([':usr_id' => $usr]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -579,7 +579,7 @@ class Users implements ControllerProviderInterface } } - return $app->redirectPath('users_display_demands', array('success' => 1)); + return $app->redirectPath('users_display_demands', ['success' => 1]); })->bind('users_submit_demands'); $controllers->get('/import/file/', function (Application $app, Request $request) { @@ -588,16 +588,16 @@ class Users implements ControllerProviderInterface $controllers->post('/import/file/', function (Application $app, Request $request) { if ((null === $file = $request->files->get('files')) || !$file->isValid()) { - return $app->redirectPath('users_display_import_file', array('error' => 'file-invalid')); + return $app->redirectPath('users_display_import_file', ['error' => 'file-invalid']); } $equivalenceToMysqlField = self::getEquivalenceToMysqlField(); $loginDefined = $pwdDefined = $mailDefined = false; - $loginNew = array(); - $out = array( - 'ignored_row' => array(), - 'errors' => array() - ); + $loginNew = []; + $out = [ + 'ignored_row' => [], + 'errors' => [] + ]; $nbUsrToAdd = 0; $lines = \format::csv_to_arr($file->getPathname()); @@ -633,15 +633,15 @@ class Users implements ControllerProviderInterface } if (!$loginDefined) { - return $app->redirectPath('users_display_import_file', array('error' => 'row-login')); + return $app->redirectPath('users_display_import_file', ['error' => 'row-login']); } if (!$pwdDefined) { - return $app->redirectPath('users_display_import_file', array('error' => 'row-pwd')); + return $app->redirectPath('users_display_import_file', ['error' => 'row-pwd']); } if (!$mailDefined) { - return $app->redirectPath('users_display_import_file', array('error' => 'row-mail')); + return $app->redirectPath('users_display_import_file', ['error' => 'row-mail']); } foreach ($lines as $nbLine => $line) { @@ -703,15 +703,15 @@ class Users implements ControllerProviderInterface } if (count($out['errors']) > 0 && $nbUsrToAdd === 0) { - return $app['twig']->render('admin/user/import/file.html.twig', array( + return $app['twig']->render('admin/user/import/file.html.twig', [ 'errors' => $out['errors'] - )); + ]); } if ($nbUsrToAdd === 0) { - return $app->redirectPath('users_display_import_file', array( + return $app->redirectPath('users_display_import_file', [ 'error' => 'no-user' - )); + ]); } $sql = " @@ -720,22 +720,22 @@ class Users implements ControllerProviderInterface INNER JOIN basusr ON (basusr.usr_id=usr.usr_id) WHERE usr.model_of = :usr_id - AND base_id in(" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('manage')))) . ") + AND base_id in(" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage']))) . ") AND usr_login not like '(#deleted_%)' GROUP BY usr_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - return $app['twig']->render('/admin/user/import/view.html.twig', array( + return $app['twig']->render('/admin/user/import/view.html.twig', [ 'nb_user_to_add' => $nbUsrToAdd, 'models' => $models, 'lines_serialized' => serialize($lines), 'columns_serialized' => serialize($columns), 'errors' => $out['errors'] - )); + ]); })->bind('users_submit_import_file'); $controllers->post('/import/', function (Application $app, Request $request) { @@ -759,7 +759,7 @@ class Users implements ControllerProviderInterface $equivalenceToMysqlField = Users::getEquivalenceToMysqlField(); foreach ($lines as $nbLine => $line) { - $curUser = array(); + $curUser = []; foreach ($columns as $nbCol => $colName) { if (!isset($equivalenceToMysqlField[$colName]) || !isset($line[$nbCol])) { continue; @@ -859,7 +859,7 @@ class Users implements ControllerProviderInterface } $app['acl']->get($NewUser)->apply_model( - \User_Adapter::getInstance($model, $app), array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('manage'))) + \User_Adapter::getInstance($model, $app), array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage'])) ); $nbCreation++; @@ -867,7 +867,7 @@ class Users implements ControllerProviderInterface } } - return $app->redirectPath('admin_users_search', array('user-updated' => $nbCreation)); + return $app->redirectPath('admin_users_search', ['user-updated' => $nbCreation]); })->bind('users_submit_import'); $controllers->get('/import/example/csv/', function (Application $app) { @@ -913,7 +913,7 @@ class Users implements ControllerProviderInterface public static function getEquivalenceToMysqlField() { - $equivalenceToMysqlField = array(); + $equivalenceToMysqlField = []; $equivalenceToMysqlField['civilite'] = 'usr_sexe'; $equivalenceToMysqlField['gender'] = 'usr_sexe'; diff --git a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php index 2dc9c8e714..72d15a18e8 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php +++ b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php @@ -86,15 +86,15 @@ class Oauth2 implements ControllerProviderInterface return $app->redirectPath('oauth2_authorize'); } } catch (RequireCaptchaException $e) { - return $app->redirectPath('oauth2_authorize', array('error' => 'captcha')); + return $app->redirectPath('oauth2_authorize', ['error' => 'captcha']); } catch (AccountLockedException $e) { - return $app->redirectPath('oauth2_authorize', array('error' => 'account-locked')); + return $app->redirectPath('oauth2_authorize', ['error' => 'account-locked']); } $app['authentication']->openAccount(\User_Adapter::getInstance($usr_id, $app)); } - return new Response($app['twig']->render($template, array("auth" => $oauth2_adapter))); + return new Response($app['twig']->render($template, ["auth" => $oauth2_adapter])); } //check if current client is already authorized by current user @@ -114,10 +114,10 @@ class Oauth2 implements ControllerProviderInterface $params['account_id'] = $account->get_id(); if (!$app_authorized && $action_accept === null) { - $params = array( + $params = [ "auth" => $oauth2_adapter, "errorMessage" => $errorMessage, - ); + ]; return new Response($app['twig']->render($template, $params)); } elseif (!$app_authorized && $action_accept !== null) { @@ -149,7 +149,7 @@ class Oauth2 implements ControllerProviderInterface */ $controllers->post('/token', function (\Silex\Application $app, Request $request) { if ( ! $request->isSecure()) { - throw new HttpException(400, 'This route requires the use of the https scheme', null, array('content-type' => 'application/json')); + throw new HttpException(400, 'This route requires the use of the https scheme', null, ['content-type' => 'application/json']); } $app['oauth']->grantAccessToken($request); diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php index 3eb20acb8d..363797fe80 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php @@ -142,7 +142,7 @@ class V1 implements ControllerProviderInterface } } - return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action); + return ['ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action]; }; /** @@ -227,7 +227,7 @@ class V1 implements ControllerProviderInterface $controllers->get('/monitor/task/{task}/', function (SilexApplication $app, Request $request, $task) { return $app['api']->get_task($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin)->assert('task', '\d+'); /** @@ -244,7 +244,7 @@ class V1 implements ControllerProviderInterface $controllers->post('/monitor/task/{task}/', function (SilexApplication $app, Request $request, $task) { return $app['api']->set_task_property($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin)->assert('task', '\d+'); /** @@ -260,7 +260,7 @@ class V1 implements ControllerProviderInterface $controllers->post('/monitor/task/{task}/start/', function (SilexApplication $app, Request $request, $task) { return $app['api']->start_task($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin); /** @@ -276,7 +276,7 @@ class V1 implements ControllerProviderInterface $controllers->post('/monitor/task/{task}/stop/', function (SilexApplication $app, Request $request, $task) { return $app['api']->stop_task($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin); /** diff --git a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php index 5765c17388..ba22eb5398 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php @@ -71,9 +71,9 @@ class Baskets implements ControllerProviderInterface } - return $app->redirectPath('get_client_baskets', array( + return $app->redirectPath('get_client_baskets', [ 'courChuId' => $request->request->get('courChuId', '') - )); + ]); } /** @@ -122,9 +122,9 @@ class Baskets implements ControllerProviderInterface } - return $app->redirectPath('get_client_baskets', array( + return $app->redirectPath('get_client_baskets', [ 'courChuId' => null !== $basket ? $basket->getId() : '' - )); + ]); } /** @@ -154,9 +154,9 @@ class Baskets implements ControllerProviderInterface } - return $app->redirectPath('get_client_baskets', array( + return $app->redirectPath('get_client_baskets', [ 'courChuId' => $basket ? $basket->getId() : '' - )); + ]); } /** @@ -185,13 +185,13 @@ class Baskets implements ControllerProviderInterface return (Boolean) $basket->getPusherId(); }); - return $app['twig']->render('client/baskets.html.twig', array( + return $app['twig']->render('client/baskets.html.twig', [ 'total_baskets' => $baskets->count(), 'user_baskets' => $basketCollections[1], 'recept_user_basket' => $basketCollections[0], 'selected_basket' => $selectedBasket, 'selected_basket_elements' => $selectedBasket ? $selectedBasket->getElements() : new ArrayCollection() - )); + ]); } /** @@ -215,10 +215,10 @@ class Baskets implements ControllerProviderInterface } } - return $app->json(array( + return $app->json([ 'success' => true, 'message' => '', 'no_view' => $noview - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Client/Root.php b/lib/Alchemy/Phrasea/Controller/Client/Root.php index c510d3affd..87a282796d 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Root.php @@ -32,7 +32,7 @@ class Root implements ControllerProviderInterface $controllers->before(function (Request $request) use ($app) { if (!$app['authentication']->isAuthenticated() && null !== $request->query->get('nolog')) { - return $app->redirectPath('login_authenticate_as_guest', array('redirect' => 'client')); + return $app->redirectPath('login_authenticate_as_guest', ['redirect' => 'client']); } $app['firewall']->requireAuthentication(); }); @@ -116,17 +116,17 @@ class Root implements ControllerProviderInterface return new Response($app['twig']->render("client/help.html.twig")); } - $resultData = array(); + $resultData = []; foreach ($searchData as $record) { try { $record->get_subdef('document'); - $lightInfo = $app['twig']->render('common/technical_datas.html.twig', array('record' => $record)); + $lightInfo = $app['twig']->render('common/technical_datas.html.twig', ['record' => $record]); } catch (\Exception $e) { $lightInfo = ''; } - $caption = $app['twig']->render('common/caption.html.twig', array('view' => 'answer', 'record' => $record)); + $caption = $app['twig']->render('common/caption.html.twig', ['view' => 'answer', 'record' => $record]); $docType = $record->get_type(); $isVideo = ($docType == 'video'); @@ -148,7 +148,7 @@ class Root implements ControllerProviderInterface $previewExists = false; } - $resultData[] = array( + $resultData[] = [ 'record' => $record, 'mini_logo' => \collection::getLogo($record->get_base_id(), $app), 'preview_exists' => $previewExists, @@ -160,10 +160,10 @@ class Root implements ControllerProviderInterface 'is_document' => $isDocument, 'can_download' => $canDownload, 'can_add_to_basket' => $app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'canputinalbum') - ); + ]; } - return new Response($app['twig']->render("client/answers.html.twig", array( + return new Response($app['twig']->render("client/answers.html.twig", [ 'mod_col' => $modCol, 'mod_row' => $modRow, 'result_data' => $resultData, @@ -174,7 +174,7 @@ class Root implements ControllerProviderInterface 'result' => $result, 'proposals' => $currentPage === 1 ? $result->getProposals() : null, 'help' => count($resultData) === 0 ? $this->getHelpStartPage($app) : '', - ))); + ])); } /** @@ -210,7 +210,7 @@ class Root implements ControllerProviderInterface */ public function getClientLanguage(Application $app, Request $request) { - $out = array(); + $out = []; $out['createWinInvite'] = _('paniers:: Quel nom souhaitez vous donner a votre panier ?'); $out['chuNameEmpty'] = _('paniers:: Quel nom souhaitez vous donner a votre panier ?'); $out['noDLok'] = _('export:: aucun document n\'est disponible au telechargement'); @@ -251,7 +251,7 @@ class Root implements ControllerProviderInterface $renderTopics = \queries::tree_topics($app['locale.I18n']); } - return new Response($app['twig']->render('client/index.html.twig', array( + return new Response($app['twig']->render('client/index.html.twig', [ 'last_action' => !$app['authentication']->getUser()->is_guest() && false !== $request->cookies->has('last_act') ? $request->cookies->has('last_act') : null, 'phrasea_home' => $this->getDefaultClientStartPage($app), 'render_topics' => $renderTopics, @@ -260,13 +260,13 @@ class Root implements ControllerProviderInterface 'storage_access' => $this->getDocumentStorageAccess($app), 'tabs_setup' => $this->getTabSetup($app), 'module' => 'client', - 'menubar' => $app['twig']->render('common/menubar.html.twig', array('module' => 'client')), + 'menubar' => $app['twig']->render('common/menubar.html.twig', ['module' => 'client']), 'css_file' => $this->getCssFile($app), 'basket_status' => null !== $app['authentication']->getUser()->getPrefs('client_basket_status') ? $app['authentication']->getUser()->getPrefs('client_basket_status') : "1", 'mod_pres' => null !== $app['authentication']->getUser()->getPrefs('client_view') ? $app['authentication']->getUser()->getPrefs('client_view') : '', 'start_page' => $app['authentication']->getUser()->getPrefs('start_page'), 'start_page_query' => null !== $app['authentication']->getUser()->getPrefs('start_page_query') ? $app['authentication']->getUser()->getPrefs('start_page_query') : '' - ))); + ])); } /** @@ -276,15 +276,15 @@ class Root implements ControllerProviderInterface */ private function getGridProperty() { - return array( - array('w' => '3', 'h' => '2', 'name' => '3*2', 'selected' => '0'), - array('w' => '5', 'h' => '4', 'name' => '5*4', 'selected' => '0'), - array('w' => '4', 'h' => '10', 'name' => '4*10', 'selected' => '0'), - array('w' => '6', 'h' => '3', 'name' => '6*3', 'selected' => '1'), - array('w' => '8', 'h' => '4', 'name' => '8*4', 'selected' => '0'), - array('w' => '1', 'h' => '10', 'name' => 'list*10', 'selected' => '0'), - array('w' => '1', 'h' => '100', 'name' => 'list*100', 'selected' => '0') - ); + return [ + ['w' => '3', 'h' => '2', 'name' => '3*2', 'selected' => '0'], + ['w' => '5', 'h' => '4', 'name' => '5*4', 'selected' => '0'], + ['w' => '4', 'h' => '10', 'name' => '4*10', 'selected' => '0'], + ['w' => '6', 'h' => '3', 'name' => '6*3', 'selected' => '1'], + ['w' => '8', 'h' => '4', 'name' => '8*4', 'selected' => '0'], + ['w' => '1', 'h' => '10', 'name' => 'list*10', 'selected' => '0'], + ['w' => '1', 'h' => '100', 'name' => 'list*100', 'selected' => '0'] + ]; } /** @@ -295,22 +295,22 @@ class Root implements ControllerProviderInterface */ private function getDocumentStorageAccess(Application $app) { - $allDataboxes = $allCollections = array(); + $allDataboxes = $allCollections = []; foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_sbas() as $databox) { if (count($app['phraseanet.appbox']->get_databoxes()) > 0) { - $allDataboxes[$databox->get_sbas_id()] = array('databox' => $databox, 'collections' => array()); + $allDataboxes[$databox->get_sbas_id()] = ['databox' => $databox, 'collections' => []]; } if (count($databox->get_collections()) > 0) { - foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { + foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]) as $coll) { $allDataboxes[$databox->get_sbas_id()]['collections'][$coll->get_base_id()] = $coll; $allCollections[$coll->get_base_id()] = $coll; } } } - return array('databoxes' => $allDataboxes, 'collections' => $allCollections); + return ['databoxes' => $allDataboxes, 'collections' => $allCollections]; } /** @@ -321,16 +321,16 @@ class Root implements ControllerProviderInterface */ private function getTabSetup(Application $app) { - $tong = array( + $tong = [ $app['phraseanet.registry']->get('GV_ong_search') => 1, $app['phraseanet.registry']->get('GV_ong_advsearch') => 2, $app['phraseanet.registry']->get('GV_ong_topics') => 3 - ); + ]; unset($tong[0]); if (count($tong) == 0) { - $tong = array(1 => 1); + $tong = [1 => 1]; } ksort($tong); @@ -348,7 +348,7 @@ class Root implements ControllerProviderInterface { $cssPath = __DIR__ . '/../../../../../www/skins/client/'; - $css = array(); + $css = []; $cssFile = $app['authentication']->getUser()->getPrefs('client_css'); $finder = new Finder(); @@ -387,8 +387,8 @@ class Root implements ControllerProviderInterface $query .= $clientQuery; } - $opAdv = $request->request->get('opAdv', array()); - $queryAdv = $request->request->get('qryAdv', array()); + $opAdv = $request->request->get('opAdv', []); + $queryAdv = $request->request->get('qryAdv', []); if (count($opAdv) > 0 && count($opAdv) == count($queryAdv)) { foreach ($opAdv as $opId => $op) { @@ -423,7 +423,7 @@ class Root implements ControllerProviderInterface return $this->getPublicationStartPage($app); } - if (in_array($startPage, array('QUERY', 'LAST_QUERY'))) { + if (in_array($startPage, ['QUERY', 'LAST_QUERY'])) { return $this->getQueryStartPage($app); } @@ -438,7 +438,7 @@ class Root implements ControllerProviderInterface */ private function getQueryStartPage(Application $app) { - $collections = $queryParameters = array(); + $collections = $queryParameters = []; $searchSet = json_decode($app['authentication']->getUser()->getPrefs('search')); @@ -456,11 +456,11 @@ class Root implements ControllerProviderInterface $queryParameters["pag"] = 0; $queryParameters["search_type"] = SearchEngineOptions::RECORD_RECORD; $queryParameters["qryAdv"] = ''; - $queryParameters["opAdv"] = array(); - $queryParameters["status"] = array(); + $queryParameters["opAdv"] = []; + $queryParameters["status"] = []; $queryParameters["recordtype"] = SearchEngineOptions::TYPE_ALL; $queryParameters["sort"] = $app['phraseanet.registry']->get('GV_phrasea_sort', ''); - $queryParameters["infield"] = array(); + $queryParameters["infield"] = []; $queryParameters["ord"] = SearchEngineOptions::SORT_MODE_DESC; $subRequest = Request::create('/client/query/', 'POST', $queryParameters); @@ -476,10 +476,10 @@ class Root implements ControllerProviderInterface */ private function getPublicationStartPage(Application $app) { - return $app['twig']->render('client/home_inter_pub_basket.html.twig', array( + return $app['twig']->render('client/home_inter_pub_basket.html.twig', [ 'feeds' => Aggregate::createFromUser($app, $app['authentication']->getUser()), 'image_size' => (int) $app['authentication']->getUser()->getPrefs('images_size') - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Controller/Lightbox.php b/lib/Alchemy/Phrasea/Controller/Lightbox.php index 868ce57ec2..a6a58091af 100644 --- a/lib/Alchemy/Phrasea/Controller/Lightbox.php +++ b/lib/Alchemy/Phrasea/Controller/Lightbox.php @@ -53,11 +53,11 @@ class Lightbox implements ControllerProviderInterface } switch ($datas['type']) { case \random::TYPE_FEED_ENTRY: - return $app->redirectPath('lightbox_feed_entry', array('entry_id' => $datas['datas'])); + return $app->redirectPath('lightbox_feed_entry', ['entry_id' => $datas['datas']]); break; case \random::TYPE_VALIDATE: case \random::TYPE_VIEW: - return $app->redirectPath('lightbox_validation', array('basket' => $datas['datas'])); + return $app->redirectPath('lightbox_validation', ['basket' => $datas['datas']]); break; } }); @@ -88,11 +88,11 @@ class Lightbox implements ControllerProviderInterface $template = 'lightbox/IE6/index.html.twig'; } - return new Response($app['twig']->render($template, array( + return new Response($app['twig']->render($template, [ 'baskets_collection' => $basket_collection, 'module_name' => 'Lightbox', 'module' => 'lightbox' - ) + ] )); }) ->bind('lightbox'); @@ -107,10 +107,10 @@ class Lightbox implements ControllerProviderInterface ->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement') ->findUserElement($sselcont_id, $app['authentication']->getUser()); - $parameters = array( + $parameters = [ 'basket_element' => $basketElement, 'module_name' => '', - ); + ]; return $app['twig']->render('lightbox/note_form.html.twig', $parameters); }) @@ -123,10 +123,10 @@ class Lightbox implements ControllerProviderInterface $BasketElement = $repository->findUserElement($sselcont_id, $app['authentication']->getUser()); if ($app['browser']->isMobile()) { - $output = $app['twig']->render('lightbox/basket_element.html.twig', array( + $output = $app['twig']->render('lightbox/basket_element.html.twig', [ 'basket_element' => $BasketElement, 'module_name' => $BasketElement->getRecord($app)->get_title() - ) + ] ); return new Response($output); @@ -145,16 +145,16 @@ class Lightbox implements ControllerProviderInterface $Basket = $BasketElement->getBasket(); - $ret = array(); + $ret = []; $ret['number'] = $BasketElement->getRecord($app)->get_number(); $ret['title'] = $BasketElement->getRecord($app)->get_title(); - $ret['preview'] = $app['twig']->render($template_preview, array('record' => $BasketElement->getRecord($app), 'not_wrapped' => true)); - $ret['options_html'] = $app['twig']->render($template_options, array('basket_element' => $BasketElement)); - $ret['agreement_html'] = $app['twig']->render($template_agreement, array('basket' => $Basket, 'basket_element' => $BasketElement)); - $ret['selector_html'] = $app['twig']->render($template_selector, array('basket_element' => $BasketElement)); - $ret['note_html'] = $app['twig']->render($template_note, array('basket_element' => $BasketElement)); - $ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $BasketElement->getRecord($app))); + $ret['preview'] = $app['twig']->render($template_preview, ['record' => $BasketElement->getRecord($app), 'not_wrapped' => true]); + $ret['options_html'] = $app['twig']->render($template_options, ['basket_element' => $BasketElement]); + $ret['agreement_html'] = $app['twig']->render($template_agreement, ['basket' => $Basket, 'basket_element' => $BasketElement]); + $ret['selector_html'] = $app['twig']->render($template_selector, ['basket_element' => $BasketElement]); + $ret['note_html'] = $app['twig']->render($template_note, ['basket_element' => $BasketElement]); + $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $BasketElement->getRecord($app)]); return $app->json($ret); } @@ -168,10 +168,10 @@ class Lightbox implements ControllerProviderInterface $item = $entry->getItem($item_id); if ($app['browser']->isMobile()) { - $output = $app['twig']->render('lightbox/feed_element.html.twig', array( + $output = $app['twig']->render('lightbox/feed_element.html.twig', [ 'feed_element' => $item, 'module_name' => $item->getRecord($app)->get_title() - ) + ] ); return new Response($output); @@ -184,13 +184,13 @@ class Lightbox implements ControllerProviderInterface $template_options = 'lightbox/IE6/feed_options_box.html.twig'; } - $ret = array(); + $ret = []; $ret['number'] = $item->getRecord($app)->get_number(); $ret['title'] = $item->getRecord($app)->get_title(); - $ret['preview'] = $app['twig']->render($template_preview, array('record' => $item->getRecord($app), 'not_wrapped' => true)); - $ret['options_html'] = $app['twig']->render($template_options, array('feed_element' => $item)); - $ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $item->getRecord($app))); + $ret['preview'] = $app['twig']->render($template_preview, ['record' => $item->getRecord($app), 'not_wrapped' => true]); + $ret['options_html'] = $app['twig']->render($template_options, ['feed_element' => $item]); + $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $item->getRecord($app)]); $ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = ''; @@ -233,13 +233,13 @@ class Lightbox implements ControllerProviderInterface $template = 'lightbox/IE6/validate.html.twig'; } - $response = new Response($app['twig']->render($template, array( + $response = new Response($app['twig']->render($template, [ 'baskets_collection' => $basket_collection, 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') - ) + ] )); $response->setCharset('UTF-8'); @@ -280,13 +280,13 @@ class Lightbox implements ControllerProviderInterface $template = 'lightbox/IE6/validate.html.twig'; } - $response = new Response($app['twig']->render($template, array( + $response = new Response($app['twig']->render($template, [ 'baskets_collection' => $basket_collection, 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') - ) + ] )); $response->setCharset('UTF-8'); @@ -314,13 +314,13 @@ class Lightbox implements ControllerProviderInterface $content = $feed_entry->getItems(); $first = $content->first(); - $output = $app['twig']->render($template, array( + $output = $app['twig']->render($template, [ 'feed_entry' => $feed_entry, 'first_item' => $first, 'local_title' => $feed_entry->getTitle(), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') - ) + ] ); $response = new Response($output, 200); $response->setCharset('UTF-8'); @@ -331,13 +331,13 @@ class Lightbox implements ControllerProviderInterface ->assert('entry_id', '\d+'); $controllers->get('/ajax/LOAD_REPORT/{basket}/', function (SilexApplication $app, Basket $basket) { - return new Response($app['twig']->render('lightbox/basket_content_report.html.twig', array('basket' => $basket))); + return new Response($app['twig']->render('lightbox/basket_content_report.html.twig', ['basket' => $basket])); }) ->bind('lightbox_ajax_report') ->assert('basket', '\d+'); $controllers->post('/ajax/SET_NOTE/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { - $output = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')); + $output = ['error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')]; $request = $app['request']; $note = $request->request->get('note'); @@ -359,15 +359,15 @@ class Lightbox implements ControllerProviderInterface $app['EM']->flush(); if ($app['browser']->isMobile()) { - $datas = $app['twig']->render('lightbox/sc_note.html.twig', array('basket_element' => $basket_element)); + $datas = $app['twig']->render('lightbox/sc_note.html.twig', ['basket_element' => $basket_element]); - $output = array('error' => false, 'datas' => $datas); + $output = ['error' => false, 'datas' => $datas]; } else { $template = 'lightbox/sc_note.html.twig'; - $datas = $app['twig']->render($template, array('basket_element' => $basket_element)); + $datas = $app['twig']->render($template, ['basket_element' => $basket_element]); - $output = array('error' => false, 'datas' => $datas); + $output = ['error' => false, 'datas' => $datas]; } return $app->json($output); @@ -387,11 +387,11 @@ class Lightbox implements ControllerProviderInterface $releasable = false; try { - $ret = array( + $ret = [ 'error' => true, 'releasable' => false, 'datas' => _('Erreur lors de la mise a jour des donnes ') - ); + ]; $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement'); @@ -423,11 +423,11 @@ class Lightbox implements ControllerProviderInterface $releasable = _('Do you want to send your report ?'); } - $ret = array( + $ret = [ 'error' => false , 'datas' => '' , 'releasable' => $releasable - ); + ]; } catch (ControllerException $e) { $ret['datas'] = $e->getMessage(); } @@ -439,7 +439,7 @@ class Lightbox implements ControllerProviderInterface $controllers->post('/ajax/SET_RELEASE/{basket}/', function (SilexApplication $app, Basket $basket) { - $datas = array('error' => true, 'datas' => ''); + $datas = ['error' => true, 'datas' => '']; try { if (!$basket->getValidation()) { @@ -466,20 +466,20 @@ class Lightbox implements ControllerProviderInterface $participant = $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app); $expires = new \DateTime('+10 days'); - $url = $app->url('lightbox', array('LOG' => $app['tokens']->getUrlToken( + $url = $app->url('lightbox', ['LOG' => $app['tokens']->getUrlToken( \random::TYPE_VALIDATE , $basket->getValidation()->getInitiator($app)->get_id() , $expires , $basket->getId() - ))); + )]); $to = $basket->getValidation()->getInitiator($app)->get_id(); - $params = array( + $params = [ 'ssel_id' => $basket->getId(), 'from' => $app['authentication']->getUser()->get_id(), 'url' => $url, 'to' => $to - ); + ]; $app['events-manager']->trigger('__VALIDATION_DONE__', $params); @@ -488,9 +488,9 @@ class Lightbox implements ControllerProviderInterface $app['EM']->merge($participant); $app['EM']->flush(); - $datas = array('error' => false, 'datas' => _('Envoie avec succes')); + $datas = ['error' => false, 'datas' => _('Envoie avec succes')]; } catch (ControllerException $e) { - $datas = array('error' => true, 'datas' => $e->getMessage()); + $datas = ['error' => true, 'datas' => $e->getMessage()]; } return $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Minifier.php b/lib/Alchemy/Phrasea/Controller/Minifier.php index 00ff222346..5e1debcb2d 100644 --- a/lib/Alchemy/Phrasea/Controller/Minifier.php +++ b/lib/Alchemy/Phrasea/Controller/Minifier.php @@ -80,7 +80,7 @@ class Minifier implements ControllerProviderInterface * array('//static' => 'D:\\staticStorage') // Windows * */ - $min_symlinks = array(); + $min_symlinks = []; /** * If you upload files from Windows to a non-Windows server, Windows may report diff --git a/lib/Alchemy/Phrasea/Controller/Permalink.php b/lib/Alchemy/Phrasea/Controller/Permalink.php index 75cb69d4d7..a992319447 100644 --- a/lib/Alchemy/Phrasea/Controller/Permalink.php +++ b/lib/Alchemy/Phrasea/Controller/Permalink.php @@ -33,7 +33,7 @@ class Permalink extends AbstractDelivery $that = $this; $retrieveRecord = function ($app, $databox, $token, $record_id, $subdef) { - if (in_array($subdef, array(\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL)) && $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedItem')->isRecordInPublicFeed($app, $databox->get_sbas_id(), $record_id)) { + if (in_array($subdef, [\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL]) && $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedItem')->isRecordInPublicFeed($app, $databox->get_sbas_id(), $record_id)) { $record = $databox->get_record($record_id); } else { $record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef); @@ -51,13 +51,13 @@ class Permalink extends AbstractDelivery $record = $retrieveRecord($app, $databox, $token, $record_id, $subdef); - $params = array( + $params = [ 'subdef_name' => $subdef , 'module_name' => 'overview' , 'module' => 'overview' , 'view' => 'overview' , 'record' => $record - ); + ]; return $app['twig']->render('overview.html.twig', $params); }; @@ -86,7 +86,7 @@ class Permalink extends AbstractDelivery } $response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); - $linkToCaption = $app->url("permalinks_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token)); + $linkToCaption = $app->url("permalinks_caption", ['sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token]); $response->headers->set('Link', $linkToCaption); return $response; @@ -108,7 +108,7 @@ class Permalink extends AbstractDelivery $response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); - $linkToCaption = $app->url("permalinks_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token)); + $linkToCaption = $app->url("permalinks_caption", ['sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token]); $response->headers->set('Link', $linkToCaption); return $response; @@ -121,7 +121,7 @@ class Permalink extends AbstractDelivery $record = $retrieveRecord($app, $databox, $token, $record_id, \databox_subdef::CLASS_THUMBNAIL); $caption = $record->get_caption(); - return new Response($caption->serialize(\caption_record::SERIALIZE_JSON), 200, array("Content-Type" => 'application/json')); + return new Response($caption->serialize(\caption_record::SERIALIZE_JSON), 200, ["Content-Type" => 'application/json']); }) ->assert('sbas_id', '\d+')->assert('record_id', '\d+') ->bind('permalinks_caption'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php index 2d44f08bf8..ed931703de 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php @@ -111,10 +111,10 @@ class BasketController implements ControllerProviderInterface } } - $params = array( + $params = [ 'basket' => $basket, 'ordre' => $request->query->get('order') - ); + ]; return $app['twig']->render('prod/WorkZone/Basket.html.twig', $params); } @@ -152,17 +152,17 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); if ($request->getRequestFormat() === 'json') { - $data = array( + $data = [ 'success' => true , 'message' => _('Basket created') - , 'basket' => array( + , 'basket' => [ 'id' => $Basket->getId() - ) - ); + ] + ]; return $app->json($data); } else { - return $app->redirectPath('prod_baskets_basket', array('basket' => $Basket->getId())); + return $app->redirectPath('prod_baskets_basket', ['basket' => $Basket->getId()]); } } @@ -171,10 +171,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->remove($basket); $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => _('Basket has been deleted') - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -194,10 +194,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => _('Record removed from basket') - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -227,11 +227,11 @@ class BasketController implements ControllerProviderInterface $msg = _('An error occurred'); } - $data = array( + $data = [ 'success' => $success , 'message' => $msg - , 'basket' => array('id' => $basket->getId()) - ); + , 'basket' => ['id' => $basket->getId()] + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -242,17 +242,17 @@ class BasketController implements ControllerProviderInterface public function displayUpdateForm(Application $app, BasketEntity $basket) { - return $app['twig']->render('prod/Baskets/Update.html.twig', array('basket' => $basket)); + return $app['twig']->render('prod/Baskets/Update.html.twig', ['basket' => $basket]); } public function displayReorderForm(Application $app, BasketEntity $basket) { - return $app['twig']->render('prod/Baskets/Reorder.html.twig', array('basket' => $basket)); + return $app['twig']->render('prod/Baskets/Reorder.html.twig', ['basket' => $basket]); } public function reorder(Application $app, BasketEntity $basket) { - $ret = array('success' => false, 'message' => _('An error occured')); + $ret = ['success' => false, 'message' => _('An error occured')]; try { $order = $app['request']->request->get('element'); @@ -266,7 +266,7 @@ class BasketController implements ControllerProviderInterface } $app['EM']->flush(); - $ret = array('success' => true, 'message' => _('Basket updated')); + $ret = ['success' => true, 'message' => _('Basket updated')]; } catch (\Exception $e) { } @@ -289,11 +289,11 @@ class BasketController implements ControllerProviderInterface $message = _('Basket has been unarchived'); } - $data = array( + $data = [ 'success' => true , 'archive' => $archive_status , 'message' => $message - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -338,10 +338,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => sprintf(_('%d records added'), $n) - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -370,10 +370,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => sprintf(_('%d records moved'), $n) - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index f04a362d46..396d8108df 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -100,12 +100,12 @@ class Bridge implements ControllerProviderInterface public function doPostManager(Application $app, Request $request) { $route = new RecordHelper\Bridge($app, $request); - $params = array( + $params = [ 'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $app['authentication']->getUser()), 'available_apis' => \Bridge_Api::get_availables($app), 'route' => $route, 'current_account_id' => '', - ); + ]; return $app['twig']->render('prod/actions/Bridge/index.html.twig', $params); } @@ -147,7 +147,7 @@ class Bridge implements ControllerProviderInterface $error_message = $e->getMessage(); } - $params = array('error_message' => $error_message); + $params = ['error_message' => $error_message]; return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params); } @@ -158,10 +158,10 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); $account->get_api()->get_connector()->disconnect(); - return $app->redirectPath('bridge_load_elements', array( + return $app->redirectPath('bridge_load_elements', [ 'account_id' => $account_id, 'type' => $account->get_api()->get_connector()->get_default_element_type(), - )); + ]); } public function doPostAccountDelete(Application $app, Request $request, $account_id) @@ -183,7 +183,7 @@ class Bridge implements ControllerProviderInterface $message = _('Something went wrong, please contact an administrator'); } - return $app->json(array('success' => $success, 'message' => $message)); + return $app->json(['success' => $success, 'message' => $message]); } public function doGetloadRecords(Application $app, Request $request, $account_id) @@ -196,13 +196,13 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); - $params = array( + $params = [ 'adapter_action' => 'load-records' , 'account' => $account , 'elements' => $elements , 'error_message' => $request->query->get('error') , 'notice_message' => $request->query->get('notice') - ); + ]; return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params); } @@ -218,14 +218,14 @@ class Bridge implements ControllerProviderInterface $elements = $account->get_api()->list_elements($type, $offset_start, $quantity); - $params = array( + $params = [ 'action_type' => $type, 'adapter_action' => 'load-elements', 'account' => $account, 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), - ); + ]; return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params); } @@ -240,14 +240,14 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); $elements = $account->get_api()->list_containers($type, $offset_start, $quantity); - $params = array( + $params = [ 'action_type' => $type, 'adapter_action' => 'load-containers', 'account' => $account, 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), - ); + ]; return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params); } @@ -257,11 +257,11 @@ class Bridge implements ControllerProviderInterface $account = \Bridge_Account::load_account($app, $account_id); $this->requireConnection($app, $account); - $elements = $request->query->get('elements_list', array()); + $elements = $request->query->get('elements_list', []); $elements = is_array($elements) ? $elements : explode(';', $elements); $destination = $request->query->get('destination'); - $route_params = array(); + $route_params = []; $class = $account->get_api()->get_connector()->get_object_class_from_type($element_type); switch ($action) { @@ -270,25 +270,25 @@ class Bridge implements ControllerProviderInterface case 'modify': if (count($elements) != 1) { - return $app->redirectPath('bridge_load_elements', array( + return $app->redirectPath('bridge_load_elements', [ 'account_id' => $account_id, 'type' => $element_type, 'page' => '', 'error' => _('Vous ne pouvez pas editer plusieurs elements simultanement'), - )); + ]); } foreach ($elements as $element_id) { if ($class === \Bridge_Api_Interface::OBJECT_CLASS_ELEMENT) { - $route_params = array('element' => $account->get_api()->get_element_from_id($element_id, $element_type)); + $route_params = ['element' => $account->get_api()->get_element_from_id($element_id, $element_type)]; } if ($class === \Bridge_Api_Interface::OBJECT_CLASS_CONTAINER) { - $route_params = array('element' => $account->get_api()->get_container_from_id($element_id, $element_type)); + $route_params = ['element' => $account->get_api()->get_container_from_id($element_id, $element_type)]; } } break; case 'moveinto': - $route_params = array('containers' => $account->get_api()->list_containers($destination, 0, 0)); + $route_params = ['containers' => $account->get_api()->list_containers($destination, 0, 0)]; break; case 'deleteelement': @@ -299,7 +299,7 @@ class Bridge implements ControllerProviderInterface break; } - $params = array( + $params = [ 'account' => $account, 'destination' => $destination, 'element_type' => $element_type, @@ -309,7 +309,7 @@ class Bridge implements ControllerProviderInterface 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), - ); + ]; $params = array_merge($params, $route_params); $template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig'; @@ -323,7 +323,7 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); - $elements = $request->request->get('elements_list', array()); + $elements = $request->request->get('elements_list', []); $elements = is_array($elements) ? $elements : explode(';', $elements); $destination = $request->request->get('destination'); @@ -342,7 +342,7 @@ class Bridge implements ControllerProviderInterface } if (count($errors) > 0) { - $params = array( + $params = [ 'element' => $account->get_api()->get_element_from_id($element_id, $element_type), 'account' => $account, 'destination' => $destination, @@ -353,7 +353,7 @@ class Bridge implements ControllerProviderInterface 'error_message' => _('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), - ); + ]; $template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig'; @@ -417,14 +417,14 @@ class Bridge implements ControllerProviderInterface $route->grep_records($account->get_api()->acceptable_records()); - $params = array( + $params = [ 'route' => $route, 'account' => $account, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), 'constraint_errors' => null, 'adapter_action' => 'upload', - ); + ]; return $app['twig']->render( 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params @@ -433,7 +433,7 @@ class Bridge implements ControllerProviderInterface public function doPostUpload(Application $app, Request $request) { - $errors = array(); + $errors = []; $account = \Bridge_Account::load_account($app, $request->request->get('account_id')); $this->requireConnection($app, $account); @@ -448,14 +448,14 @@ class Bridge implements ControllerProviderInterface } if (count($errors) > 0) { - $params = array( + $params = [ 'route' => $route, 'account' => $account, 'error_message' => _('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), 'adapter_action' => 'upload', - ); + ]; return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php b/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php index e16bed26d4..d01b1197d7 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php @@ -63,7 +63,7 @@ class DoDownload implements ControllerProviderInterface $app->abort(500, 'Invalid datas'); } - $records = array(); + $records = []; foreach ($list['files'] as $file) { if (!is_array($file) || !isset($file['base_id']) || !isset($file['record_id'])) { @@ -81,14 +81,14 @@ class DoDownload implements ControllerProviderInterface } return new Response($app['twig']->render( - '/prod/actions/Download/prepare.html.twig', array( + '/prod/actions/Download/prepare.html.twig', [ 'module_name' => _('Export'), 'module' => _('Export'), 'list' => $list, 'records' => $records, 'token' => $token, 'anonymous' => $request->query->get('anonymous', false) - ))); + ])); } /** @@ -153,17 +153,17 @@ class DoDownload implements ControllerProviderInterface try { $datas = $app['tokens']->helloToken($token); } catch (NotFoundHttpException $e) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => 'Invalid token' - )); + ]); } if (false === $list = @unserialize((string) $datas['datas'])) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => 'Invalid datas' - )); + ]); } set_time_limit(0); @@ -178,9 +178,9 @@ class DoDownload implements ControllerProviderInterface sprintf($app['root.path'] . '/tmp/download/%s.zip', $datas['value']) // Dest file ); - return $app->json(array( + return $app->json([ 'success' => true, 'message' => '' - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Download.php b/lib/Alchemy/Phrasea/Controller/Prod/Download.php index 8f44b98a93..8006d6ecba 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Download.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Download.php @@ -48,7 +48,7 @@ class Download implements ControllerProviderInterface { $lst = $request->request->get('lst'); $ssttid = $request->request->get('ssttid', ''); - $subdefs = $request->request->get('obj', array()); + $subdefs = $request->request->get('obj', []); $download = new \set_export($app, $lst, $ssttid); @@ -77,14 +77,14 @@ class Download implements ControllerProviderInterface throw new \RuntimeException('Download token could not be generated'); } - $app['events-manager']->trigger('__DOWNLOAD__', array( + $app['events-manager']->trigger('__DOWNLOAD__', [ 'lst' => $lst, 'downloader' => $app['authentication']->getUser()->get_id(), 'subdefs' => $subdefs, 'from_basket' => $ssttid, 'export_file' => $download->getExportName() - )); + ]); - return $app->redirectPath('prepare_download', array('token' => $token)); + return $app->redirectPath('prepare_download', ['token' => $token]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index bc54f51928..5be280301e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -39,11 +39,11 @@ class Edit implements ControllerProviderInterface $controllers->post('/', function (Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']); $thesaurus = false; $status = $ids = $elements = $suggValues = - $fields = $JSFields = array(); + $fields = $JSFields = []; $databox = null; $multipleDataboxes = count($records->databoxes()) > 1; @@ -60,12 +60,12 @@ class Edit implements ControllerProviderInterface $separator = $meta->get_separator(); - $JSFields[$meta->get_id()] = array( + $JSFields[$meta->get_id()] = [ 'meta_struct_id' => $meta->get_id() , 'name' => $meta->get_name() , '_status' => 0 , '_value' => '' - , '_sgval' => array() + , '_sgval' => [] , 'required' => $meta->is_required() , 'label' => $meta->get_label($app['locale.I18n']) , 'readonly' => $meta->is_readonly() @@ -79,7 +79,7 @@ class Edit implements ControllerProviderInterface , 'separator' => $separator , 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null , 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false - ); + ]; if (trim($meta->get_tbranch()) !== '') { $thesaurus = true; @@ -92,7 +92,7 @@ class Edit implements ControllerProviderInterface foreach ($records->collections() as $collection) { /* @var $record record_adapter */ - $suggValues['b' . $collection->get_base_id()] = array(); + $suggValues['b' . $collection->get_base_id()] = []; if ($sxe = simplexml_load_string($collection->get_prefs())) { $z = $sxe->xpath('/baseprefs/sugestedValues'); @@ -107,7 +107,7 @@ class Edit implements ControllerProviderInterface continue; } - $suggValues['b' . $collection->get_base_id()][$field->get_id()] = array(); + $suggValues['b' . $collection->get_base_id()][$field->get_id()] = []; foreach ($vi->value as $oneValue) { $suggValues['b' . $collection->get_base_id()][$field->get_id()][] = (string) $oneValue; @@ -124,7 +124,7 @@ class Edit implements ControllerProviderInterface $dbstatus = \databox_status::getDisplayStatus($app); if (isset($dbstatus[$databox->get_sbas_id()])) { foreach ($dbstatus[$databox->get_sbas_id()] as $n => $statbit) { - $status[$n] = array(); + $status[$n] = []; $status[$n]['label0'] = $statbit['labels_off_i18n'][$app['locale.I18n']]; $status[$n]['label1'] = $statbit['labels_on_i18n'][$app['locale.I18n']]; $status[$n]['img_off'] = $statbit['img_off']; @@ -138,24 +138,24 @@ class Edit implements ControllerProviderInterface * generate javascript elements */ foreach ($databox->get_meta_structure() as $field) { - $databox_fields[$field->get_id()] = array( + $databox_fields[$field->get_id()] = [ 'dirty' => false, 'meta_struct_id' => $field->get_id(), - 'values' => array() - ); + 'values' => [] + ]; } foreach ($records as $record) { $indice = $record->get_number(); - $elements[$indice] = array( + $elements[$indice] = [ 'bid' => $record->get_base_id(), 'rid' => $record->get_record_id(), 'sselcont_id' => null, '_selected' => false, 'fields' => $databox_fields - ); + ]; - $elements[$indice]['statbits'] = array(); + $elements[$indice]['statbits'] = []; if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'chgstatus')) { foreach ($status as $n => $s) { $tmp_val = substr(strrev($record->get_status()), $n, 1); @@ -172,7 +172,7 @@ class Edit implements ControllerProviderInterface continue; } - $values = array(); + $values = []; foreach ($field->get_values() as $value) { $type = $id = null; @@ -181,38 +181,38 @@ class Edit implements ControllerProviderInterface $id = $value->getVocabularyId(); } - $values[$value->getId()] = array( + $values[$value->getId()] = [ 'meta_id' => $value->getId(), 'value' => $value->getValue(), 'vocabularyId' => $id, 'vocabularyType' => $type - ); + ]; } - $elements[$indice]['fields'][$meta_struct_id] = array( + $elements[$indice]['fields'][$meta_struct_id] = [ 'dirty' => false, 'meta_struct_id' => $meta_struct_id, 'values' => $values - ); + ]; } - $elements[$indice]['subdefs'] = array(); + $elements[$indice]['subdefs'] = []; $thumbnail = $record->get_thumbnail(); - $elements[$indice]['subdefs']['thumbnail'] = array( + $elements[$indice]['subdefs']['thumbnail'] = [ 'url' => $thumbnail->get_url() , 'w' => $thumbnail->get_width() , 'h' => $thumbnail->get_height() - ); + ]; - $elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', array('record' => $record)); + $elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', ['record' => $record]); $elements[$indice]['type'] = $record->get_type(); } } - $params = array( + $params = [ 'multipleDataboxes' => $multipleDataboxes, 'recordsRequest' => $records, 'databox' => $databox, @@ -224,13 +224,13 @@ class Edit implements ControllerProviderInterface 'fields' => $fields, 'JSonSuggValues' => json_encode($suggValues), 'thesaurus' => $thesaurus, - ); + ]; return $app['twig']->render('prod/actions/edit_default.html.twig', $params); }); $controllers->get('/vocabulary/{vocabulary}/', function (Application $app, Request $request, $vocabulary) { - $datas = array('success' => false, 'message' => '', 'results' => array()); + $datas = ['success' => false, 'message' => '', 'results' => []]; $sbas_id = (int) $request->query->get('sbas_id'); @@ -251,15 +251,15 @@ class Edit implements ControllerProviderInterface $results = $VC->find($query, $app['authentication']->getUser(), $databox); - $list = array(); + $list = []; foreach ($results as $Term) { /* @var $Term \Alchemy\Phrasea\Vocabulary\Term */ - $list[] = array( + $list[] = [ 'id' => $Term->getId(), 'context' => $Term->getContext(), 'value' => $Term->getValue(), - ); + ]; } $datas['success'] = true; @@ -270,7 +270,7 @@ class Edit implements ControllerProviderInterface $controllers->post('/apply/', function (Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']); if (count($records->databoxes()) !== 1) { throw new \Exception('Unable to edit on multiple databoxes'); @@ -289,7 +289,7 @@ class Edit implements ControllerProviderInterface } foreach ($newsubdef_reg->get_subdefs() as $name => $value) { - if (!in_array($name, array('thumbnail', 'preview'))) { + if (!in_array($name, ['thumbnail', 'preview'])) { continue; } $media = $app['mediavorus']->guess($value->get_pathfile()); @@ -307,7 +307,7 @@ class Edit implements ControllerProviderInterface } if (!is_array($request->request->get('mds'))) { - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); } $databoxes = $records->databoxes(); @@ -354,7 +354,7 @@ class Edit implements ControllerProviderInterface * todo : this should not work */ if ($write_edit_el instanceof \databox_field) { - $fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()), true); + $fields = $record->get_caption()->get_fields([$write_edit_el->get_name()], true); $field = array_pop($fields); $meta_id = null; @@ -364,21 +364,21 @@ class Edit implements ControllerProviderInterface $meta_id = array_pop($values)->getId(); } - $metas = array( - array( + $metas = [ + [ 'meta_struct_id' => $write_edit_el->get_id(), 'meta_id' => $meta_id, 'value' => $date_obj->format('Y-m-d h:i:s'), - ) - ); + ] + ]; $record->set_metadatas($metas, true); } $newstat = $record->get_status(); $statbits = ltrim($statbits, 'x'); - if (!in_array($statbits, array('', 'null'))) { - $mask_and = ltrim(str_replace(array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0'); + if (!in_array($statbits, ['', 'null'])) { + $mask_and = ltrim(str_replace(['x', '0', '1', 'z'], ['1', 'z', '0', '1'], $statbits), '0'); if ($mask_and != '') { $newstat = \databox_status::operation_and_not($app, $newstat, $mask_and); } @@ -407,7 +407,7 @@ class Edit implements ControllerProviderInterface } } - return $app->json(array('success' => true)); + return $app->json(['success' => true]); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index fccb4772b2..fa20e9cefe 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -67,13 +67,13 @@ class Export implements ControllerProviderInterface $request->request->get('story') ); - return new Response($app['twig']->render('common/dialog_export.html.twig', array( + return new Response($app['twig']->render('common/dialog_export.html.twig', [ 'download' => $download, 'ssttid' => $request->request->get('ssel'), 'lst' => $download->serialize_list(), 'default_export_title' => $app['phraseanet.registry']->get('GV_default_export_title'), 'choose_export_title' => $app['phraseanet.registry']->get('GV_choose_export_title') - ))); + ])); } /** @@ -100,10 +100,10 @@ class Export implements ControllerProviderInterface $msg = sprintf(_('Error while connecting to FTP')); } - return $app->json(array( + return $app->json([ 'success' => $success, 'message' => $msg - )); + ]); } /** @@ -116,7 +116,7 @@ class Export implements ControllerProviderInterface { $download = new \set_exportftp($app, $request->request->get('lst'), $request->request->get('ssttid')); - $mandatoryParameters = array('address', 'login', 'dest_folder', 'prefix_folder', 'obj'); + $mandatoryParameters = ['address', 'login', 'dest_folder', 'prefix_folder', 'obj']; foreach ($mandatoryParameters as $parameter) { if (!$request->request->get($parameter)) { @@ -125,10 +125,10 @@ class Export implements ControllerProviderInterface } if (count($download->get_display_ftp()) == 0) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => _("You do not have required rights to send these documents over FTP") - )); + ]); } try { @@ -153,15 +153,15 @@ class Export implements ControllerProviderInterface $request->request->get('logfile') ); - return $app->json(array( + return $app->json([ 'success' => true, 'message' => _('Export saved in the waiting queue') - )); + ]); } catch (\Exception $e) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => _('Something went wrong') - )); + ]); } } @@ -197,19 +197,19 @@ class Export implements ControllerProviderInterface $list['export_name'] = sprintf("%s.zip", $download->getExportName()); $list['email'] = implode(';', preg_split($separator, $request->request->get("destmail", ""))); - $destMails = array(); + $destMails = []; //get destination mails foreach (explode(";", $list['email']) as $mail) { if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { $destMails[] = $mail; } else { - $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( + $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ 'usr_id' => $app['authentication']->getUser()->get_id(), 'lst' => $lst, 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => \eventsmanager_notify_downloadmailfail::MAIL_NO_VALID - )); + ]); } } @@ -228,7 +228,7 @@ class Export implements ControllerProviderInterface $remaingEmails = $destMails; - $url = $app->url('prepare_download', array('token' => $token, 'anonymous')); + $url = $app->url('prepare_download', ['token' => $token, 'anonymous']); $emitter = new Emitter($app['authentication']->getUser()->get_display_name(), $app['authentication']->getUser()->get_email()); @@ -250,30 +250,30 @@ class Export implements ControllerProviderInterface //some mails failed if (count($remaingEmails) > 0) { foreach ($remaingEmails as $mail) { - $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( + $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ 'usr_id' => $app['authentication']->getUser()->get_id(), 'lst' => $lst, 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => \eventsmanager_notify_downloadmailfail::MAIL_FAIL - )); + ]); } } } elseif (!$token && count($destMails) > 0) { //couldn't generate token foreach ($destMails as $mail) { - $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( + $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ 'usr_id' => $app['authentication']->getUser()->get_id(), 'lst' => $lst, 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => 0 - )); + ]); } } - return $app->json(array( + return $app->json([ 'success' => true, 'message' => '' - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index faf317714f..0dd3fb2b51 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -44,9 +44,9 @@ class Feed implements ControllerProviderInterface $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser( $app['acl']->get($app['authentication']->getUser()) ); - $publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub')); + $publishing = RecordsRequest::fromRequest($app, $request, true, [], ['bas_chupub']); - return $app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds)); + return $app['twig']->render('prod/actions/publish/publish.html.twig', ['publishing' => $publishing, 'feeds' => $feeds]); }); $controllers->post('/entry/create/', function (Application $app, Request $request) { @@ -56,7 +56,7 @@ class Feed implements ControllerProviderInterface $app->abort(404, "Feed not found"); } - $publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(array('feed' => $feed, 'usrId' => $app['authentication']->getUser()->get_id())); + $publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(['feed' => $feed, 'usrId' => $app['authentication']->getUser()->get_id()]); if ('' === $title = trim($request->request->get('title', ''))) { $app->abort(400, "Bad request"); @@ -76,7 +76,7 @@ class Feed implements ControllerProviderInterface $feed->addEntry($entry); - $publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub')); + $publishing = RecordsRequest::fromRequest($app, $request, true, [], ['bas_chupub']); foreach ($publishing as $record) { $item = new FeedItem(); $item->setEntry($entry) @@ -90,9 +90,9 @@ class Feed implements ControllerProviderInterface $app['EM']->persist($feed); $app['EM']->flush(); - $app['events-manager']->trigger('__FEED_ENTRY_CREATE__', array('entry_id' => $entry->getId(), 'notify_email' => (Boolean) $request->request->get('notify')), $entry); + $app['events-manager']->trigger('__FEED_ENTRY_CREATE__', ['entry_id' => $entry->getId(), 'notify_email' => (Boolean) $request->request->get('notify')], $entry); - $datas = array('error' => false, 'message' => false); + $datas = ['error' => false, 'message' => false]; return $app->json($datas); }) @@ -110,7 +110,7 @@ class Feed implements ControllerProviderInterface $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', array('entry' => $entry, 'feeds' => $feeds)); + $datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', ['entry' => $entry, 'feeds' => $feeds]); return new Response($datas); }) @@ -121,7 +121,7 @@ class Feed implements ControllerProviderInterface }); $controllers->post('/entry/{id}/update/', function (Application $app, Request $request, $id) { - $datas = array('error' => true, 'message' => '', 'datas' => ''); + $datas = ['error' => true, 'message' => '', 'datas' => '']; $entry = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedEntry')->find($id); if (null === $entry) { @@ -170,13 +170,13 @@ class Feed implements ControllerProviderInterface $app['EM']->persist($entry); $app['EM']->flush(); - return $app->json(array( + return $app->json([ 'error' => false, 'message' => 'succes', - 'datas' => $app['twig']->render('prod/feeds/entry.html.twig', array( + 'datas' => $app['twig']->render('prod/feeds/entry.html.twig', [ 'entry' => $entry - )) - )); + ]) + ]); }) ->bind('prod_feeds_entry_update') ->assert('id', '\d+')->before(function (Request $request) use ($app) { @@ -184,7 +184,7 @@ class Feed implements ControllerProviderInterface }); $controllers->post('/entry/{id}/delete/', function (Application $app, Request $request, $id) { - $datas = array('error' => true, 'message' => ''); + $datas = ['error' => true, 'message' => '']; $entry = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedEntry')->find($id); @@ -198,7 +198,7 @@ class Feed implements ControllerProviderInterface $app['EM']->remove($entry); $app['EM']->flush(); - return $app->json(array('error' => false, 'message' => 'succes')); + return $app->json(['error' => false, 'message' => 'succes']); }) ->bind('prod_feeds_entry_delete') ->assert('id', '\d+')->before(function (Request $request) use ($app) { @@ -212,11 +212,11 @@ class Feed implements ControllerProviderInterface $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/feeds/feeds.html.twig', array( + $datas = $app['twig']->render('prod/feeds/feeds.html.twig', [ 'feeds' => $feeds, 'feed' => new Aggregate($app['EM'], $feeds), 'page' => $page - )); + ]); return new Response($datas); })->bind('prod_feeds'); @@ -231,7 +231,7 @@ class Feed implements ControllerProviderInterface } $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/feeds/feeds.html.twig', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page)); + $datas = $app['twig']->render('prod/feeds/feeds.html.twig', ['feed' => $feed, 'feeds' => $feeds, 'page' => $page]); return new Response($datas); }) @@ -249,12 +249,12 @@ class Feed implements ControllerProviderInterface null, $renew ); - $output = array( + $output = [ 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

', 'titre' => _('publications::votre rss personnel') - ); + ]; return $app->json($output); })->bind('prod_feeds_subscribe_aggregated'); @@ -268,12 +268,12 @@ class Feed implements ControllerProviderInterface } $link = $app['feed.user-link-generator']->generate($feed, $app['authentication']->getUser(), FeedLinkGenerator::FORMAT_RSS, null, $renew); - $output = array( + $output = [ 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

', 'titre' => _('publications::votre rss personnel') - ); + ]; return $app->json($output); }) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Language.php b/lib/Alchemy/Phrasea/Controller/Prod/Language.php index ea50197e9d..5ff3b4d10f 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Language.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Language.php @@ -29,7 +29,7 @@ class Language implements ControllerProviderInterface $controller->get("/", function (Application $app) { - $out = array(); + $out = []; $out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.'); $out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?'); $out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index b4bcf78643..2e44ab203d 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -87,7 +87,7 @@ class Lazaret implements ControllerProviderInterface */ public function listElement(Application $app, Request $request) { - $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canaddrecord'])); $lazaretFiles = null; @@ -100,7 +100,7 @@ class Lazaret implements ControllerProviderInterface } return $app['twig']->render( - 'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles) + 'prod/upload/lazaret.html.twig', ['lazaretFiles' => $lazaretFiles] ); } @@ -115,7 +115,7 @@ class Lazaret implements ControllerProviderInterface */ public function getElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; $lazaretFile = $app['EM']->find('Alchemy\Phrasea\Model\Entities\LazaretFile', $file_id); @@ -126,7 +126,7 @@ class Lazaret implements ControllerProviderInterface return $app->json($ret); } - $file = array( + $file = [ 'filename' => $lazaretFile->getOriginalName(), 'base_id' => $lazaretFile->getBaseId(), 'created' => $lazaretFile->getCreated()->format(\DateTime::ATOM), @@ -134,7 +134,7 @@ class Lazaret implements ControllerProviderInterface 'pathname' => $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(), 'sha256' => $lazaretFile->getSha256(), 'uuid' => $lazaretFile->getUuid(), - ); + ]; $ret['result'] = $file; $ret['success'] = true; @@ -157,11 +157,11 @@ class Lazaret implements ControllerProviderInterface */ public function addElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; //Optional parameter $keepAttributes = !!$request->request->get('keep_attributes', false); - $attributesToKeep = $request->request->get('attributes', array()); + $attributesToKeep = $request->request->get('attributes', []); //Mandatory parameter if (null === $request->request->get('bas_id')) { @@ -258,7 +258,7 @@ class Lazaret implements ControllerProviderInterface } try { - $app['filesystem']->remove(array($lazaretFileName, $lazaretThumbFileName)); + $app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]); } catch (IOException $e) { } @@ -277,7 +277,7 @@ class Lazaret implements ControllerProviderInterface */ public function denyElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; $lazaretFile = $app['EM']->find('Alchemy\Phrasea\Model\Entities\LazaretFile', $file_id); /* @var $lazaretFile LazaretFile */ @@ -306,7 +306,7 @@ class Lazaret implements ControllerProviderInterface $app['EM']->flush(); try { - $app['filesystem']->remove(array($lazaretFileName, $lazaretThumbFileName)); + $app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]); } catch (IOException $e) { } @@ -324,7 +324,7 @@ class Lazaret implements ControllerProviderInterface */ public function emptyLazaret(Application $app, Request $request) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; $lazaretFiles = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\LazaretFile')->findAll(); @@ -355,7 +355,7 @@ class Lazaret implements ControllerProviderInterface */ public function acceptElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; //Mandatory parameter if (null === $recordId = $request->request->get('record_id')) { @@ -416,7 +416,7 @@ class Lazaret implements ControllerProviderInterface } try { - $app['filesystem']->remove(array($lazaretFileName, $lazaretThumbFileName)); + $app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]); } catch (IOException $e) { } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php index 683fb75e92..507d125bc0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php @@ -46,32 +46,32 @@ class MoveCollection implements ControllerProviderInterface public function displayForm(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, false, array('candeleterecord')); + $records = RecordsRequest::fromRequest($app, $request, false, ['candeleterecord']); $sbas_ids = array_map(function (\databox $databox) { return $databox->get_sbas_id(); }, $records->databoxes()); $collections = $app['acl']->get($app['authentication']->getUser()) - ->get_granted_base(array('canaddrecord'), $sbas_ids); + ->get_granted_base(['canaddrecord'], $sbas_ids); - $parameters = array( + $parameters = [ 'records' => $records, 'message' => '', 'collections' => $collections, - ); + ]; return $app['twig']->render('prod/actions/collection_default.html.twig', $parameters); } public function apply(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, false, array('candeleterecord')); + $records = RecordsRequest::fromRequest($app, $request, false, ['candeleterecord']); - $datas = array( + $datas = [ 'success' => false, 'message' => '', - ); + ]; try { if (null === $request->request->get('base_id')) { @@ -106,15 +106,15 @@ class MoveCollection implements ControllerProviderInterface } } - $ret = array( + $ret = [ 'success' => true, 'message' => _('Records have been successfuly moved'), - ); + ]; } catch (\Exception $e) { - $ret = array( + $ret = [ 'success' => false, 'message' => _('An error occured'), - ); + ]; } return $app->json($ret); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Order.php b/lib/Alchemy/Phrasea/Controller/Prod/Order.php index 917992ffc5..0ca4ef6fac 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Order.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Order.php @@ -91,10 +91,10 @@ class Order implements ControllerProviderInterface { $success = false; $collectionHasOrderAdmins = new ArrayCollection(); - $toRemove = array(); + $toRemove = []; - $records = RecordsRequest::fromRequest($app, $request, true, array('cancmd')); - $hasOneAdmin = array(); + $records = RecordsRequest::fromRequest($app, $request, true, ['cancmd']); + $hasOneAdmin = []; if (!$records->isEmpty()) { $order = new OrderEntity(); @@ -110,8 +110,8 @@ class Order implements ControllerProviderInterface if (!isset($hasOneAdmin[$record->get_base_id()])) { $query = new \User_Query($app); - $hasOneAdmin[$record->get_base_id()] = (Boolean) count($query->on_base_ids(array($record->get_base_id())) - ->who_have_right(array('order_master')) + $hasOneAdmin[$record->get_base_id()] = (Boolean) count($query->on_base_ids([$record->get_base_id()]) + ->who_have_right(['order_master']) ->execute()->get_results()); } @@ -146,10 +146,10 @@ class Order implements ControllerProviderInterface $order->setTodo($order->getElements()->count()); try { - $app['events-manager']->trigger('__NEW_ORDER__', array( + $app['events-manager']->trigger('__NEW_ORDER__', [ 'order_id' => $order->getId(), 'usr_id' => $order->getUsrId() - )); + ]); $success = true; $app['EM']->persist($order); @@ -168,16 +168,16 @@ class Order implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, - )); + ]); } - return $app->redirectPath('prod_orders', array( + return $app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send' - )); + ]); } /** @@ -195,19 +195,19 @@ class Order implements ControllerProviderInterface $perPage = (int) $request->query->get('per-page', 10); $sort = $request->query->get('sort'); - $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('order_master'))); + $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['order_master'])); $ordersList = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->listOrders($baseIds, $offsetStart, $perPage, $sort); $total = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->countTotalOrders($baseIds); - return $app['twig']->render('prod/orders/order_box.html.twig', array( + return $app['twig']->render('prod/orders/order_box.html.twig', [ 'page' => $page, 'perPage' => $perPage, 'total' => $total, 'previousPage' => $page < 2 ? false : ($page - 1), 'nextPage' => $page >= ceil($total / $perPage) ? false : $page + 1, 'orders' => new ArrayCollection($ordersList) - )); + ]); } /** @@ -225,9 +225,9 @@ class Order implements ControllerProviderInterface throw new NotFoundHttpException('Order not found'); } - return $app['twig']->render('prod/orders/order_item.html.twig', array( + return $app['twig']->render('prod/orders/order_item.html.twig', [ 'order' => $order - )); + ]); } /** @@ -261,7 +261,7 @@ class Order implements ControllerProviderInterface } $n = 0; - $elements = $request->request->get('elements', array()); + $elements = $request->request->get('elements', []); foreach ($order->getElements() as $orderElement) { if (in_array($orderElement->getId(), $elements)) { $sbas_id = \phrasea::sbasFromBas($app, $orderElement->getBaseId()); @@ -286,12 +286,12 @@ class Order implements ControllerProviderInterface if ($n > 0) { $order->setTodo($order->getTodo() - $n); - $app['events-manager']->trigger('__ORDER_DELIVER__', array( + $app['events-manager']->trigger('__ORDER_DELIVER__', [ 'ssel_id' => $order->getBasket()->getId(), 'from' => $app['authentication']->getUser()->get_id(), 'to' => $dest_user->get_id(), 'n' => $n - )); + ]); } $success = true; @@ -304,17 +304,17 @@ class Order implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'), 'order_id' => $order_id - )); + ]); } - return $app->redirectPath('prod_orders', array( + return $app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send' - )); + ]); } /** @@ -334,7 +334,7 @@ class Order implements ControllerProviderInterface } $n = 0; - $elements = $request->request->get('elements', array()); + $elements = $request->request->get('elements', []); foreach ($order->getElements() as $orderElement) { if (in_array($orderElement->getId(),$elements)) { $orderElement->setOrderMasterId($app['authentication']->getUser()->get_id()); @@ -349,11 +349,11 @@ class Order implements ControllerProviderInterface if ($n > 0) { $order->setTodo($order->getTodo() - $n); - $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', array( + $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [ 'from' => $app['authentication']->getUser()->get_id(), 'to' => $order->getUsrId(), 'n' => $n - )); + ]); } $success = true; @@ -364,16 +364,16 @@ class Order implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'), 'order_id' => $order_id - )); + ]); } - return $app->redirectPath('prod_orders', array( + return $app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send' - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php index c9f1e96213..269b2532b4 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php @@ -33,7 +33,7 @@ class Printer implements ControllerProviderInterface $controllers->post('/', function (Application $app) { $printer = new RecordHelper\Printer($app, $app['request']); - return $app['twig']->render('prod/actions/printer_default.html.twig', array('printer' => $printer, 'message' => '')); + return $app['twig']->render('prod/actions/printer_default.html.twig', ['printer' => $printer, 'message' => '']); } ); @@ -50,7 +50,7 @@ class Printer implements ControllerProviderInterface } $PDF = new PDFExport($app, $printer->get_elements(), $layout); - $response = new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf')); + $response = new Response($PDF->render(), 200, ['Content-Type' => 'application/pdf']); $response->headers->set('Pragma', 'public', true); $response->setMaxAge(0); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Property.php b/lib/Alchemy/Phrasea/Controller/Prod/Property.php index 96f581c5d8..bd0cb4419e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Property.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Property.php @@ -61,16 +61,16 @@ class Property implements ControllerProviderInterface $app->abort(400); } - $records = RecordsRequest::fromRequest($app, $request, false, array('chgstatus')); + $records = RecordsRequest::fromRequest($app, $request, false, ['chgstatus']); $databoxStatus = \databox_status::getDisplayStatus($app); - $statusBit = $nRec = array(); + $statusBit = $nRec = []; foreach ($records as $record) { //perform logic $sbasId = $record->get_databox()->get_sbas_id(); if (!isset($nRec[$sbasId])) { - $nRec[$sbasId] = array('stories' => 0, 'records' => 0); + $nRec[$sbasId] = ['stories' => 0, 'records' => 0]; } $nRec[$sbasId]['records']++; @@ -80,7 +80,7 @@ class Property implements ControllerProviderInterface } if (!isset($statusBit[$sbasId])) { - $statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : array(); + $statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : []; foreach (array_keys($statusBit[$sbasId]) as $bit) { $statusBit[$sbasId][$bit]['nset'] = 0; @@ -101,11 +101,11 @@ class Property implements ControllerProviderInterface } } - return new Response($app['twig']->render('prod/actions/Property/index.html.twig', array( + return new Response($app['twig']->render('prod/actions/Property/index.html.twig', [ 'records' => $records, 'statusBit' => $statusBit, 'nRec' => $nRec - ))); + ])); } /** @@ -121,29 +121,29 @@ class Property implements ControllerProviderInterface $app->abort(400); } - $records = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']); - $recordsType = array(); + $recordsType = []; foreach ($records as $record) { //perform logic $sbasId = $record->get_databox()->get_sbas_id(); if (!isset($recordsType[$sbasId])) { - $recordsType[$sbasId] = array(); + $recordsType[$sbasId] = []; } if (!isset($recordsType[$sbasId][$record->get_type()])) { - $recordsType[$sbasId][$record->get_type()] = array(); + $recordsType[$sbasId][$record->get_type()] = []; } $recordsType[$sbasId][$record->get_type()][] = $record; } - return new Response($app['twig']->render('prod/actions/Property/type.html.twig', array( + return new Response($app['twig']->render('prod/actions/Property/type.html.twig', [ 'records' => $records, 'recordsType' => $recordsType, - ))); + ])); } /** @@ -155,9 +155,9 @@ class Property implements ControllerProviderInterface */ public function changeStatus(Application $app, Request $request) { - $applyStatusToChildren = $request->request->get('apply_to_children', array()); - $records = RecordsRequest::fromRequest($app, $request, false, array('chgstatus')); - $updated = array(); + $applyStatusToChildren = $request->request->get('apply_to_children', []); + $records = RecordsRequest::fromRequest($app, $request, false, ['chgstatus']); + $updated = []; $postStatus = (array) $request->request->get('status'); foreach ($records as $record) { @@ -178,7 +178,7 @@ class Property implements ControllerProviderInterface } } - return $app->json(array('success' => true, 'updated' => $updated), 201); + return $app->json(['success' => true, 'updated' => $updated], 201); } /** @@ -190,10 +190,10 @@ class Property implements ControllerProviderInterface */ public function changeType(Application $app, Request $request) { - $typeLst = $request->request->get('types', array()); - $records = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord')); + $typeLst = $request->request->get('types', []); + $records = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']); $forceType = $request->request->get('force_types', ''); - $updated = array(); + $updated = []; foreach ($records as $record) { try { @@ -208,7 +208,7 @@ class Property implements ControllerProviderInterface } } - return $app->json(array('success' => true, 'updated' => $updated), 201); + return $app->json(['success' => true, 'updated' => $updated], 201); } /** @@ -233,10 +233,10 @@ class Property implements ControllerProviderInterface $record->set_binary_status(strrev($newStatus)); - return array( + return [ 'current_status' => $currentStatus, 'new_status' => $newStatus - ); + ]; } return null; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index bbc3690555..98ec635cc3 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -36,9 +36,9 @@ class Push implements ControllerProviderInterface protected function getUserFormatter() { return function (\User_Adapter $user) { - $subtitle = array_filter(array($user->get_job(), $user->get_company())); + $subtitle = array_filter([$user->get_job(), $user->get_company()]); - return array( + return [ 'type' => 'USER' , 'usr_id' => $user->get_id() , 'firstname' => $user->get_firstname() @@ -46,7 +46,7 @@ class Push implements ControllerProviderInterface , 'email' => $user->get_email() , 'display_name' => $user->get_display_name() , 'subtitle' => implode(', ', $subtitle) - ); + ]; }; } @@ -55,23 +55,23 @@ class Push implements ControllerProviderInterface $userFormatter = $this->getUserFormatter(); return function (UsrList $List) use ($userFormatter, $app) { - $entries = array(); + $entries = []; foreach ($List->getEntries() as $entry) { /* @var $entry UsrListEntry */ - $entries[] = array( + $entries[] = [ 'Id' => $entry->getId(), 'User' => $userFormatter($entry->getUser($app)) - ); + ]; } - return array( + return [ 'type' => 'LIST' , 'list_id' => $List->getId() , 'name' => $List->getName() , 'length' => count($entries) , 'entries' => $entries - ); + ]; }; } @@ -125,13 +125,13 @@ class Push implements ControllerProviderInterface $RecommendedUsers = $userSelection($push->get_elements()); - $params = array( + $params = [ 'push' => $push, 'message' => '', 'lists' => $repository->findUserLists($app['authentication']->getUser()), 'context' => 'Push', 'RecommendedUsers' => $RecommendedUsers - ); + ]; return $app['twig']->render('prod/actions/Push.html.twig', $params); }); @@ -143,13 +143,13 @@ class Push implements ControllerProviderInterface $RecommendedUsers = $userSelection($push->get_elements()); - $params = array( + $params = [ 'push' => $push, 'message' => '', 'lists' => $repository->findUserLists($app['authentication']->getUser()), 'context' => 'Feedback', 'RecommendedUsers' => $RecommendedUsers - ); + ]; return $app['twig']->render('prod/actions/Push.html.twig', $params); }); @@ -157,10 +157,10 @@ class Push implements ControllerProviderInterface $controllers->post('/send/', function (Application $app) { $request = $app['request']; - $ret = array( + $ret = [ 'success' => false, 'message' => _('Unable to send the documents') - ); + ]; try { $pusher = new RecordHelper\Push($app, $app['request']); @@ -220,7 +220,7 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $url = $app->url('lightbox_compare', array( + $url = $app->url('lightbox_compare', [ 'basket' => $Basket->getId(), 'LOG' => $app['tokens']->getUrlToken( \random::TYPE_VIEW, @@ -228,11 +228,11 @@ class Push implements ControllerProviderInterface null, $Basket->getId() ) - )); + ]); $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : ''; - $params = array( + $params = [ 'from' => $app['authentication']->getUser()->get_id() , 'from_email' => $app['authentication']->getUser()->get_email() , 'to' => $user_receiver->get_id() @@ -242,7 +242,7 @@ class Push implements ControllerProviderInterface , 'accuse' => $receipt , 'message' => $request->request->get('message') , 'ssel_id' => $Basket->getId() - ); + ]; $app['events-manager']->trigger('__PUSH_DATAS__', $params); } @@ -258,10 +258,10 @@ class Push implements ControllerProviderInterface , count($receivers) ); - $ret = array( + $ret = [ 'success' => true, 'message' => $message - ); + ]; } catch (ControllerException $e) { $ret['message'] = $e->getMessage() . $e->getFile() . $e->getLine(); } @@ -272,10 +272,10 @@ class Push implements ControllerProviderInterface $controllers->post('/validate/', function (Application $app) { $request = $app['request']; - $ret = array( + $ret = [ 'success' => false, 'message' => _('Unable to send the documents') - ); + ]; $app['EM']->beginTransaction(); @@ -349,16 +349,16 @@ class Push implements ControllerProviderInterface } if (!$found) { - $participants[$app['authentication']->getUser()->get_id()] = array( + $participants[$app['authentication']->getUser()->get_id()] = [ 'see_others' => 1, 'usr_id' => $app['authentication']->getUser()->get_id(), 'agree' => 0, 'HD' => 0 - ); + ]; } foreach ($participants as $key => $participant) { - foreach (array('see_others', 'usr_id', 'agree', 'HD') as $mandatoryparam) { + foreach (['see_others', 'usr_id', 'agree', 'HD'] as $mandatoryparam) { if (!array_key_exists($mandatoryparam, $participant)) throw new ControllerException(sprintf(_('Missing mandatory parameter %s'), $mandatoryparam)); } @@ -418,7 +418,7 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $url = $app->url('lightbox_validation', array( + $url = $app->url('lightbox_validation', [ 'basket' => $Basket->getId(), 'LOG' => $app['tokens']->getUrlToken( \random::TYPE_VALIDATE, @@ -426,11 +426,11 @@ class Push implements ControllerProviderInterface null, $Basket->getId() ) - )); + ]); $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : ''; - $params = array( + $params = [ 'from' => $app['authentication']->getUser()->get_id(), 'from_email' => $app['authentication']->getUser()->get_email(), 'to' => $participant_user->get_id(), @@ -441,7 +441,7 @@ class Push implements ControllerProviderInterface 'message' => $request->request->get('message'), 'ssel_id' => $Basket->getId(), 'duration' => (int) $request->request->get('duration'), - ); + ]; $app['events-manager']->trigger('__PUSH_VALIDATION__', $params); } @@ -457,10 +457,10 @@ class Push implements ControllerProviderInterface , count($request->request->get('participants')) ); - $ret = array( + $ret = [ 'success' => true, 'message' => $message - ); + ]; $app['EM']->commit(); } catch (ControllerException $e) { @@ -478,9 +478,9 @@ class Push implements ControllerProviderInterface $query = new \User_Query($app); - $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canpush')); + $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); - $query->in(array($usr_id)); + $query->in([$usr_id]); $result = $query->include_phantoms() ->limit(0, 1) @@ -512,7 +512,7 @@ class Push implements ControllerProviderInterface ->assert('list_id', '\d+'); $controllers->post('/add-user/', function (Application $app, Request $request) use ($userFormatter) { - $result = array('success' => false, 'message' => '', 'user' => null); + $result = ['success' => false, 'message' => '', 'user' => null]; try { if (!$app['acl']->get($app['authentication']->getUser())->has_right('manageusers')) @@ -577,7 +577,7 @@ class Push implements ControllerProviderInterface })->bind('prod_push_do_add_user'); $controllers->get('/add-user/', function (Application $app, Request $request) { - $params = array('callback' => $request->query->get('callback')); + $params = ['callback' => $request->query->get('callback')]; return $app['twig']->render('prod/User/Add.html.twig', $params); })->bind('prod_push_add_user'); @@ -587,7 +587,7 @@ class Push implements ControllerProviderInterface $query = new \User_Query($app); - $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canpush')); + $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); $query->like(\User_Query::LIKE_FIRSTNAME, $request->query->get('query')) ->like(\User_Query::LIKE_LASTNAME, $request->query->get('query')) @@ -602,7 +602,7 @@ class Push implements ControllerProviderInterface $lists = $repository->findUserListLike($app['authentication']->getUser(), $request->query->get('query')); - $datas = array(); + $datas = []; if ($lists) { foreach ($lists as $list) { @@ -627,7 +627,7 @@ class Push implements ControllerProviderInterface $query = new \User_Query($app); - $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canpush')); + $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); if ($request->get('query')) { $query->like($request->get('like_field'), $request->get('query')) @@ -661,13 +661,13 @@ class Push implements ControllerProviderInterface ->limit($offset_start, $perPage) ->execute()->get_results(); - $params = array( + $params = [ 'query' => $query , 'results' => $results , 'list' => $list , 'sort' => $sort , 'ord' => $ord - ); + ]; if ($request->get('type') === 'fragment') { return new Response( diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 437e7efcd8..113f3036bd 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -61,7 +61,7 @@ class Query implements ControllerProviderInterface $mod = $app['authentication']->getUser()->getPrefs('view'); - $json = array(); + $json = []; $options = SearchEngineOptions::fromRequest($app, $request); @@ -196,12 +196,12 @@ class Query implements ControllerProviderInterface } } - $json['results'] = $app['twig']->render($template, array( + $json['results'] = $app['twig']->render($template, [ 'results' => $result, 'highlight' => $result->getQuery(), 'searchEngine' => $app['phraseanet.SE'], 'suggestions' => $prop - ) + ] ); $json['query'] = $query; @@ -239,12 +239,12 @@ class Query implements ControllerProviderInterface $record = new \record_preview($app, 'RESULT', $pos, '', $app['phraseanet.SE'], $query); - return $app->json(array( - 'current' => $app['twig']->render('prod/preview/result_train.html.twig', array( + return $app->json([ + 'current' => $app['twig']->render('prod/preview/result_train.html.twig', [ 'records' => $record->get_train($pos, $query, $app['phraseanet.SE']), 'selected' => $pos - )) - )); + ]) + ]); } /** @@ -258,9 +258,9 @@ class Query implements ControllerProviderInterface { $record = new \record_preview($app, 'REG', $request->request->get('pos'), $request->request->get('cont')); - return new Response($app['twig']->render('prod/preview/reg_train.html.twig', array( + return new Response($app['twig']->render('prod/preview/reg_train.html.twig', [ 'container_records' => $record->get_container()->get_children(), 'record' => $record - ))); + ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Records.php b/lib/Alchemy/Phrasea/Controller/Prod/Records.php index 6a9551fb16..ce8309f590 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Records.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Records.php @@ -96,48 +96,48 @@ class Records implements ControllerProviderInterface if ($record->is_from_reg()) { $train = $app['twig']->render('prod/preview/reg_train.html.twig', - array('record' => $record) + ['record' => $record] ); } if ($record->is_from_basket() && $reloadTrain) { $train = $app['twig']->render('prod/preview/basket_train.html.twig', - array('record' => $record) + ['record' => $record] ); } if ($record->is_from_feed()) { $train = $app['twig']->render('prod/preview/feed_train.html.twig', - array('record' => $record) + ['record' => $record] ); } - return $app->json(array( - "desc" => $app['twig']->render('prod/preview/caption.html.twig', array( + return $app->json([ + "desc" => $app['twig']->render('prod/preview/caption.html.twig', [ 'record' => $record, 'highlight' => $query, 'searchEngine' => $searchEngine - )), - "html_preview" => $app['twig']->render('common/preview.html.twig', array( + ]), + "html_preview" => $app['twig']->render('common/preview.html.twig', [ 'record' => $record - )), - "others" => $app['twig']->render('prod/preview/appears_in.html.twig', array( + ]), + "others" => $app['twig']->render('prod/preview/appears_in.html.twig', [ 'parents' => $record->get_grouping_parents(), 'baskets' => $record->get_container_baskets($app['EM'], $app['authentication']->getUser()) - )), + ]), "current" => $train, - "history" => $app['twig']->render('prod/preview/short_history.html.twig', array( + "history" => $app['twig']->render('prod/preview/short_history.html.twig', [ 'record' => $record - )), - "popularity" => $app['twig']->render('prod/preview/popularity.html.twig', array( + ]), + "popularity" => $app['twig']->render('prod/preview/popularity.html.twig', [ 'record' => $record - )), - "tools" => $app['twig']->render('prod/preview/tools.html.twig', array( + ]), + "tools" => $app['twig']->render('prod/preview/tools.html.twig', [ 'record' => $record - )), + ]), "pos" => $record->get_number(), "title" => $record->get_title($query, $searchEngine) - )); + ]); } /** @@ -149,14 +149,14 @@ class Records implements ControllerProviderInterface */ public function doDeleteRecords(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), array( + $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), [ 'candeleterecord' - )); + ]); $basketElementsRepository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement'); $StoryWZRepository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\StoryWZ'); - $deleted = array(); + $deleted = []; foreach ($records as $record) { try { @@ -194,13 +194,13 @@ class Records implements ControllerProviderInterface */ public function whatCanIDelete(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), array( + $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), [ 'candeleterecord' - )); + ]); - return $app['twig']->render('prod/actions/delete_records_confirm.html.twig', array( + return $app['twig']->render('prod/actions/delete_records_confirm.html.twig', [ 'records' => $records - )); + ]); } /** @@ -215,7 +215,7 @@ class Records implements ControllerProviderInterface { $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('renew_children_url')); - $renewed = array(); + $renewed = []; foreach ($records as $record) { $renewed[$record->get_serialize_key()] = $record->get_preview()->renew_url(); }; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index 512fe9018d..dd310cb6b3 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -50,7 +50,7 @@ class Root implements ControllerProviderInterface $cssPath = $app['root.path'] . '/www/skins/prod/'; - $css = array(); + $css = []; $cssfile = false; $finder = new Finder(); @@ -87,25 +87,25 @@ class Root implements ControllerProviderInterface $queries_topics = \queries::tree_topics($app['locale.I18n']); } - $sbas = $bas2sbas = array(); + $sbas = $bas2sbas = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); - $sbas['s' + $sbas_id] = array( + $sbas['s' + $sbas_id] = [ 'sbid' => $sbas_id, - 'seeker' => null); + 'seeker' => null]; foreach ($databox->get_collections() as $coll) { - $bas2sbas['b' . $coll->get_base_id()] = array( + $bas2sbas['b' . $coll->get_base_id()] = [ 'sbid' => $sbas_id, - 'ckobj' => array('checked' => false), + 'ckobj' => ['checked' => false], 'waschecked' => false - ); + ]; } } - return $app['twig']->render('prod/index.html.twig', array( + return $app['twig']->render('prod/index.html.twig', [ 'module_name' => 'Production', 'WorkZone' => new Helper\WorkZone($app, $app['request']), 'module_prod' => new Helper\Prod($app, $app['request']), @@ -127,7 +127,7 @@ class Root implements ControllerProviderInterface 'thesau_json_sbas' => json_encode($sbas), 'thesau_json_bas2sbas' => json_encode($bas2sbas), 'thesau_languages' => $app['locales.available'], - )); + ]); })->bind('prod'); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Share.php b/lib/Alchemy/Phrasea/Controller/Prod/Share.php index 1748c10e97..1aa55942a6 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Share.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Share.php @@ -57,8 +57,8 @@ class Share implements ControllerProviderInterface $app->abort(403); } - return new Response($app['twig']->render('prod/Share/record.html.twig', array( + return new Response($app['twig']->render('prod/Share/record.html.twig', [ 'record' => $record, - ))); + ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Story.php b/lib/Alchemy/Phrasea/Controller/Prod/Story.php index 5d09f80222..c8215f74cb 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Story.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Story.php @@ -38,7 +38,7 @@ class Story implements ControllerProviderInterface }); $controllers->get('/create/', function (Application $app) { - return $app['twig']->render('prod/Story/Create.html.twig', array()); + return $app['twig']->render('prod/Story/Create.html.twig', []); })->bind('prod_stories_create'); $controllers->post('/', function (Application $app, Request $request) { @@ -61,7 +61,7 @@ class Story implements ControllerProviderInterface $Story->appendChild($record); } - $metadatas = array(); + $metadatas = []; foreach ($collection->get_databox()->get_meta_structure() as $meta) { if ($meta->get_thumbtitle()) { @@ -70,11 +70,11 @@ class Story implements ControllerProviderInterface continue; } - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta->get_id() , 'meta_id' => null , 'value' => $value - ); + ]; break; } @@ -90,29 +90,29 @@ class Story implements ControllerProviderInterface $app['EM']->flush(); if ($request->getRequestFormat() == 'json') { - $data = array( + $data = [ 'success' => true , 'message' => _('Story created') , 'WorkZone' => $StoryWZ->getId() - , 'story' => array( + , 'story' => [ 'sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id(), - ) - ); + ] + ]; return $app->json($data); } else { - return $app->redirectPath('prod_stories_story', array( + return $app->redirectPath('prod_stories_story', [ 'sbas_id' => $StoryWZ->getSbasId(), 'record_id' => $StoryWZ->getRecordId(), - )); + ]); } })->bind('prod_stories_do_create'); $controllers->get('/{sbas_id}/{record_id}/', function (Application $app, $sbas_id, $record_id) { $Story = new \record_adapter($app, $sbas_id, $record_id); - $html = $app['twig']->render('prod/WorkZone/Story.html.twig', array('Story' => $Story)); + $html = $app['twig']->render('prod/WorkZone/Story.html.twig', ['Story' => $Story]); return new Response($html); }) @@ -139,15 +139,15 @@ class Story implements ControllerProviderInterface $n++; } - $data = array( + $data = [ 'success' => true , 'message' => sprintf(_('%d records added'), $n) - ); + ]; if ($request->getRequestFormat() == 'json') { return $app->json($data); } else { - return $app->redirectPath('prod_stories_story', array('sbas_id' => $sbas_id,'record_id' => $record_id)); + return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id,'record_id' => $record_id]); } })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); @@ -161,15 +161,15 @@ class Story implements ControllerProviderInterface $Story->removeChild($record); - $data = array( + $data = [ 'success' => true , 'message' => _('Record removed from story') - ); + ]; if ($request->getRequestFormat() == 'json') { return $app->json($data); } else { - return $app->redirectPath('prod_stories_story', array('sbas_id' => $sbas_id,'record_id' => $record_id)); + return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id,'record_id' => $record_id]); } }) ->bind('prod_stories_story_remove_element') @@ -191,7 +191,7 @@ class Story implements ControllerProviderInterface return new Response( $app['twig']->render( 'prod/Story/Reorder.html.twig' - , array('story' => $story) + , ['story' => $story] ) ); }) @@ -200,7 +200,7 @@ class Story implements ControllerProviderInterface ->assert('record_id', '\d+'); $controllers->post('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) { - $ret = array('success' => false, 'message' => _('An error occured')); + $ret = ['success' => false, 'message' => _('An error occured')]; try { $story = new \record_adapter($app, $sbas_id, $record_id); @@ -218,19 +218,19 @@ class Story implements ControllerProviderInterface $stmt = $story->get_databox()->get_connection()->prepare($sql); foreach ($app['request']->request->get('element') as $record_id => $ord) { - $params = array( + $params = [ ':ord' => $ord, ':parent_id' => $story->get_record_id(), ':children_id' => $record_id - ); + ]; $stmt->execute($params); } $stmt->closeCursor(); - $ret = array('success' => true, 'message' => _('Story updated')); + $ret = ['success' => true, 'message' => _('Story updated')]; } catch (ControllerException $e) { - $ret = array('success' => false, 'message' => $e->getMessage()); + $ret = ['success' => false, 'message' => $e->getMessage()]; } catch (\Exception $e) { } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php index 0a5ac013cb..1472b88f75 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -52,13 +52,13 @@ class TOU implements ControllerProviderInterface */ public function denyTermsOfUse(Application $app, Request $request, $sbas_id) { - $ret = array('success' => false, 'message' => ''); + $ret = ['success' => false, 'message' => '']; try { $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $app['acl']->get($app['authentication']->getUser())->revoke_access_from_bases( - array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id()))) + array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()])) ); $app['acl']->get($app['authentication']->getUser())->revoke_unused_sbas_rights(); @@ -81,8 +81,8 @@ class TOU implements ControllerProviderInterface */ public function displayTermsOfUse(Application $app, Request $request) { - $toDisplay = $request->query->get('to_display', array()); - $data = array(); + $toDisplay = $request->query->get('to_display', []); + $data = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { if (count($toDisplay) > 0 && !in_array($databox->get_sbas_id(), $toDisplay)) { @@ -98,9 +98,9 @@ class TOU implements ControllerProviderInterface $data[$databox->get_label($app['locale.I18n'])] = $cgus[$app['locale']]['value']; } - return new Response($app['twig']->render('/prod/TOU.html.twig', array( + return new Response($app['twig']->render('/prod/TOU.html.twig', [ 'TOUs' => $data, 'local_title' => _('Terms of use') - ))); + ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php index 11c31b58c7..d5a87bc851 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php @@ -59,21 +59,21 @@ class Tools implements ControllerProviderInterface } } - $var = array( + $var = [ 'records' => $records, 'record' => $record, 'metadatas' => $metadatas, - ); + ]; return $app['twig']->render('prod/actions/Tools/index.html.twig', $var); }); $controllers->post('/rotate/', function (Application $app, Request $request) { - $return = array('success' => true, 'errorMessage' => ''); + $return = ['success' => true, 'errorMessage' => '']; $records = RecordsRequest::fromRequest($app, $request, false); - $rotation = in_array($request->request->get('rotation'), array('-90', '90', '180')) ? $request->request->get('rotation', 90) : 90; + $rotation = in_array($request->request->get('rotation'), ['-90', '90', '180']) ? $request->request->get('rotation', 90) : 90; foreach ($records as $record) { foreach ($record->get_subdefs() as $name => $subdef) { @@ -92,9 +92,9 @@ class Tools implements ControllerProviderInterface })->bind('prod_tools_rotate'); $controllers->post('/image/', function (Application $app, Request $request) { - $return = array('success' => true); + $return = ['success' => true]; - $selection = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord')); + $selection = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']); foreach ($selection as $record) { @@ -169,10 +169,10 @@ class Tools implements ControllerProviderInterface $app->abort(400, 'Missing file parameter'); } - return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', array( + return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', [ 'success' => $success, 'message' => $message, - )); + ]); })->bind('prod_tools_hd_substitution'); $controllers->post('/chgthumb/', function (Application $app, Request $request) { @@ -223,22 +223,22 @@ class Tools implements ControllerProviderInterface $app->abort(400, 'Missing file parameter'); } - return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', array( + return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', [ 'success' => $success, 'message' => $message, - )); + ]); })->bind('prod_tools_thumbnail_substitution'); $controllers->post('/thumb-extractor/confirm-box/', function (Application $app, Request $request) { - $return = array('error' => false, 'datas' => ''); + $return = ['error' => false, 'datas' => '']; $template = 'prod/actions/Tools/confirm.html.twig'; try { $record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id')); - $var = array( + $var = [ 'video_title' => $record->get_title() , 'image' => $request->request->get('image', '') - ); + ]; $return['datas'] = $app['twig']->render($template, $var); } catch (\Exception $e) { $return['datas'] = _('an error occured'); @@ -249,7 +249,7 @@ class Tools implements ControllerProviderInterface }); $controllers->post('/thumb-extractor/apply/', function (Application $app, Request $request) { - $return = array('success' => false, 'message' => ''); + $return = ['success' => false, 'message' => '']; try { $record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id')); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php index 9023a49905..ce41398736 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php @@ -84,14 +84,14 @@ class Tooltip implements ControllerProviderInterface public function displayBasket(Application $app, Basket $basket) { - return $app['twig']->render('prod/Tooltip/Basket.html.twig', array('basket' => $basket)); + return $app['twig']->render('prod/Tooltip/Basket.html.twig', ['basket' => $basket]); } public function displayStory(Application $app, $sbas_id, $record_id) { $Story = new \record_adapter($app, $sbas_id, $record_id); - return $app['twig']->render('prod/Tooltip/Story.html.twig', array('Story' => $Story)); + return $app['twig']->render('prod/Tooltip/Story.html.twig', ['Story' => $Story]); } public function displayUserBadge(Application $app, $usr_id) @@ -100,7 +100,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/User.html.twig' - , array('user' => $user) + , ['user' => $user] ); } @@ -110,7 +110,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/Preview.html.twig' - , array('record' => $record, 'not_wrapped' => true) + , ['record' => $record, 'not_wrapped' => true] ); } @@ -132,12 +132,12 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/Caption.html.twig' - , array( + , [ 'record' => $record, 'view' => $context, 'highlight' => $app['request']->request->get('query'), 'searchEngine' => $search_engine, - )); + ]); } public function displayTechnicalDatas(Application $app, $sbas_id, $record_id) @@ -152,7 +152,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/TechnicalDatas.html.twig' - , array('record' => $record, 'document' => $document) + , ['record' => $record, 'document' => $document] ); } @@ -163,7 +163,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/DataboxField.html.twig' - , array('field' => $field) + , ['field' => $field] ); } @@ -174,7 +174,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/DCESFieldInfo.html.twig' - , array('field' => $field) + , ['field' => $field] ); } @@ -185,7 +185,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/DataboxFieldRestrictions.html.twig' - , array('field' => $field) + , ['field' => $field] ); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index f2225fc90c..6e6b6ca2e0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -76,12 +76,12 @@ class Upload implements ControllerProviderInterface $maxFileSize = $this->getUploadMaxFileSize(); return $app['twig']->render( - 'prod/upload/upload-flash.html.twig', array( + 'prod/upload/upload-flash.html.twig', [ 'sessionId' => session_id(), 'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())), 'maxFileSize' => $maxFileSize, 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize) - )); + ]); } /** @@ -97,11 +97,11 @@ class Upload implements ControllerProviderInterface $maxFileSize = $this->getUploadMaxFileSize(); return $app['twig']->render( - 'prod/upload/upload.html.twig', array( + 'prod/upload/upload.html.twig', [ 'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())), 'maxFileSize' => $maxFileSize, 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize) - )); + ]); } /** @@ -121,14 +121,14 @@ class Upload implements ControllerProviderInterface */ public function upload(Application $app, Request $request) { - $datas = array( + $datas = [ 'success' => false, 'code' => null, 'message' => '', 'element' => '', - 'reasons' => array(), + 'reasons' => [], 'id' => '', - ); + ]; if (null === $request->files->get('files')) { throw new BadRequestHttpException('Missing file parameter'); @@ -185,7 +185,7 @@ class Upload implements ControllerProviderInterface $forceBehavior = $request->request->get('forceAction'); - $reasons = array(); + $reasons = []; $elementCreated = null; $callback = function ($element, $visa, $code) use (&$reasons, &$elementCreated) { @@ -205,7 +205,7 @@ class Upload implements ControllerProviderInterface $app['filesystem']->rename($renamedFilename, $uploadedFilename); if (!!$forceBehavior) { - $reasons = array(); + $reasons = []; } if ($elementCreated instanceof \record_adapter) { @@ -237,7 +237,7 @@ class Upload implements ControllerProviderInterface } } } else { - $params = array('lazaret_file' => $elementCreated); + $params = ['lazaret_file' => $elementCreated]; $app['events-manager']->trigger('__UPLOAD_QUARANTINE__', $params); @@ -246,14 +246,14 @@ class Upload implements ControllerProviderInterface $message = _('The file was moved to the quarantine'); } - $datas = array( + $datas = [ 'success' => true, 'code' => $code, 'message' => $message, 'element' => $element, 'reasons' => $reasons, 'id' => $id, - ); + ]; } catch (\Exception $e) { $datas['message'] = _('Unable to add file to Phraseanet'); } @@ -275,16 +275,16 @@ class Upload implements ControllerProviderInterface */ private function getGrantedCollections(\ACL $acl) { - $collections = array(); + $collections = []; - foreach ($acl->get_granted_base(array('canaddrecord')) as $collection) { + foreach ($acl->get_granted_base(['canaddrecord']) as $collection) { $databox = $collection->get_databox(); if ( ! isset($collections[$databox->get_sbas_id()])) { - $collections[$databox->get_sbas_id()] = array( + $collections[$databox->get_sbas_id()] = [ 'databox' => $databox, - 'databox_collections' => array() - ); + 'databox_collections' => [] + ]; } $collections[$databox->get_sbas_id()]['databox_collections'][] = $collection; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index 62b5455ff0..2441726862 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -78,11 +78,11 @@ class UsrLists implements ControllerProviderInterface public function getAll(Application $app, Request $request) { - $datas = array( + $datas = [ 'success' => false , 'message' => '' , 'result' => null - ); + ]; $lists = new ArrayCollection(); @@ -91,13 +91,13 @@ class UsrLists implements ControllerProviderInterface $lists = $repository->findUserLists($app['authentication']->getUser()); - $result = array(); + $result = []; foreach ($lists as $list) { - $owners = $entries = array(); + $owners = $entries = []; foreach ($list->getOwners() as $owner) { - $owners[] = array( + $owners[] = [ 'usr_id' => $owner->getUser($app)->get_id(), 'display_name' => $owner->getUser($app)->get_display_name(), 'position' => $owner->getUser($app)->get_position(), @@ -105,40 +105,40 @@ class UsrLists implements ControllerProviderInterface 'company' => $owner->getUser($app)->get_company(), 'email' => $owner->getUser($app)->get_email(), 'role' => $owner->getRole() - ); + ]; } foreach ($list->getEntries() as $entry) { - $entries[] = array( + $entries[] = [ 'usr_id' => $owner->getUser($app)->get_id(), 'display_name' => $owner->getUser($app)->get_display_name(), 'position' => $owner->getUser($app)->get_position(), 'job' => $owner->getUser($app)->get_job(), 'company' => $owner->getUser($app)->get_company(), 'email' => $owner->getUser($app)->get_email(), - ); + ]; } /* @var $list UsrList */ - $result[] = array( + $result[] = [ 'name' => $list->getName(), 'created' => $list->getCreated()->format(DATE_ATOM), 'updated' => $list->getUpdated()->format(DATE_ATOM), 'owners' => $owners, 'users' => $entries - ); + ]; } - $datas = array( + $datas = [ 'success' => true , 'message' => '' , 'result' => $result - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { } @@ -147,7 +147,7 @@ class UsrLists implements ControllerProviderInterface return $app->json($datas); } - return $app['twig']->render('prod/actions/Feedback/lists-all.html.twig', array('lists' => $lists)); + return $app['twig']->render('prod/actions/Feedback/lists-all.html.twig', ['lists' => $lists]); } public function createList(Application $app) @@ -156,11 +156,11 @@ class UsrLists implements ControllerProviderInterface $list_name = $request->request->get('name'); - $datas = array( + $datas = [ 'success' => false , 'message' => sprintf(_('Unable to create list %s'), $list_name) , 'list_id' => null - ); + ]; try { if (!$list_name) { @@ -181,16 +181,16 @@ class UsrLists implements ControllerProviderInterface $app['EM']->persist($List); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('List %s has been created'), $list_name) , 'list_id' => $List->getId() - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { } @@ -208,7 +208,7 @@ class UsrLists implements ControllerProviderInterface $owners = new ArrayCollection(); foreach ($list->getOwners() as $owner) { - $owners[] = array( + $owners[] = [ 'usr_id' => $owner->getUser($app)->get_id(), 'display_name' => $owner->getUser($app)->get_display_name(), 'position' => $owner->getUser($app)->get_position(), @@ -216,40 +216,40 @@ class UsrLists implements ControllerProviderInterface 'company' => $owner->getUser($app)->get_company(), 'email' => $owner->getUser($app)->get_email(), 'role' => $owner->getRole($app) - ); + ]; } foreach ($list->getEntries() as $entry) { - $entries[] = array( + $entries[] = [ 'usr_id' => $entry->getUser($app)->get_id(), 'display_name' => $entry->getUser($app)->get_display_name(), 'position' => $entry->getUser($app)->get_position(), 'job' => $entry->getUser($app)->get_job(), 'company' => $entry->getUser($app)->get_company(), 'email' => $entry->getUser($app)->get_email(), - ); + ]; } - return $app->json(array( - 'result' => array( + return $app->json([ + 'result' => [ 'id' => $list->getId(), 'name' => $list->getName(), 'created' => $list->getCreated()->format(DATE_ATOM), 'updated' => $list->getUpdated()->format(DATE_ATOM), 'owners' => $owners, 'users' => $entries - ) - )); + ] + ]); } public function updateList(Application $app, $list_id) { $request = $app['request']; - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to update list') - ); + ]; try { $list_name = $request->request->get('name'); @@ -270,15 +270,15 @@ class UsrLists implements ControllerProviderInterface $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('List has been updated') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { } @@ -300,21 +300,21 @@ class UsrLists implements ControllerProviderInterface $app['EM']->remove($list); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('List has been deleted')) - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => sprintf(_('Unable to delete list')) - ); + ]; } return $app->json($datas); @@ -339,21 +339,21 @@ class UsrLists implements ControllerProviderInterface $app['EM']->remove($user_entry); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('Entry removed from list') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to remove entry from list ' . $e->getMessage()) - ); + ]; } return $app->json($datas); @@ -375,7 +375,7 @@ class UsrLists implements ControllerProviderInterface throw new ControllerException(_('You are not authorized to do this')); } - $inserted_usr_ids = array(); + $inserted_usr_ids = []; foreach ($request->request->get('usr_ids') as $usr_id) { $user_entry = \User_Adapter::getInstance($usr_id, $app); @@ -397,29 +397,29 @@ class UsrLists implements ControllerProviderInterface $app['EM']->flush(); if (count($inserted_usr_ids) > 1) { - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('%d Users added to list'), count($inserted_usr_ids)) , 'result' => $inserted_usr_ids - ); + ]; } else { - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('%d User added to list'), count($inserted_usr_ids)) , 'result' => $inserted_usr_ids - ); + ]; } } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to add usr to list') - ); + ]; } return $app->json($datas); @@ -443,16 +443,16 @@ class UsrLists implements ControllerProviderInterface } - return $app['twig']->render('prod/actions/Feedback/List-Share.html.twig', array('list' => $list)); + return $app['twig']->render('prod/actions/Feedback/List-Share.html.twig', ['list' => $list]); } public function shareWithUser(Application $app, $list_id, $usr_id) { - $availableRoles = array( + $availableRoles = [ UsrListOwner::ROLE_USER, UsrListOwner::ROLE_EDITOR, UsrListOwner::ROLE_ADMIN, - ); + ]; if (!$app['request']->request->get('role')) throw new BadRequestHttpException('Missing role parameter'); @@ -493,21 +493,21 @@ class UsrLists implements ControllerProviderInterface $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('List shared to user') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to share the list with the usr') - ); + ]; } return $app->json($datas); @@ -532,20 +532,20 @@ class UsrLists implements ControllerProviderInterface $app['EM']->remove($owner); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('Owner removed from list') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to remove usr from list') - ); + ]; } return $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php index 1a019f6d91..8014b40f47 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php @@ -66,12 +66,12 @@ class WorkZone implements ControllerProviderInterface public function displayWorkzone(Application $app) { - $params = array( + $params = [ 'WorkZone' => new WorkzoneHelper($app, $app['request']) , 'selected_type' => $app['request']->query->get('type') , 'selected_id' => $app['request']->query->get('id') , 'srt' => $app['request']->query->get('sort') - ); + ]; return $app['twig']->render('prod/WorkZone/WorkZone.html.twig', $params); } @@ -104,7 +104,7 @@ class WorkZone implements ControllerProviderInterface $page = floor($offsetStart / $PerPage) + 1; $maxPage = floor(count($Baskets) / $PerPage) + 1; - $params = array( + $params = [ 'Baskets' => $Baskets , 'Page' => $page , 'MaxPage' => $maxPage @@ -112,14 +112,14 @@ class WorkZone implements ControllerProviderInterface , 'Query' => $request->query->get('Query') , 'Year' => $request->query->get('Year') , 'Type' => $request->query->get('Type') - ); + ]; return $app['twig']->render('prod/WorkZone/Browser/Results.html.twig', $params); } public function browseBasket(Application $app, Request $request, Basket $basket) { - return $app['twig']->render('prod/WorkZone/Browser/Basket.html.twig', array('Basket' => $basket)); + return $app['twig']->render('prod/WorkZone/Browser/Basket.html.twig', ['Basket' => $basket]); } public function attachStories(Application $app, Request $request) @@ -132,7 +132,7 @@ class WorkZone implements ControllerProviderInterface $alreadyFixed = $done = 0; - $stories = $request->request->get('stories', array()); + $stories = $request->request->get('stories', []); foreach ($stories as $element) { $element = explode('_', $element); @@ -190,10 +190,10 @@ class WorkZone implements ControllerProviderInterface } if ($request->getRequestFormat() == 'json') { - return $app->json(array( + return $app->json([ 'success' => true , 'message' => $message - )); + ]); } return $app->redirectPath('prod_workzone_show'); @@ -216,10 +216,10 @@ class WorkZone implements ControllerProviderInterface $app['EM']->flush(); if ($request->getRequestFormat() == 'json') { - return $app->json(array( + return $app->json([ 'success' => true , 'message' => _('Story detached from the WorkZone') - )); + ]); } return $app->redirectPath('prod_workzone_show'); diff --git a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php index 08c8399db2..4ad903a04a 100644 --- a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php +++ b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php @@ -45,7 +45,7 @@ class RecordsRequest extends ArrayCollection $this->isSingleStory = ($flatten !== self::FLATTEN_YES && 1 === count($this) && $this->first()->is_grouping()); if (self::FLATTEN_NO !== $flatten) { - $to_remove = array(); + $to_remove = []; foreach ($this as $key => $record) { if ($record->is_grouping()) { if (self::FLATTEN_YES === $flatten) { @@ -77,7 +77,7 @@ class RecordsRequest extends ArrayCollection public function databoxes() { if (!$this->databoxes) { - $this->databoxes = array(); + $this->databoxes = []; foreach ($this as $record) { if (false === array_key_exists($record->get_databox()->get_sbas_id(), $this->databoxes)) { @@ -99,7 +99,7 @@ class RecordsRequest extends ArrayCollection public function collections() { if (!$this->collections) { - $this->collections = array(); + $this->collections = []; foreach ($this as $record) { if (false === array_key_exists($record->get_base_id(), $this->collections)) { @@ -182,7 +182,7 @@ class RecordsRequest extends ArrayCollection return $this->singleStory()->get_serialize_key(); } - $basrec = array(); + $basrec = []; foreach ($this as $record) { $basrec[] = $record->get_serialize_key(); } @@ -200,9 +200,9 @@ class RecordsRequest extends ArrayCollection * @param array $rightsDatabox * @return RecordsRequest */ - public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = array(), array $rightsDatabox = array()) + public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = [], array $rightsDatabox = []) { - $elements = $received = array(); + $elements = $received = []; $basket = null; if ($request->get('ssel')) { @@ -239,7 +239,7 @@ class RecordsRequest extends ArrayCollection $elements = $received; - $to_remove = array(); + $to_remove = []; foreach ($elements as $id => $record) { diff --git a/lib/Alchemy/Phrasea/Controller/Report/Activity.php b/lib/Alchemy/Phrasea/Controller/Report/Activity.php index 49c3e579b9..d6ba29bd16 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Activity.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Activity.php @@ -105,22 +105,22 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { $report = $activity->getConnexionBase(false, $request->request->get('on', 'user')); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -133,13 +133,13 @@ class Activity implements ControllerProviderInterface */ public function doReportDownloadsByUsers(Application $app, Request $request) { - $conf = array( - 'user' => array(_('report:: utilisateur'), 0, 1, 0, 0), - 'nbdoc' => array(_('report:: nombre de documents'), 0, 0, 0, 0), - 'poiddoc' => array(_('report:: poids des documents'), 0, 0, 0, 0), - 'nbprev' => array(_('report:: nombre de preview'), 0, 0, 0, 0), - 'poidprev' => array(_('report:: poids des previews'), 0, 0, 0, 0) - ); + $conf = [ + 'user' => [_('report:: utilisateur'), 0, 1, 0, 0], + 'nbdoc' => [_('report:: nombre de documents'), 0, 0, 0, 0], + 'poiddoc' => [_('report:: poids des documents'), 0, 0, 0, 0], + 'nbprev' => [_('report:: nombre de preview'), 0, 0, 0, 0], + 'poidprev' => [_('report:: poids des previews'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -171,20 +171,20 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -197,11 +197,11 @@ class Activity implements ControllerProviderInterface */ public function doReportBestOfQuestions(Application $app, Request $request) { - $conf = array( - 'search' => array(_('report:: question'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0) - ); + $conf = [ + 'search' => [_('report:: question'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'nb_rep' => [_('report:: nombre de reponses'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -227,22 +227,22 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { $report = $activity->getTopQuestion($conf); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -255,11 +255,11 @@ class Activity implements ControllerProviderInterface */ public function doReportNoBestOfQuestions(Application $app, Request $request) { - $conf = array( - 'search' => array(_('report:: question'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0) - ); + $conf = [ + 'search' => [_('report:: question'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'nb_rep' => [_('report:: nombre de reponses'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -292,22 +292,22 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { $report = $activity->getTopQuestion($conf, true); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -342,20 +342,20 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => true, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -368,12 +368,12 @@ class Activity implements ControllerProviderInterface */ public function doReportSiteActiviyPerDays(Application $app, Request $request) { - $conf = array( - 'ddate' => array(_('report:: jour'), 0, 0, 0, 0), - 'total' => array(_('report:: total des telechargements'), 0, 0, 0, 0), - 'preview' => array(_('report:: preview'), 0, 0, 0, 0), - 'document' => array(_('report:: document original'), 0, 0, 0, 0) - ); + $conf = [ + 'ddate' => [_('report:: jour'), 0, 0, 0, 0], + 'total' => [_('report:: total des telechargements'), 0, 0, 0, 0], + 'preview' => [_('report:: preview'), 0, 0, 0, 0], + 'document' => [_('report:: document original'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -406,20 +406,20 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -432,14 +432,14 @@ class Activity implements ControllerProviderInterface */ public function doReportPushedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'getter' => array("Destinataire", 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'getter' => ["Destinataire", 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_push( $app, @@ -461,7 +461,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -470,15 +470,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -486,7 +486,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -498,13 +498,13 @@ class Activity implements ControllerProviderInterface */ public function doReportAddedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_add( $app, @@ -526,7 +526,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -535,15 +535,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -551,7 +551,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -563,13 +563,13 @@ class Activity implements ControllerProviderInterface */ public function doReportEditedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_edit( $app, @@ -591,7 +591,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -600,15 +600,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -616,7 +616,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -628,14 +628,14 @@ class Activity implements ControllerProviderInterface */ public function doReportValidatedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'getter' => array("Destinataire", 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'getter' => ["Destinataire", 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_validate( $app, @@ -657,7 +657,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -666,15 +666,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -682,7 +682,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -694,14 +694,14 @@ class Activity implements ControllerProviderInterface */ public function doReportSentDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - 'comment' => array(_('Receiver'), 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + 'comment' => [_('Receiver'), 1, 0, 1, 1], + ]; $activity = new \module_report_sent( $app, @@ -723,7 +723,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -732,15 +732,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -748,7 +748,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -790,9 +790,9 @@ class Activity implements ControllerProviderInterface //display content of a table column when user click on it if ($request->request->get('conf') == 'on') { - return $app->json(array('liste' => $app['twig']->render('report/listColumn.html.twig', array( + return $app->json(['liste' => $app['twig']->render('report/listColumn.html.twig', [ 'conf' => $base_conf - )), "title" => _("configuration"))); + ]), "title" => _("configuration")]); } //set order @@ -803,7 +803,7 @@ class Activity implements ControllerProviderInterface //work on filters $mapColumnTitleToSqlField = $report->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -816,10 +816,10 @@ class Activity implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - )), "title" => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), "title" => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -854,18 +854,18 @@ class Activity implements ControllerProviderInterface $groupField = isset($conf[strtolower($groupby)]['title']) ? $conf[strtolower($groupby)]['title'] : ''; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => true, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField)) - )); + ]); } //set Limit diff --git a/lib/Alchemy/Phrasea/Controller/Report/Export.php b/lib/Alchemy/Phrasea/Controller/Report/Export.php index 38e8cec583..b0fc59b1e3 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Export.php @@ -54,7 +54,7 @@ class Export implements ControllerProviderInterface $filename = mb_strtolower('report_' . $name . '_' . date('dmY') . '.csv'); $data = preg_replace('/[ \t\r\f]+/', '', $data); - $response = new Response($data, 200, array( + $response = new Response($data, 200, [ 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT', 'Cache-Control' => 'no-store, no-cache, must-revalidate', @@ -64,7 +64,7 @@ class Export implements ControllerProviderInterface 'Content-Length' => strlen($data), 'Cache-Control' => 'max-age=3600, must-revalidate', 'Content-Disposition' => 'max-age=3600, must-revalidate', - )); + ]); $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename)); diff --git a/lib/Alchemy/Phrasea/Controller/Report/Informations.php b/lib/Alchemy/Phrasea/Controller/Report/Informations.php index 1fd2136673..9a68ac4fa9 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Informations.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Informations.php @@ -50,38 +50,38 @@ class Informations implements ControllerProviderInterface */ public function doReportInformationsUser(Application $app, Request $request) { - $conf = array( - 'config' => array( - 'photo' => array(_('report:: document'), 0, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 0, 0, 0, 0), - 'date' => array(_('report:: date'), 0, 0, 0, 0), - 'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'titre' => array(_('report:: titre'), 0, 0, 0, 0), - 'taille' => array(_('report:: poids'), 0, 0, 0, 0) - ), - 'conf' => array( - 'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0), - 'nom' => array(_('report:: nom'), 0, 0, 0, 0), - 'mail' => array(_('report:: email'), 0, 0, 0, 0), - 'adresse' => array(_('report:: adresse'), 0, 0, 0, 0), - 'tel' => array(_('report:: telephone'), 0, 0, 0, 0) - ), - 'config_cnx' => array( - 'ddate' => array(_('report:: date'), 0, 0, 0, 0), - 'appli' => array(_('report:: modules'), 0, 0, 0, 0), - ), - 'config_dl' => array( - 'ddate' => array(_('report:: date'), 0, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 0, 1, 0, 0), - 'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'coll_id' => array(_('report:: collections'), 0, 0, 0, 0), - 'comment' => array(_('report:: commentaire'), 0, 0, 0, 0), - ), - 'config_ask' => array( - 'search' => array(_('report:: question'), 0, 0, 0, 0), - 'ddate' => array(_('report:: date'), 0, 0, 0, 0) - ) - ); + $conf = [ + 'config' => [ + 'photo' => [_('report:: document'), 0, 0, 0, 0], + 'record_id' => [_('report:: record id'), 0, 0, 0, 0], + 'date' => [_('report:: date'), 0, 0, 0, 0], + 'type' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'titre' => [_('report:: titre'), 0, 0, 0, 0], + 'taille' => [_('report:: poids'), 0, 0, 0, 0] + ], + 'conf' => [ + 'identifiant' => [_('report:: identifiant'), 0, 0, 0, 0], + 'nom' => [_('report:: nom'), 0, 0, 0, 0], + 'mail' => [_('report:: email'), 0, 0, 0, 0], + 'adresse' => [_('report:: adresse'), 0, 0, 0, 0], + 'tel' => [_('report:: telephone'), 0, 0, 0, 0] + ], + 'config_cnx' => [ + 'ddate' => [_('report:: date'), 0, 0, 0, 0], + 'appli' => [_('report:: modules'), 0, 0, 0, 0], + ], + 'config_dl' => [ + 'ddate' => [_('report:: date'), 0, 0, 0, 0], + 'record_id' => [_('report:: record id'), 0, 1, 0, 0], + 'final' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'coll_id' => [_('report:: collections'), 0, 0, 0, 0], + 'comment' => [_('report:: commentaire'), 0, 0, 0, 0], + ], + 'config_ask' => [ + 'search' => [_('report:: question'), 0, 0, 0, 0], + 'ddate' => [_('report:: date'), 0, 0, 0, 0] + ] + ]; $report = null; $html = $html_info = ''; @@ -94,10 +94,10 @@ class Informations implements ControllerProviderInterface } if ('' !== $on && $app['phraseanet.registry']->get('GV_anonymousReport') == true) { - $conf['conf'] = array( - $on => array($on, 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0) - ); + $conf['conf'] = [ + $on => [$on, 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0] + ]; } if ($from == 'CNXU' || $from == 'CNX') { @@ -135,7 +135,7 @@ class Informations implements ControllerProviderInterface if ($report) { $mapColumnTitleToSqlField = $report->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -148,10 +148,10 @@ class Informations implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - )), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -188,17 +188,17 @@ class Informations implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } - $html = $app['twig']->render('report/ajax_data_content.html.twig', array( + $html = $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => $report instanceof \module_report_download, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); } $info = new \module_report_nav( @@ -214,32 +214,32 @@ class Informations implements ControllerProviderInterface $infoArray = $info->buildTabGrpInfo( null !== $report ? $report->getReq() : '', - null !== $report ? $report->getParams() : array(), + null !== $report ? $report->getParams() : [], $selectValue, $conf['conf'], $on ); if (false == $app['phraseanet.registry']->get('GV_anonymousReport')) { - $html_info = $app['twig']->render('report/ajax_data_content.html.twig', array( + $html_info = $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($infoArray['report']) ? $infoArray['report'] : $infoArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); $title = ('' === $on && isset($infoArray['result'])) ? $infoArray['result'][0]['identifiant'] : $selectValue; } else { $title = $selectValue; } - return $app->json(array( + return $app->json([ 'rs' => sprintf('%s%s', $html_info, $html), 'display_nav' => false, 'title' => $title - )); + ]); } /** @@ -251,10 +251,10 @@ class Informations implements ControllerProviderInterface */ public function doReportinformationsBrowser(Application $app, Request $request) { - $conf = array( - 'version' => array(_('report::version '), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0) - ); + $conf = [ + 'version' => [_('report::version '), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0] + ]; $info = new \module_report_nav( $app, @@ -273,18 +273,18 @@ class Informations implements ControllerProviderInterface $reportArray = $info->buildTabInfoNav($conf, $browser); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => $browser - )); + ]); } /** @@ -296,26 +296,26 @@ class Informations implements ControllerProviderInterface */ public function doReportInformationsDocument(Application $app, Request $request) { - $config = array( - 'photo' => array(_('report:: document'), 0, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 0, 0, 0, 0), - 'date' => array(_('report:: date'), 0, 0, 0, 0), - 'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'titre' => array(_('report:: titre'), 0, 0, 0, 0), - 'taille' => array(_('report:: poids'), 0, 0, 0, 0) - ); + $config = [ + 'photo' => [_('report:: document'), 0, 0, 0, 0], + 'record_id' => [_('report:: record id'), 0, 0, 0, 0], + 'date' => [_('report:: date'), 0, 0, 0, 0], + 'type' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'titre' => [_('report:: titre'), 0, 0, 0, 0], + 'taille' => [_('report:: poids'), 0, 0, 0, 0] + ]; - $config_dl = array( - 'ddate' => array(_('report:: date'), 0, 0, 0, 0), - 'user' => array(_('report:: utilisateurs'), 0, 0, 0, 0), - 'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'coll_id' => array(_('report:: collections'), 0, 0, 0, 0), - 'comment' => array(_('report:: commentaire'), 0, 0, 0, 0), - 'fonction' => array(_('report:: fonction'), 0, 0, 0, 0), - 'activite' => array(_('report:: activite'), 0, 0, 0, 0), - 'pays' => array(_('report:: pays'), 0, 0, 0, 0), - 'societe' => array(_('report:: societe'), 0, 0, 0, 0) - ); + $config_dl = [ + 'ddate' => [_('report:: date'), 0, 0, 0, 0], + 'user' => [_('report:: utilisateurs'), 0, 0, 0, 0], + 'final' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'coll_id' => [_('report:: collections'), 0, 0, 0, 0], + 'comment' => [_('report:: commentaire'), 0, 0, 0, 0], + 'fonction' => [_('report:: fonction'), 0, 0, 0, 0], + 'activite' => [_('report:: activite'), 0, 0, 0, 0], + 'pays' => [_('report:: pays'), 0, 0, 0, 0], + 'societe' => [_('report:: societe'), 0, 0, 0, 0] + ]; //format conf according user preferences if ('' !== $columnsList = $request->request->get('list_column', '')) { @@ -361,25 +361,25 @@ class Informations implements ControllerProviderInterface $title = $what->getTitle(); - $html = $app['twig']->render('report/ajax_data_content.html.twig', array( + $html = $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); $from = $request->request->get('from', ''); if ('TOOL' === $from) { $what->setTitle(''); - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } if ('DASH' !== $from && 'PUSHDOC' !== $from) { @@ -393,7 +393,7 @@ class Informations implements ControllerProviderInterface $mapColumnTitleToSqlField = $download->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -406,10 +406,10 @@ class Informations implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $download->colFilter($field), 'field' => $field - )), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -437,33 +437,33 @@ class Informations implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } - $html .= $app['twig']->render('report/ajax_data_content.html.twig', array( + $html .= $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } if ($app['phraseanet.registry']->get('GV_anonymousReport') == false && $from !== 'DOC' && $from !== 'DASH' && $from !== 'GEN' && $from !== 'PUSHDOC') { - $conf = array( - 'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0), - 'nom' => array(_('report:: nom'), 0, 0, 0, 0), - 'mail' => array(_('report:: email'), 0, 0, 0, 0), - 'adresse' => array(_('report:: adresse'), 0, 0, 0, 0), - 'tel' => array(_('report:: telephone'), 0, 0, 0, 0) - ); + $conf = [ + 'identifiant' => [_('report:: identifiant'), 0, 0, 0, 0], + 'nom' => [_('report:: nom'), 0, 0, 0, 0], + 'mail' => [_('report:: email'), 0, 0, 0, 0], + 'adresse' => [_('report:: adresse'), 0, 0, 0, 0], + 'tel' => [_('report:: telephone'), 0, 0, 0, 0] + ]; $info = new \module_report_nav( $app, @@ -477,7 +477,7 @@ class Informations implements ControllerProviderInterface $info->setConfig(false); $info->setTitle(_('report:: utilisateur')); - $reportArray = $info->buildTabGrpInfo(false, array(), $request->request->get('user'), $conf, false); + $reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false); if ($request->request->get('printcsv') == 'on') { $download->setPrettyString(false); @@ -488,29 +488,29 @@ class Informations implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } - $html .= $app['twig']->render('report/ajax_data_content.html.twig', array( + $html .= $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Report/Root.php b/lib/Alchemy/Phrasea/Controller/Report/Root.php index 1d0959dc88..8f3f818307 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Root.php @@ -74,7 +74,7 @@ class Root implements ControllerProviderInterface $dashboard->execute(); - return $app['twig']->render('report/report_layout_child.html.twig', array( + return $app['twig']->render('report/report_layout_child.html.twig', [ 'ajax_dash' => true, 'dashboard' => $dashboard, 'home_title' => $app['phraseanet.registry']->get('GV_homeTitle'), @@ -84,7 +84,7 @@ class Root implements ControllerProviderInterface 'g_anal' => $app['phraseanet.registry']->get('GV_googleAnalytics'), 'ajax' => false, 'ajax_chart' => false - )); + ]); } $dmin = $request->request->get('dmin'); @@ -96,9 +96,9 @@ class Root implements ControllerProviderInterface $dashboard->execute(); - return $app->json(array('html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', array( + return $app->json(['html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', [ 'dashboard' => $dashboard - )))); + ])]); } /** @@ -111,7 +111,7 @@ class Root implements ControllerProviderInterface */ public function initReport(Application $app, Request $request) { - $popbases = $request->request->get('popbases', array()); + $popbases = $request->request->get('popbases', []); if ('' === $dmin = $request->request->get('dmin', '')) { $dmin = '01-' . date('m') . '-' . date('Y'); @@ -125,7 +125,7 @@ class Root implements ControllerProviderInterface $dmax = \DateTime::createFromFormat('d-m-Y H:i:s', sprintf('%s 23:59:59', $dmax)); //get user's sbas & collections selection from popbases - $selection = array(); + $selection = []; $liste = $id_sbas = ''; $i = 0; foreach (array_fill_keys($popbases, 0) as $key => $val) { @@ -142,13 +142,13 @@ class Root implements ControllerProviderInterface //fill the last entry $selection[$id_sbas]['liste'] = $liste; - return $app['twig']->render('report/ajax_report_content.html.twig', array( + return $app['twig']->render('report/ajax_report_content.html.twig', [ 'selection' => $selection, 'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'), 'ajax' => true, 'dmin' => $dmin->format('Y-m-d H:i:s'), 'dmax' => $dmax->format('Y-m-d H:i:s'), - )); + ]); } /** @@ -168,16 +168,16 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf = array( - 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'ip' => array(_('report:: IP'), 1, 0, 0, 0), - 'appli' => array(_('report:: modules'), 1, 0, 0, 0), - 'fonction' => array(_('report::fonction'), 1, 1, 1, 1), - 'activite' => array(_('report::activite'), 1, 1, 1, 1), - 'pays' => array(_('report::pays'), 1, 1, 1, 1), - 'societe' => array(_('report::societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'ip' => [_('report:: IP'), 1, 0, 0, 0], + 'appli' => [_('report:: modules'), 1, 0, 0, 0], + 'fonction' => [_('report::fonction'), 1, 1, 1, 1], + 'activite' => [_('report::activite'), 1, 1, 1, 1], + 'pays' => [_('report::pays'), 1, 1, 1, 1], + 'societe' => [_('report::societe'), 1, 1, 1, 1] + ]; if ($request->request->get('printcsv') == 'on') { $cnx->setHasLimit(false); @@ -189,7 +189,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $cnx, $conf); @@ -198,15 +198,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -214,7 +214,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -234,15 +234,15 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf = array( - 'user' => array(_('report:: utilisateur'), 1, 1, 1, 1), - 'search' => array(_('report:: question'), 1, 0, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), - 'activite' => array(_('report:: activite'), 1, 1, 1, 1), - 'pays' => array(_('report:: pays'), 1, 1, 1, 1), - 'societe' => array(_('report:: societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('report:: utilisateur'), 1, 1, 1, 1], + 'search' => [_('report:: question'), 1, 0, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], + 'activite' => [_('report:: activite'), 1, 1, 1, 1], + 'pays' => [_('report:: pays'), 1, 1, 1, 1], + 'societe' => [_('report:: societe'), 1, 1, 1, 1] + ]; if ($request->request->get('printcsv') == 'on') { $questions->setHasLimit(false); @@ -254,7 +254,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $questions, $conf); @@ -263,15 +263,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -279,7 +279,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -299,24 +299,24 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf_pref = array(); + $conf_pref = []; foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) { - $conf_pref[strtolower($field)] = array($field, 0, 0, 0, 0); + $conf_pref[strtolower($field)] = [$field, 0, 0, 0, 0]; } - $conf = array_merge(array( - 'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'record_id' => array(_('report:: record id'), 1, 1, 1, 1), - 'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1), - 'coll_id' => array(_('report:: collections'), 1, 0, 1, 1), - 'comment' => array(_('report:: commentaire'), 1, 0, 0, 0), - 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), - 'activite' => array(_('report:: activite'), 1, 1, 1, 1), - 'pays' => array(_('report:: pays'), 1, 1, 1, 1), - 'societe' => array(_('report:: societe'), 1, 1, 1, 1) - ), $conf_pref); + $conf = array_merge([ + 'user' => [_('report:: utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'record_id' => [_('report:: record id'), 1, 1, 1, 1], + 'final' => [_('phrseanet:: sous definition'), 1, 0, 1, 1], + 'coll_id' => [_('report:: collections'), 1, 0, 1, 1], + 'comment' => [_('report:: commentaire'), 1, 0, 0, 0], + 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], + 'activite' => [_('report:: activite'), 1, 1, 1, 1], + 'pays' => [_('report:: pays'), 1, 1, 1, 1], + 'societe' => [_('report:: societe'), 1, 1, 1, 1] + ], $conf_pref); if ($request->request->get('printcsv') == 'on') { $download->setHasLimit(false); @@ -328,7 +328,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $download, $conf); @@ -337,15 +337,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -353,7 +353,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -373,20 +373,20 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf_pref = array(); + $conf_pref = []; foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) { - $conf_pref[strtolower($field)] = array($field, 0, 0, 0, 0); + $conf_pref[strtolower($field)] = [$field, 0, 0, 0, 0]; } - $conf = array_merge(array( - 'telechargement' => array(_('report:: telechargements'), 1, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 1, 1, 1, 0), - 'final' => array(_('phraseanet:: sous definition'), 1, 0, 1, 1), - 'file' => array(_('report:: fichier'), 1, 0, 0, 1), - 'mime' => array(_('report:: type'), 1, 0, 1, 1), - 'size' => array(_('report:: taille'), 1, 0, 1, 1) - ), $conf_pref); + $conf = array_merge([ + 'telechargement' => [_('report:: telechargements'), 1, 0, 0, 0], + 'record_id' => [_('report:: record id'), 1, 1, 1, 0], + 'final' => [_('phraseanet:: sous definition'), 1, 0, 1, 1], + 'file' => [_('report:: fichier'), 1, 0, 0, 1], + 'mime' => [_('report:: type'), 1, 0, 1, 1], + 'size' => [_('report:: taille'), 1, 0, 1, 1] + ], $conf_pref); if ($request->request->get('printcsv') == 'on') { $document->setHasLimit(false); @@ -398,7 +398,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $document, $conf, 'record_id'); @@ -407,15 +407,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => true - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -423,7 +423,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -443,63 +443,63 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf_nav = array( - 'nav' => array(_('report:: navigateur'), 0, 1, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); + $conf_nav = [ + 'nav' => [_('report:: navigateur'), 0, 1, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; - $conf_combo = array( - 'combo' => array(_('report:: navigateurs et plateforme'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); - $conf_os = array( - 'os' => array(_('report:: plateforme'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); - $conf_res = array( - 'res' => array(_('report:: resolution'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); - $conf_mod = array( - 'appli' => array(_('report:: module'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); + $conf_combo = [ + 'combo' => [_('report:: navigateurs et plateforme'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; + $conf_os = [ + 'os' => [_('report:: plateforme'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; + $conf_res = [ + 'res' => [_('report:: resolution'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; + $conf_mod = [ + 'appli' => [_('report:: module'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; - $report = array( + $report = [ 'nav' => $nav->buildTabNav($conf_nav), 'os' => $nav->buildTabOs($conf_os), 'res' => $nav->buildTabRes($conf_res), 'mod' => $nav->buildTabModule($conf_mod), 'combo' => $nav->buildTabCombo($conf_combo) - ); + ]; if ($request->request->get('printcsv') == 'on') { - return $app->json(array( + return $app->json([ 'nav' => \format::arr_to_csv($report['nav']['result'], $conf_nav), 'os' => \format::arr_to_csv($report['os']['result'], $conf_os), 'res' => \format::arr_to_csv($report['res']['result'], $conf_res), 'mod' => \format::arr_to_csv($report['mod']['result'], $conf_mod), 'combo' => \format::arr_to_csv($report['combo']['result'], $conf_combo) - )); + ]); } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => true, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } /** @@ -541,9 +541,9 @@ class Root implements ControllerProviderInterface //display content of a table column when user click on it if ($request->request->get('conf') == 'on') { - return $app->json(array('liste' => $app['twig']->render('report/listColumn.html.twig', array( + return $app->json(['liste' => $app['twig']->render('report/listColumn.html.twig', [ 'conf' => $base_conf - )), 'title' => _('configuration'))); + ]), 'title' => _('configuration')]); } //set order @@ -554,7 +554,7 @@ class Root implements ControllerProviderInterface //work on filters $mapColumnTitleToSqlField = $report->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -567,10 +567,10 @@ class Root implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - )), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -605,18 +605,18 @@ class Root implements ControllerProviderInterface $groupField = isset($conf[strtolower($groupby)]['title']) ? $conf[strtolower($groupby)]['title'] : ''; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => true, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField)) - )); + ]); } //set Limit diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index 6c6a20c6a6..492eeeab5a 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -108,7 +108,7 @@ class Account implements ControllerProviderInterface return $app['twig']->render('account/change-password.html.twig', array_merge( Login::getDefaultTemplateVariables($app), - array('form' => $form->createView()) + ['form' => $form->createView()] )); } @@ -148,7 +148,7 @@ class Account implements ControllerProviderInterface $date = new \DateTime('1 day'); $token = $app['tokens']->getUrlToken(\random::TYPE_EMAIL, $app['authentication']->getUser()->get_id(), $date, $app['authentication']->getUser()->get_email()); - $url = $app->url('account_reset_email', array('token' => $token)); + $url = $app->url('account_reset_email', ['token' => $token]); try { $receiver = Receiver::fromUser($app['authentication']->getUser()); @@ -227,7 +227,7 @@ class Account implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -241,9 +241,9 @@ class Account implements ControllerProviderInterface { require_once $app['root.path'] . '/lib/classes/deprecated/inscript.api.php'; - return $app['twig']->render('account/access.html.twig', array( + return $app['twig']->render('account/access.html.twig', [ 'inscriptions' => giveMeBases($app, $app['authentication']->getUser()->get_id()) - )); + ]); } /** @@ -255,9 +255,9 @@ class Account implements ControllerProviderInterface */ public function accountAuthorizedApps(Application $app, Request $request) { - return $app['twig']->render('account/authorized_apps.html.twig', array( + return $app['twig']->render('account/authorized_apps.html.twig', [ "applications" => \API_OAuth2_Application::load_app_by_user($app, $app['authentication']->getUser()), - )); + ]); } /** @@ -274,10 +274,10 @@ class Account implements ControllerProviderInterface ORDER BY s.created DESC'; $query = $app['EM']->createQuery($dql); - $query->setParameters(array('usr_id' => $app['session']->get('usr_id'))); + $query->setParameters(['usr_id' => $app['session']->get('usr_id')]); $sessions = $query->getResult(); - $result = array(); + $result = []; foreach ($sessions as $session) { $info = ''; try { @@ -302,13 +302,13 @@ class Account implements ControllerProviderInterface } - $result[] = array( + $result[] = [ 'session' => $session, 'info' => $info, - ); + ]; } - return $app['twig']->render('account/sessions.html.twig', array('sessions' => $result)); + return $app['twig']->render('account/sessions.html.twig', ['sessions' => $result]); } /** @@ -320,11 +320,11 @@ class Account implements ControllerProviderInterface */ public function displayAccount(Application $app, Request $request) { - return $app['twig']->render('account/account.html.twig', array( + return $app['twig']->render('account/account.html.twig', [ 'user' => $app['authentication']->getUser(), 'evt_mngr' => $app['events-manager'], 'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()), - )); + ]); } /** @@ -336,7 +336,7 @@ class Account implements ControllerProviderInterface */ public function updateAccount(PhraseaApplication $app, Request $request) { - $demands = (array) $request->request->get('demand', array()); + $demands = (array) $request->request->get('demand', []); if (0 !== count($demands)) { $register = new \appbox_register($app['phraseanet.appbox']); @@ -351,7 +351,7 @@ class Account implements ControllerProviderInterface } } - $accountFields = array( + $accountFields = [ 'form_gender', 'form_firstname', 'form_lastname', @@ -369,7 +369,7 @@ class Account implements ControllerProviderInterface 'form_destFTP', 'form_prefixFTPfolder', 'form_retryFTP' - ); + ]; if (0 === count(array_diff($accountFields, array_keys($request->request->all())))) { @@ -410,7 +410,7 @@ class Account implements ControllerProviderInterface } } - $requestedNotifications = (array) $request->request->get('notifications', array()); + $requestedNotifications = (array) $request->request->get('notifications', []); foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()) as $notifications) { foreach ($notifications as $notification) { diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php index 79a925fe83..a17e2ef8d7 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php @@ -90,7 +90,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -121,7 +121,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -158,7 +158,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error, 'token' => $accessToken)); + return $app->json(['success' => !$error, 'token' => $accessToken]); } /** @@ -184,7 +184,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -212,13 +212,13 @@ class Developers implements ControllerProviderInterface ->set_type($form->getType()) ->set_website($form->getSchemeWebsite() . $form->getWebsite()); - return $app->redirectPath('developers_application', array('id' => $application->get_id())); + return $app->redirectPath('developers_application', ['id' => $application->get_id()]); } - $var = array( + $var = [ "violations" => $violations, "form" => $form - ); + ]; return $app['twig']->render('/developers/application_form.html.twig', $var); } @@ -232,9 +232,9 @@ class Developers implements ControllerProviderInterface */ public function listApps(Application $app, Request $request) { - return $app['twig']->render('developers/applications.html.twig', array( + return $app['twig']->render('developers/applications.html.twig', [ "applications" => \API_OAuth2_Application::load_dev_app_by_user($app, $app['authentication']->getUser()) - )); + ]); } /** @@ -246,11 +246,11 @@ class Developers implements ControllerProviderInterface */ public function displayFormApp(Application $app, Request $request) { - return $app['twig']->render('developers/application_form.html.twig', array( + return $app['twig']->render('developers/application_form.html.twig', [ "violations" => null, 'form' => null, 'request' => $request - )); + ]); } /** @@ -271,10 +271,10 @@ class Developers implements ControllerProviderInterface $token = $client->get_user_account($app['authentication']->getUser())->get_token()->get_value(); - return $app['twig']->render('developers/application.html.twig', array( + return $app['twig']->render('developers/application.html.twig', [ "application" => $client, "user" => $app['authentication']->getUser(), "token" => $token - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index 67a6065e4a..2cfb59c44f 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -50,21 +50,21 @@ class Login implements ControllerProviderInterface { public static function getDefaultTemplateVariables(Application $app) { - $items = array(); + $items = []; foreach ($app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedItem')->loadLatest($app, 20) as $item) { $record = $item->getRecord($app); $preview = $record->get_subdef('preview'); $permalink = $preview->get_permalink(); - $items[] = array( + $items[] = [ 'record' => $record, 'preview' => $preview, 'permalink' => $permalink - ); + ]; } - return array( + return [ 'last_publication_items' => $items, 'instance_title' => $app['phraseanet.registry']->get('GV_homeTitle'), 'has_terms_of_use' => $app->hasTermsOfUse(), @@ -84,7 +84,7 @@ class Login implements ControllerProviderInterface 'authentication_providers' => $app['authentication.providers'], 'registration_fields' => $app['registration.fields'], 'registration_optional_fields' => $app['registration.optional-fields'] - ); + ]; } public function connect(Application $app) @@ -110,10 +110,10 @@ class Login implements ControllerProviderInterface // then post login operation like getting baskets from an invit session // could be done by Session_handler authentication process - $params = array(); + $params = []; if (null !== $redirect = $request->query->get('redirect')) { - $params = array('redirect' => ltrim($redirect, '/')); + $params = ['redirect' => ltrim($redirect, '/')]; } $response = $app->redirectPath('logout', $params); @@ -203,7 +203,7 @@ class Login implements ControllerProviderInterface // Displays Terms of use $controllers->get('/cgus', function (PhraseaApplication $app, Request $request) { return $app['twig']->render('login/cgus.html.twig', array_merge( - array('cgus' => \databox_cgu::getHome($app)), + ['cgus' => \databox_cgu::getHome($app)], self::getDefaultTemplateVariables($app) )); })->bind('login_cgus'); @@ -216,7 +216,7 @@ class Login implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { - $response = $app->json(array( + $response = $app->json([ 'validation_blank' => _('Please provide a value.'), 'validation_choice_min' => _('Please select at least %s choice.'), 'validation_email' => _('Please provide a valid email address.'), @@ -234,7 +234,7 @@ class Login implements ControllerProviderInterface 'ordinary' => _('Ordinary'), 'good' => _('Good'), 'great' => _('Great'), - )); + ]); $response->setExpires(new \DateTime('+1 day')); @@ -314,7 +314,7 @@ class Login implements ControllerProviderInterface $selected = isset($data['collections']) ? $data['collections'] : null; } $inscriptions = giveMeBases($app); - $inscOK = array(); + $inscOK = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { @@ -342,7 +342,7 @@ class Login implements ControllerProviderInterface $user = \User_Adapter::create($app, $data['login'], $data['password'], $data['email'], false); - foreach (array( + foreach ([ 'gender' => 'set_gender', 'firstname' => 'set_firstname', 'lastname' => 'set_lastname', @@ -354,9 +354,9 @@ class Login implements ControllerProviderInterface 'company' => 'set_company', 'position' => 'set_position', 'geonameid' => 'set_geonameid', - ) as $property => $method) { + ] as $property => $method) { if (isset($data[$property])) { - call_user_func(array($user, $method), $data[$property]); + call_user_func([$user, $method], $data[$property]); } } @@ -365,7 +365,7 @@ class Login implements ControllerProviderInterface $app['EM']->flush(); } - $demandOK = array(); + $demandOK = []; if ($app['phraseanet.registry']->get('GV_autoregister')) { @@ -373,7 +373,7 @@ class Login implements ControllerProviderInterface $template_user = \User_Adapter::getInstance($template_user_id, $app); - $base_ids = array(); + $base_ids = []; foreach (array_keys($inscOK) as $base_id) { $base_ids[] = $base_id; @@ -395,11 +395,11 @@ class Login implements ControllerProviderInterface $demandOK[$base_id] = true; } - $params = array( + $params = [ 'demand' => $demandOK, 'autoregister' => $autoReg, 'usr_id' => $user->get_id() - ); + ]; $app['events-manager']->trigger('__REGISTER_AUTOREGISTER__', $params); $app['events-manager']->trigger('__REGISTER_APPROVAL__', $params); @@ -423,21 +423,21 @@ class Login implements ControllerProviderInterface $provider = $this->findProvider($app, $request->query->get('providerId')); $identity = $provider->getIdentity(); - $form->setData(array_filter(array( + $form->setData(array_filter([ 'email' => $identity->getEmail(), 'firstname' => $identity->getFirstname(), 'lastname' => $identity->getLastname(), 'company' => $identity->getCompany(), 'provider-id' => $provider->getId(), - ))); + ])); } return $app['twig']->render('login/register-classic.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array( + [ 'geonames_server_uri' => str_replace(sprintf('%s:', parse_url($app['geonames.server-uri'], PHP_URL_SCHEME)), '', $app['geonames.server-uri']), 'form' => $form->createView() - ))); + ])); } private function attachProviderToUser(EntityManager $em, ProviderInterface $provider, \User_Adapter $user) @@ -505,7 +505,7 @@ class Login implements ControllerProviderInterface $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email()); $mail = MailRequestEmailConfirmation::create($app, $receiver); - $mail->setButtonUrl($app->url('login_register_confirm', array('code' => $token))); + $mail->setButtonUrl($app->url('login_register_confirm', ['code' => $token])); $mail->setExpiration($expire); $app['notification.deliverer']->deliver($mail); @@ -589,7 +589,7 @@ class Login implements ControllerProviderInterface } $form = $app->form(new PhraseaRecoverPasswordForm($app)); - $form->setData(array('token' => $token)); + $form->setData(['token' => $token]); if ('POST' === $request->getMethod()) { $form->bind($request); @@ -615,7 +615,7 @@ class Login implements ControllerProviderInterface return $app['twig']->render('login/renew-password.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array('form' => $form->createView()) + ['form' => $form->createView()] )); } @@ -655,7 +655,7 @@ class Login implements ControllerProviderInterface return $app->abort(500, 'Unable to generate a token'); } - $url = $app->url('login_renew_password', array('token' => $token), true); + $url = $app->url('login_renew_password', ['token' => $token], true); $mail = MailRequestPasswordUpdate::create($app, $receiver); $mail->setLogin($user->get_login()); @@ -673,9 +673,9 @@ class Login implements ControllerProviderInterface return $app['twig']->render('login/forgot-password.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array( + [ 'form' => $form->createView(), - ))); + ])); } /** @@ -712,9 +712,9 @@ class Login implements ControllerProviderInterface $app->addFlash('info', _('Vous etes maintenant deconnecte. A bientot.')); - $response = $app->redirectPath('homepage', array( + $response = $app->redirectPath('homepage', [ 'redirect' => $request->query->get("redirect") - )); + ]); $response->headers->clearCookie('persistent'); $response->headers->clearCookie('last_act'); @@ -740,19 +740,19 @@ class Login implements ControllerProviderInterface $app->addFlash('error', _('login::erreur: No available connection - Please contact sys-admin')); } - $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC')); + $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC']); $form = $app->form(new PhraseaAuthenticationForm()); - $form->setData(array( + $form->setData([ 'redirect' => $request->query->get('redirect') - )); + ]); return $app['twig']->render('login/index.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array( + [ 'feeds' => $feeds, 'form' => $form->createView(), - ))); + ])); } /** @@ -765,7 +765,7 @@ class Login implements ControllerProviderInterface public function authenticate(PhraseaApplication $app, Request $request) { $form = $app->form(new PhraseaAuthenticationForm()); - $redirector = function (array $params = array()) use ($app) { + $redirector = function (array $params = []) use ($app) { return $app->redirectPath('homepage', $params); }; @@ -847,13 +847,13 @@ class Login implements ControllerProviderInterface continue; } - $app['events-manager']->trigger('__VALIDATION_REMINDER__', array( + $app['events-manager']->trigger('__VALIDATION_REMINDER__', [ 'to' => $participantId, 'ssel_id' => $basketId, 'from' => $validationSession->getInitiatorId(), 'validate_id' => $validationSession->getId(), - 'url' => $app->url('lightbox_validation', array('basket' => $basketId, 'LOG' => $token)), - )); + 'url' => $app->url('lightbox_validation', ['basket' => $basketId, 'LOG' => $token]), + ]); $participant->setReminded(new \DateTime('now')); $app['EM']->persist($participant); @@ -959,7 +959,7 @@ class Login implements ControllerProviderInterface return $app->redirect($redirection); } elseif ($app['registration.enabled']) { - return $app->redirectPath('login_register_classic', array('providerId' => $providerId)); + return $app->redirectPath('login_register_classic', ['providerId' => $providerId]); } $app->addFlash('error', _('Your identity is not recognized.')); @@ -999,7 +999,7 @@ class Login implements ControllerProviderInterface throw new AuthenticationException(call_user_func($redirector)); } - $params = array(); + $params = []; if (null !== $redirect = $request->get('redirect')) { $params['redirect'] = ltrim($redirect, '/'); @@ -1039,7 +1039,7 @@ class Login implements ControllerProviderInterface if ($user->get_id() != $inviteUsrId = $request->cookies->get('invite-usr_id')) { $repo = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $baskets = $repo->findBy(array('usr_id' => $inviteUsrId)); + $baskets = $repo->findBy(['usr_id' => $inviteUsrId]); foreach ($baskets as $basket) { $basket->setUsrId($user->get_id()); diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php index ab3f646e66..cbe408bc7a 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php +++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php @@ -67,7 +67,7 @@ class RSSFeeds implements ControllerProviderInterface ->assert('format', '(rss|atom)'); $controllers->get('/userfeed/aggregated/{token}/{format}/', function (Application $app, $token, $format) { - $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(array("value" => $token)); + $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(["value" => $token]); $user = \User_Adapter::getInstance($token->getUsrId(), $app); diff --git a/lib/Alchemy/Phrasea/Controller/Root/Root.php b/lib/Alchemy/Phrasea/Controller/Root/Root.php index 703e2e2b28..41147d861c 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Root.php @@ -52,7 +52,7 @@ class Root implements ControllerProviderInterface $buffer = "User-Agent: *\n" . "Disallow: /\n"; } - return new Response($buffer, 200, array('Content-Type' => 'text/plain')); + return new Response($buffer, 200, ['Content-Type' => 'text/plain']); } public function getRoot(Application $app, Request $request) diff --git a/lib/Alchemy/Phrasea/Controller/Root/Session.php b/lib/Alchemy/Phrasea/Controller/Root/Session.php index 7548beb04b..063db799f2 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Session.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Session.php @@ -50,12 +50,12 @@ class Session implements ControllerProviderInterface $app->abort(400); } - $ret = array( + $ret = [ 'status' => 'unknown', 'message' => '', 'notifications' => false, - 'changed' => array() - ); + 'changed' => [] + ]; if ($app['authentication']->isAuthenticated()) { $usr_id = $app['authentication']->getUser()->get_id(); @@ -99,9 +99,9 @@ class Session implements ControllerProviderInterface $ret['status'] = 'ok'; - $ret['notifications'] = $app['twig']->render('prod/notifications.html.twig', array( + $ret['notifications'] = $app['twig']->render('prod/notifications.html.twig', [ 'notifications' => $app['events-manager']->get_notifications() - )); + ]); $baskets = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket')->findUnreadActiveByUser($app['authentication']->getUser()); @@ -109,7 +109,7 @@ class Session implements ControllerProviderInterface $ret['changed'][] = $basket->getId(); } - if (in_array($app['session']->get('phraseanet.message'), array('1', null))) { + if (in_array($app['session']->get('phraseanet.message'), ['1', null])) { if ($app['configuration']['main']['maintenance']) { $ret['message'] .= _('The application is going down for maintenance, please logout.'); } @@ -147,10 +147,10 @@ class Session implements ControllerProviderInterface $app['EM']->flush(); if ($app['request']->isXmlHttpRequest()) { - return $app->json(array( + return $app->json([ 'success' => true, 'session_id' => $id - )); + ]); } return $app->redirectPath('account_sessions'); diff --git a/lib/Alchemy/Phrasea/Controller/Setup.php b/lib/Alchemy/Phrasea/Controller/Setup.php index 4b75ae0071..c86ea983d3 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Setup.php @@ -53,37 +53,37 @@ class Setup implements ControllerProviderInterface { $requirementsCollection = $this->getRequirementsCollection(); - return $app['twig']->render('/setup/index.html.twig', array( + return $app['twig']->render('/setup/index.html.twig', [ 'locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', 'requirementsCollection' => $requirementsCollection, - )); + ]); } private function getRequirementsCollection() { - return array( + return [ new BinariesRequirements(), new FilesystemRequirements(), new LocalesRequirements(), new PhpRequirements(), new PhraseaRequirements(), new SystemRequirements(), - ); + ]; } public function displayUpgradeInstructions(Application $app, Request $request) { - return $app['twig']->render('/setup/upgrade-instructions.html.twig', array( + return $app['twig']->render('/setup/upgrade-instructions.html.twig', [ 'locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), - )); + ]); } public function getInstallForm(Application $app, Request $request) { - $warnings = array(); + $warnings = []; $requirementsCollection = $this->getRequirementsCollection(); @@ -99,16 +99,16 @@ class Setup implements ControllerProviderInterface $warnings[] = _('It is not recommended to install Phraseanet without HTTPS support'); } - return $app['twig']->render('/setup/step2.html.twig', array( + return $app['twig']->render('/setup/step2.html.twig', [ 'locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), - 'available_templates' => array('en', 'fr'), + 'available_templates' => ['en', 'fr'], 'warnings' => $warnings, 'error' => $request->query->get('error'), 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', 'discovered_binaries' => \setup::discover_binaries(), 'rootpath' => realpath(__DIR__ . '/../../../../'), - )); + ]); } public function doInstall(Application $app, Request $request) @@ -128,21 +128,21 @@ class Setup implements ControllerProviderInterface $databox_name = $request->request->get('db_name'); try { - $abConn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $ab_password, $appbox_name, array(), $app['debug']); + $abConn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $ab_password, $appbox_name, [], $app['debug']); } catch (\Exception $e) { - return $app->redirectPath('install_step2', array( + return $app->redirectPath('install_step2', [ 'error' => _('Appbox is unreachable'), - )); + ]); } try { if ($databox_name) { - $dbConn = new \connection_pdo('databox', $hostname, $port, $user_ab, $ab_password, $databox_name, array(), $app['debug']); + $dbConn = new \connection_pdo('databox', $hostname, $port, $user_ab, $ab_password, $databox_name, [], $app['debug']); } } catch (\Exception $e) { - return $app->redirectPath('install_step2', array( + return $app->redirectPath('install_step2', [ 'error' => _('Databox is unreachable'), - )); + ]); } $email = $request->request->get('email'); @@ -154,8 +154,8 @@ class Setup implements ControllerProviderInterface $installer = $app['phraseanet.installer']; $installer->setPhraseaIndexerPath($request->request->get('binary_phraseanet_indexer')); - $binaryData = array(); - foreach (array( + $binaryData = []; + foreach ([ 'php_binary' => $request->request->get('binary_php'), 'phraseanet_indexer' => $request->request->get('binary_phraseanet_indexer'), 'swf_extract_binary' => $request->request->get('binary_swfextract'), @@ -166,7 +166,7 @@ class Setup implements ControllerProviderInterface 'mp4box_binary' => $request->request->get('binary_MP4Box'), 'pdftotext_binary' => $request->request->get('binary_xpdf'), 'recess_binary' => $request->request->get('binary_recess'), - ) as $key => $path) { + ] as $key => $path) { $binaryData[$key] = $path; } @@ -174,14 +174,14 @@ class Setup implements ControllerProviderInterface $app['authentication']->openAccount($user); - return $app->redirectPath('admin', array( + return $app->redirectPath('admin', [ 'section' => 'taskmanager', 'notice' => 'install_success', - )); + ]); } catch (\Exception $e) { - return $app->redirectPath('install_step2', array( + return $app->redirectPath('install_step2', [ 'error' => sprintf(_('an error occured : %s'), $e->getMessage()), - )); + ]); } } } diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php index a8e0296653..7479f580b2 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php @@ -104,7 +104,7 @@ class Thesaurus implements ControllerProviderInterface } } - return $app['twig']->render('thesaurus/accept.html.twig', array( + return $app['twig']->render('thesaurus/accept.html.twig', [ 'dlg' => $request->get('dlg'), 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), @@ -117,12 +117,12 @@ class Thesaurus implements ControllerProviderInterface 'fullpath_tgt' => $fullpath_tgt, 'fullpath_src' => $fullpath_src, 'acceptable' => $acceptable, - )); + ]); } public function exportText(Application $app, Request $request) { - $thits = $tnodes = array(); + $thits = $tnodes = []; $output = ''; if (null === $bid = $request->get("bid")) { @@ -167,10 +167,10 @@ class Thesaurus implements ControllerProviderInterface } } - return $app['twig']->render('thesaurus/export-text.html.twig', array( + return $app['twig']->render('thesaurus/export-text.html.twig', [ 'output' => $output, 'smp' => $request->get('smp'), - )); + ]); } private function printTNodes(&$output, &$tnodes, $iln, $hit, $ilg, $osl) @@ -272,29 +272,29 @@ class Thesaurus implements ControllerProviderInterface { if ($node->nodeType == XML_ELEMENT_NODE) { if (($nname = $node->nodeName) == "thesaurus" || $nname == "cterms") { - $tnodes[] = array( + $tnodes[] = [ "type" => "ROOT", "depth" => $depth, "name" => $nname, "cdate" => $node->getAttribute("creation_date"), "mdate" => $node->getAttribute("modification_date") - ); + ]; } elseif (($fld = $node->getAttribute("field"))) { if ($node->getAttribute("delbranch")) { - $tnodes[] = array( + $tnodes[] = [ "type" => "TRASH", "depth" => $depth, "name" => $fld - ); + ]; } else { - $tnodes[] = array( + $tnodes[] = [ "type" => "FIELD", "depth" => $depth, "name" => $fld - ); + ]; } } else { - $tsy = array(); + $tsy = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "sy") { $id = $n->getAttribute("id"); @@ -304,21 +304,21 @@ class Thesaurus implements ControllerProviderInterface $hits = 0; } - $tsy[] = array( + $tsy[] = [ "v" => $n->getAttribute("v"), "lng" => $n->getAttribute("lng"), "hits" => $hits - ); + ]; } } - $tnodes[] = array("type" => "TERM", "depth" => $depth, "syns" => $tsy); + $tnodes[] = ["type" => "TERM", "depth" => $depth, "syns" => $tsy]; } } } private function export0($znode, &$tnodes, &$thits, &$output, $iln, $hit, $ilg, $osl) { - $nodes = array(); + $nodes = []; $depth = 0; for ($node = $znode->parentNode; $node; $node = $node->parentNode) { @@ -349,13 +349,13 @@ class Thesaurus implements ControllerProviderInterface public function exportTextDialog(Application $app, Request $request) { - return $app['twig']->render('thesaurus/export-text-dialog.html.twig', array( + return $app['twig']->render('thesaurus/export-text-dialog.html.twig', [ 'dlg' => $request->get('dlg'), 'bid' => $request->get('bid'), 'typ' => $request->get('typ'), 'piv' => $request->get('piv'), 'id' => $request->get('id'), - )); + ]); } public function exportTopics(Application $app, Request $request) @@ -363,7 +363,7 @@ class Thesaurus implements ControllerProviderInterface $lng = $app['locale']; $obr = explode(';', $request->get('obr')); - $t_lng = array(); + $t_lng = []; if ($request->get('ofm') == 'tofiles') { $t_lng = array_map(function ($code) { @@ -399,7 +399,7 @@ class Thesaurus implements ControllerProviderInterface } $now = date('YmdHis'); - $lngs = array(); + $lngs = []; try { $databox = $app['phraseanet.appbox']->get_databox((int) $request->get("bid")); if ($request->get("typ") == "TH") { @@ -438,7 +438,7 @@ class Thesaurus implements ControllerProviderInterface $this->export0Topics($xpathth->query($q)->item(0), $dom, $root, $lng, $request->get("srt"), $request->get("sth"), $request->get("sand"), $opened_display, $obr); if ($request->get("ofm") == 'toscreen') { - $lngs[$lng] = str_replace(array('&', '<', '>'), array('&', '<', '>'), $dom->saveXML()); + $lngs[$lng] = str_replace(['&', '<', '>'], ['&', '<', '>'], $dom->saveXML()); } elseif ($request->get("ofm") == 'tofiles') { $fname = 'topics_' . $lng . '.xml'; @@ -456,10 +456,10 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/export-topics.html.twig', array( + return $app['twig']->render('thesaurus/export-topics.html.twig', [ 'lngs' => $lngs, 'ofm' => $request->get('ofm'), - )); + ]); } private function export0Topics($znode, \DOMDocument $dom, \DOMNode $root, $lng, $srt, $sth, $sand, $opened_display, $obr) @@ -472,8 +472,8 @@ class Thesaurus implements ControllerProviderInterface { $ntopics = 0; if ($node->nodeType == XML_ELEMENT_NODE) { - $t_node = array(); - $t_sort = array(); + $t_node = []; + $t_sort = []; $i = 0; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "te") { @@ -506,7 +506,7 @@ class Thesaurus implements ControllerProviderInterface } $t_sort[$i] = $query; // tri sur w - $t_node[$i] = array('label' => $label, 'node' => $n); + $t_node[$i] = ['label' => $label, 'node' => $n]; $i ++; } @@ -550,14 +550,14 @@ class Thesaurus implements ControllerProviderInterface public function exportTopicsDialog(Application $app, Request $request) { - return $app['twig']->render('thesaurus/export-topics-dialog.html.twig', array( + return $app['twig']->render('thesaurus/export-topics-dialog.html.twig', [ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), 'dlg' => $request->get('dlg'), 'id' => $request->get('id'), 'obr' => $request->get('obr'), - )); + ]); } public function import(Application $app, Request $request) @@ -584,8 +584,8 @@ class Thesaurus implements ControllerProviderInterface $node->removeChild($node->firstChild); } - $cbad = array(); - $cok = array(); + $cbad = []; + $cok = []; for ($i = 0; $i < 32; $i ++) { $cbad[] = chr($i); $cok[] = '_'; @@ -732,7 +732,7 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/import.html.twig', array('err' => $err)); + return $app['twig']->render('thesaurus/import.html.twig', ['err' => $err]); } private function checkEncoding($string, $string_encoding) @@ -745,12 +745,12 @@ class Thesaurus implements ControllerProviderInterface public function importDialog(Application $app, Request $request) { - return $app['twig']->render('thesaurus/import-dialog.html.twig', array( + return $app['twig']->render('thesaurus/import-dialog.html.twig', [ 'dlg' => $request->get('dlg'), 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), - )); + ]); } public function indexThesaurus(Application $app, Request $request) @@ -770,10 +770,10 @@ class Thesaurus implements ControllerProviderInterface HAVING bas_edit_thesaurus > 0 ORDER BY sbas.ord"; - $bases = $languages = array(); + $bases = $languages = []; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -791,10 +791,10 @@ class Thesaurus implements ControllerProviderInterface $languages[$lng_code[0]] = $lng; } - return $app['twig']->render('thesaurus/index.html.twig', array( + return $app['twig']->render('thesaurus/index.html.twig', [ 'languages' => $languages, 'bases' => $bases, - )); + ]); } public function linkFieldStep1(Application $app, Request $request) @@ -830,7 +830,7 @@ class Thesaurus implements ControllerProviderInterface $fullBranch = " / " . $sy . $fullBranch; } } - $fieldnames = array(); + $fieldnames = []; $nodes = $xpathstruct->query("/record/description/*"); for ($i = 0; $i < $nodes->length; $i ++) { $fieldname = $nodes->item($i)->nodeName; @@ -852,13 +852,13 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/link-field-step1.html.twig', array( + return $app['twig']->render('thesaurus/link-field-step1.html.twig', [ 'piv' => $request->get('piv'), 'bid' => $request->get('bid'), 'tid' => $request->get('tid'), 'fullBranch' => $fullBranch, 'fieldnames' => $fieldnames - )); + ]); } public function linkFieldStep2(Application $app, Request $request) @@ -867,7 +867,7 @@ class Thesaurus implements ControllerProviderInterface return new Response('Missing bid parameter', 400); } - $oldlinks = array(); + $oldlinks = []; $needreindex = false; try { @@ -884,7 +884,7 @@ class Thesaurus implements ControllerProviderInterface $fieldname = $nodes->item($i)->nodeName; $oldbranch = $nodes->item($i)->getAttribute("tbranch"); $ck = false; - $tids = array(); // les ids de branches liees e ce champ + $tids = []; // les ids de branches liees e ce champ if ($oldbranch) { // ce champ a deje un tbranch, on balaye les branches auxquelles il est lie $thnodes = $xpathth->query($oldbranch); @@ -900,7 +900,7 @@ class Thesaurus implements ControllerProviderInterface } } - if (in_array($fieldname, $request->get('field', array())) != $ck) { + if (in_array($fieldname, $request->get('field', [])) != $ck) { if ($ck) { // print("il etait lie a la branche, il ne l'est plus
\n"); unset($tids[$request->get('tid')]); @@ -922,10 +922,10 @@ class Thesaurus implements ControllerProviderInterface } } - $oldlinks[$fieldname] = array( + $oldlinks[$fieldname] = [ 'old_branch' => $oldbranch, 'new_branch' => $newtbranch - ); + ]; if ($newtbranch != "") { $needreindex = true; @@ -937,13 +937,13 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/link-field-step2.html.twig', array( + return $app['twig']->render('thesaurus/link-field-step2.html.twig', [ 'piv' => $request->get('piv'), 'bid' => $request->get('bid'), 'tid' => $request->get('tid'), 'oldlinks' => $oldlinks, 'need_reindex' => $needreindex, - )); + ]); } public function linkFieldStep3(Application $app, Request $request) @@ -963,15 +963,15 @@ class Thesaurus implements ControllerProviderInterface $xpathct = new \DOMXPath($domct); $ctchanged = false; - $candidates2del = array(); - foreach ($request->get("f2unlk", array()) as $f2unlk) { + $candidates2del = []; + foreach ($request->get("f2unlk", []) as $f2unlk) { $q = "/cterms/te[@field='" . \thesaurus::xquery_escape($f2unlk) . "']"; $nodes = $xpathct->query($q); for ($i = 0; $i < $nodes->length; $i ++) { - $candidates2del[] = array( + $candidates2del[] = [ "field" => $f2unlk, "node" => $nodes->item($i) - ); + ]; } $field = $meta_struct->get_element_by_name($f2unlk); @@ -984,7 +984,7 @@ class Thesaurus implements ControllerProviderInterface $ctchanged = true; } - foreach ($request->get("fbranch", array()) as $fbranch) { + foreach ($request->get("fbranch", []) as $fbranch) { $p = strpos($fbranch, "<"); if ($p > 1) { $fieldname = substr($fbranch, 0, $p); @@ -1003,8 +1003,8 @@ class Thesaurus implements ControllerProviderInterface $sql = "DELETE FROM thit WHERE name = :name"; $stmt = $connbas->prepare($sql); - foreach ($request->get("f2unlk", array()) as $f2unlk) { - $stmt->execute(array(':name' => $f2unlk)); + foreach ($request->get("f2unlk", []) as $f2unlk) { + $stmt->execute([':name' => $f2unlk]); } $stmt->closeCursor(); @@ -1018,13 +1018,13 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/link-field-step3.html.twig', array( - 'field2del' => $request->get('f2unlk', array()), + return $app['twig']->render('thesaurus/link-field-step3.html.twig', [ + 'field2del' => $request->get('f2unlk', []), 'candidates2del' => $candidates2del, - 'branch2del' => $request->get('fbranch', array()), + 'branch2del' => $request->get('fbranch', []), 'ctchanged' => $ctchanged, 'reindexed' => $request->get('reindex'), - )); + ]); } private function fixThesaurus($app, \DOMDocument $domct, \DOMDocument $domth, \connection_interface $connbas) @@ -1057,7 +1057,7 @@ class Thesaurus implements ControllerProviderInterface $updated = false; $validThesaurus = true; - $ctlist = array(); + $ctlist = []; $name = \phrasea::sbas_labels($request->get('bid'), $app); try { @@ -1092,10 +1092,10 @@ class Thesaurus implements ControllerProviderInterface for ($ct = $domct->documentElement->firstChild; $ct; $ct = $ct->nextSibling) { if ($ct->nodeName == "te") { - $ctlist[] = array( + $ctlist[] = [ 'id' => $ct->getAttribute("id"), 'field' => $ct->getAttribute("field") - ); + ]; } } } else { @@ -1105,29 +1105,29 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/load-thesaurus.html.twig', array( + return $app['twig']->render('thesaurus/load-thesaurus.html.twig', [ 'bid' => $request->get('bid'), 'name' => $name, 'cterms' => $ctlist, 'valid_thesaurus' => $validThesaurus, 'updated' => $updated - )); + ]); } public function newSynonymDialog(Application $app, Request $request) { - $languages = array(); + $languages = []; foreach ($app['locales.available'] as $lng_code => $lng) { $lng_code = explode('_', $lng_code); $languages[$lng_code[0]] = $lng; } - return $app['twig']->render('thesaurus/new-synonym-dialog.html.twig', array( + return $app['twig']->render('thesaurus/new-synonym-dialog.html.twig', [ 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), 'languages' => $languages, - )); + ]); } @@ -1152,17 +1152,17 @@ class Thesaurus implements ControllerProviderInterface $nb_candidates_bad ++; } } - $candidates_list = array(); + $candidates_list = []; for ($i = 0; $i < $candidates->length; $i ++) { if ($candidates->item($i)->getAttribute("sourceok") == "1") { - $candidates_list = array( + $candidates_list = [ 'id' => $candidates->item($i)->getAttribute("id"), 'field' => $candidates->item($i)->getAttribute("field"), - ); + ]; } } - return $app['twig']->render('thesaurus/new-term.html.twig', array( + return $app['twig']->render('thesaurus/new-term.html.twig', [ 'typ' => $request->get('typ'), 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), @@ -1174,7 +1174,7 @@ class Thesaurus implements ControllerProviderInterface 'context' => $context, 'nb_candidates_ok' => $nb_candidates_ok, 'nb_candidates_bad' => $nb_candidates_bad, - )); + ]); } public function properties(Application $app, Request $request) @@ -1183,16 +1183,16 @@ class Thesaurus implements ControllerProviderInterface $fullpath = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue; $hits = $dom->getElementsByTagName("allhits")->item(0)->firstChild->nodeValue; - $languages = $synonyms = array(); + $languages = $synonyms = []; $sy_list = $dom->getElementsByTagName("sy_list")->item(0); for ($n = $sy_list->firstChild; $n; $n = $n->nextSibling) { - $synonyms[] = array( + $synonyms[] = [ 'id' => $n->getAttribute("id"), 'lng' => $n->getAttribute("lng"), 't' => $n->getAttribute("t"), 'hits' => $n->getAttribute("hits"), - ); + ]; } foreach ($app['locales.available'] as $code => $language) { @@ -1200,7 +1200,7 @@ class Thesaurus implements ControllerProviderInterface $languages[$lng_code[0]] = $language; } - return $app['twig']->render('thesaurus/properties.html.twig', array( + return $app['twig']->render('thesaurus/properties.html.twig', [ 'typ' => $request->get('typ'), 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), @@ -1210,7 +1210,7 @@ class Thesaurus implements ControllerProviderInterface 'fullpath' => $fullpath, 'hits' => $hits, 'synonyms' => $synonyms, - )); + ]); } public function search(Application $app, Request $request) @@ -1220,21 +1220,21 @@ class Thesaurus implements ControllerProviderInterface public function thesaurus(Application $app, Request $request) { - $flags = $jsFlags = array(); + $flags = $jsFlags = []; foreach ($app['locales.available'] as $code => $language) { $lng_code = explode('_', $code); $flags[$lng_code[0]] = $language; - $jsFlags[$lng_code[0]] = array('w' => 18, 'h' => 13); + $jsFlags[$lng_code[0]] = ['w' => 18, 'h' => 13]; } $jsFlags = json_encode($jsFlags); - return $app['twig']->render('thesaurus/thesaurus.html.twig', array( + return $app['twig']->render('thesaurus/thesaurus.html.twig', [ 'piv' => $request->get('piv'), 'bid' => $request->get('bid'), 'flags' => $flags, 'jsFlags' => $jsFlags, - )); + ]); } @@ -1245,11 +1245,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "piv" => $request->get('piv'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1279,7 +1279,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function acceptBranch(Application $app, $sbas_id, \DOMElement $node) @@ -1295,10 +1295,10 @@ class Thesaurus implements ControllerProviderInterface try { $connbas = \connection::getPDOConnection($app, $sbas_id); $stmt = $connbas->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':thit_new' => $thit_newid, 'thit_old' => $thit_oldid - )); + ]); $stmt->closeCursor(); } catch (\Exception $e) { @@ -1318,13 +1318,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'cid' => $request->get('cid'), 'pid' => $request->get('pid'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1368,7 +1368,7 @@ class Thesaurus implements ControllerProviderInterface $oldid = $ct->getAttribute("id"); $te = $domth->importNode($ct, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { $pid = "T" . $nid; @@ -1388,7 +1388,7 @@ class Thesaurus implements ControllerProviderInterface WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); if ($icid == 0) { // on update la destination une seule fois @@ -1417,7 +1417,7 @@ class Thesaurus implements ControllerProviderInterface $oldid = $ct2->getAttribute("id"); $te = $domth->importNode($ct2, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { $pid = "T" . $nid; } else { @@ -1436,7 +1436,7 @@ class Thesaurus implements ControllerProviderInterface WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); $thchanged = true; @@ -1468,7 +1468,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function renumerate($node, $id, &$chgids, $depth = 0) @@ -1491,13 +1491,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'newlng' => $request->get('cid'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -1542,7 +1542,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function changeSynonymPositionXml(Application $app, Request $request) @@ -1552,13 +1552,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'dir' => $request->get('dir'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -1609,7 +1609,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function removeNoHitXml(Application $app, Request $request) @@ -1619,13 +1619,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'id' => $request->get('id'), 'pid' => $request->get('pid'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -1665,7 +1665,7 @@ class Thesaurus implements ControllerProviderInterface } if (($znode = $xpath->query($q)->item(0))) { - $nodestodel = array(); + $nodestodel = []; $root->setAttribute('n_nohits', (string) $this->doDeleteNohits($znode, $s_thits, $nodestodel)); foreach ($nodestodel as $n) { $n->parentNode->removeChild($n); @@ -1680,7 +1680,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function doDeleteNohits($node, &$s_thits, &$nodestodel) @@ -1713,12 +1713,12 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1800,10 +1800,10 @@ class Thesaurus implements ControllerProviderInterface $sql = "UPDATE thit SET value = :new_id WHERE value = :old_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':new_id' => $sql_newid, ':old_id' => $sql_oldid)); + $stmt->execute([':new_id' => $sql_newid, ':old_id' => $sql_oldid]); $stmt->closeCursor(); - $sql = array(); + $sql = []; $databox->saveCterms($domct); if ($request->get('typ') == "CT") { @@ -1837,7 +1837,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function removeSpecificTermXml(Application $app, Request $request) @@ -1847,11 +1847,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1872,7 +1872,7 @@ class Thesaurus implements ControllerProviderInterface $thnode = $xpathth->query($q)->item(0); if ($thnode) { - $chgids = array(); + $chgids = []; $pid = $thnode->parentNode->getAttribute("id"); if ($pid === "") { $pid = "T"; @@ -1917,7 +1917,7 @@ class Thesaurus implements ControllerProviderInterface WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); $thnode->parentNode->removeChild($thnode); @@ -1934,7 +1934,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function getHtmlBranchXml(Application $app, Request $request) @@ -1944,11 +1944,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement("html")); @@ -1985,7 +1985,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function formatHTMLBranch($srcnode, $dstdom, $dstnode, $depth) @@ -2027,7 +2027,7 @@ class Thesaurus implements ControllerProviderInterface $allsy = "THESAURUS"; } - return array("allsy" => $allsy, "nts" => $nts); + return ["allsy" => $allsy, "nts" => $nts]; } public function getSynonymXml(Application $app, Request $request) @@ -2037,11 +2037,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -2083,7 +2083,7 @@ class Thesaurus implements ControllerProviderInterface $sy = $root->appendchild($ret->createElement("sy")); $sy->setAttribute("t", $t); - foreach (array("v", "w", "k", "lng", "id") as $a) { + foreach (["v", "w", "k", "lng", "id"] as $a) { if ($nodes->item(0)->hasAttribute($a)) { $sy->setAttribute($a, $nodes->item(0)->getAttribute($a)); } @@ -2134,7 +2134,7 @@ class Thesaurus implements ControllerProviderInterface $sql = "SELECT COUNT(DISTINCT(record_id)) AS hits FROM thit WHERE value = :id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $id)); + $stmt->execute([':id' => $id]); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2149,7 +2149,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function getTermXml(Application $app, Request $request) @@ -2159,7 +2159,7 @@ class Thesaurus implements ControllerProviderInterface $request->get('piv'), $request->get('sortsy'), $request->get('sel'), $request->get('nots'), $request->get('acf'))->saveXML(), 200, - array('Content-Type' => 'text/xml') + ['Content-Type' => 'text/xml'] ); } @@ -2170,7 +2170,7 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $bid, "id" => $id, "typ" => $typ, @@ -2179,7 +2179,7 @@ class Thesaurus implements ControllerProviderInterface "sel" => $sel, "nots" => $nots, "acf" => $acf, - ), true))); + ], true))); $cfield = $root->appendChild($ret->createElement("cfield")); $ts_list = $root->appendChild($ret->createElement("ts_list")); @@ -2232,7 +2232,7 @@ class Thesaurus implements ControllerProviderInterface $root->setAttribute('found', '' . $nodes->length); if ($nodes->length > 0) { $nts = 0; - $tts = array(); + $tts = []; // on dresse la liste des termes specifiques avec comme cle le synonyme // dans la langue pivot for ($n = $nodes->item(0)->firstChild; $n; $n = $n->nextSibling) { @@ -2276,17 +2276,17 @@ class Thesaurus implements ControllerProviderInterface break; } } - $tts[$realksy . "_" . $uniq] = array( + $tts[$realksy . "_" . $uniq] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length - ); + ]; } else { - $tts[] = array( + $tts[] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length - ); + ]; } } } elseif ($n->nodeName == "sy") { @@ -2297,7 +2297,7 @@ class Thesaurus implements ControllerProviderInterface FROM thit WHERE value = :id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $value_id)); + $stmt->execute([':id' => $value_id]); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2395,7 +2395,7 @@ class Thesaurus implements ControllerProviderInterface FROM thit WHERE value = :id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $value_id)); + $stmt->execute([':id' => $value_id]); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2411,7 +2411,7 @@ class Thesaurus implements ControllerProviderInterface FROM thit WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $value_id . '%')); + $stmt->execute([':like' => $value_id . '%']); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2438,12 +2438,12 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2479,7 +2479,7 @@ class Thesaurus implements ControllerProviderInterface $sql = "DELETE FROM thit WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $xml_oldid . '%')); + $stmt->execute([':like' => $xml_oldid . '%']); $stmt->closeCursor(); if ($request->get('typ') == "CT") { @@ -2511,7 +2511,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function newSynonymXml(Application $app, Request $request) @@ -2521,14 +2521,14 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "pid" => $request->get('pid'), "piv" => $request->get('piv'), "sylng" => $request->get('sylng'), "t" => $request->get('t'), "k" => $request->get('k'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2598,7 +2598,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function splitTermAndContext($word) @@ -2612,7 +2612,7 @@ class Thesaurus implements ControllerProviderInterface } } - return array($term, $context); + return [$term, $context]; } public function newSpecificTermXml(Application $app, Request $request) @@ -2622,14 +2622,14 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "pid" => $request->get('pid'), "t" => $request->get('t'), "k" => $request->get('k'), "sylng" => $request->get('sylng'), "reindex" => $request->get('reindex'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2709,7 +2709,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function openBranchesXml(Application $app, Request $request) @@ -2719,13 +2719,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "typ" => $request->get('typ'), "t" => $request->get('t'), "method" => $request->get('method'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement("html")); @@ -2795,7 +2795,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function getBranchHTML($type, $srcnode, $dstdom, $dstnode, $depth) @@ -2843,7 +2843,7 @@ class Thesaurus implements ControllerProviderInterface } } - return array("allsy" => $allsy, "nts" => $nts); + return ["allsy" => $allsy, "nts" => $nts]; } public function RejectXml(Application $app, Request $request) @@ -2853,11 +2853,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2890,7 +2890,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function doRejectBranch(\connection_pdo $connbas, \DOMElement $node) @@ -2902,7 +2902,7 @@ class Thesaurus implements ControllerProviderInterface $thit_newid = str_replace(".", "d", $newid) . "d"; $sql = "UPDATE thit SET value = :new_value WHERE value = :old_value"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':old_value' => $thit_oldid, ':new_value' => $thit_newid)); + $stmt->execute([':old_value' => $thit_oldid, ':new_value' => $thit_newid]); $stmt->closeCursor(); } for ($n = $node->firstChild; $n; $n = $n->nextSibling) { @@ -2920,7 +2920,7 @@ class Thesaurus implements ControllerProviderInterface $ret = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $request->get('t'), $request->get('k'), $request->get('piv')); - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function doSearchCandidate(Application $app, $bid, $pid, $t, $k, $piv) @@ -2930,13 +2930,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $bid, "pid" => $pid, "t" => $t, "k" => $k, "piv" => $piv, - ), true))); + ], true))); $ctlist = $root->appendChild($ret->createElement("candidates_list")); @@ -2952,7 +2952,7 @@ class Thesaurus implements ControllerProviderInterface $xpathct = new \DOMXPath($domct); // on cherche les champs d'oe peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme - $fields = array(); + $fields = []; $xpathstruct = new \DOMXPath($domstruct); $nodes = $xpathstruct->query("/record/description/*[@tbranch]"); for ($i = 0; $i < $nodes->length; $i ++) { @@ -2964,12 +2964,12 @@ class Thesaurus implements ControllerProviderInterface $q = "(" . $tbranch . ")/descendant-or-self::te[not(@id)]"; } - $fields[$fieldname] = array( + $fields[$fieldname] = [ "name" => $fieldname, "tbranch" => $tbranch, "cid" => null, "sourceok" => false - ); + ]; if (! $tbranch) { continue; @@ -2987,12 +2987,12 @@ class Thesaurus implements ControllerProviderInterface } } // on considere que la source 'deleted' est toujours valide - $fields["[deleted]"] = array( + $fields["[deleted]"] = [ "name" => _('thesaurus:: corbeille'), "tbranch" => null, "cid" => null, "sourceok" => true - ); + ]; if (count($fields) > 0) { $q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'"; @@ -3045,13 +3045,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "pid" => $request->get('pid'), 'typ' => $request->get('typ'), 'id' => $request->get('id'), "piv" => $request->get('piv'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -3097,7 +3097,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function countNohits($node, &$s_thits) diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php index 0b03012c7e..bcfd31a7b6 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php @@ -56,8 +56,8 @@ class Xmlhttp implements ControllerProviderInterface public function AcceptCandidatesJson(Application $app, Request $request) { - $ret = array('refresh' => array()); - $refresh = array(); + $ret = ['refresh' => []]; + $refresh = []; $sbas_id = $request->get('sbid'); @@ -107,7 +107,7 @@ class Xmlhttp implements ControllerProviderInterface $oldid = $ct->getAttribute("id"); $te = $domth->importNode($ct, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { $pid = "T" . $nid; } else { @@ -133,24 +133,24 @@ class Xmlhttp implements ControllerProviderInterface printf("soldid=%s ; snewid=%s
\nsql=%s
\n", $soldid, $snewid, $sql); } else { $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); } $refreshid = $parentnode->getAttribute('id'); - $refresh['T' . $refreshid] = array( + $refresh['T' . $refreshid] = [ 'type' => 'T', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $thchanged = true; $refreshid = $ct->parentNode->getAttribute("id"); - $refresh['C' . $refreshid] = array( + $refresh['C' . $refreshid] = [ 'type' => 'C', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $ct->parentNode->removeChild($ct); @@ -166,7 +166,7 @@ class Xmlhttp implements ControllerProviderInterface $oldid = $ct2->getAttribute("id"); $te = $domth->importNode($ct2, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { // racine $pid = "T" . $nid; @@ -193,7 +193,7 @@ class Xmlhttp implements ControllerProviderInterface printf("soldid=%s ; snewid=%s
\nsql=%s
\n", $soldid, $snewid, $sql); } else { $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); } @@ -201,18 +201,18 @@ class Xmlhttp implements ControllerProviderInterface } $refreshid = $parentnode->parentNode->getAttribute("id"); - $refresh['T' . $refreshid] = array( + $refresh['T' . $refreshid] = [ 'type' => 'T', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $refreshid = $ct->parentNode->getAttribute("id"); - $refresh['C' . $refreshid] = array( + $refresh['C' . $refreshid] = [ 'type' => 'C', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $ct->parentNode->removeChild($ct); $ctchanged = true; @@ -255,7 +255,7 @@ class Xmlhttp implements ControllerProviderInterface public function CheckCandidateTargetJson(Application $app, Request $request) { - $json = array(); + $json = []; if (null === $sbas_id = $request->get("sbid")) { return $app->json($json); @@ -362,14 +362,14 @@ class Xmlhttp implements ControllerProviderInterface { $usr_id = $app['authentication']->getUser()->get_id(); - $ret = array('parm' => array( + $ret = ['parm' => [ 'act' => $request->get('act'), 'sbas' => $request->get('sbas'), 'presetid' => $request->get('presetid'), 'title' => $request->get('title'), 'f' => $request->get('f'), 'debug' => $request->get('debug'), - )); + ]]; switch ($request->get('act')) { case 'DELETE': @@ -377,10 +377,10 @@ class Xmlhttp implements ControllerProviderInterface WHERE edit_preset_id = :editpresetid AND usr_id = :usr_id'; - $params = array( + $params = [ ':editpresetid' => $request->get('presetid'), ':usr_id' => $usr_id - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -402,12 +402,12 @@ class Xmlhttp implements ControllerProviderInterface VALUES (NOW(), :sbas_id, :usr_id, :title, :presets)'; - $params = array( + $params = [ ':sbas_id' => $request->get('sbas'), ':usr_id' => $usr_id, ':title' => $request->get('title'), ':presets' => $dom->saveXML(), - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -424,15 +424,15 @@ class Xmlhttp implements ControllerProviderInterface WHERE edit_preset_id = :edit_preset_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':edit_preset_id' => $request->get('presetid'))); + $stmt->execute([':edit_preset_id' => $request->get('presetid')]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $fields = array(); + $fields = []; if ($row && ($sx = simplexml_load_string($row['xml']))) { foreach ($sx->fields->children() as $fn => $fv) { if (!array_key_exists($fn, $fields)) { - $fields[$fn] = array(); + $fields[$fn] = []; } $fields[$fn][] = trim($fv); } @@ -456,10 +456,10 @@ class Xmlhttp implements ControllerProviderInterface ORDER BY creation_date ASC'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':sbas_id' => $sbas_id, ':usr_id' => $usr_id, - )); + ]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -467,7 +467,7 @@ class Xmlhttp implements ControllerProviderInterface if (!($sx = simplexml_load_string($row['xml']))) { continue; } - $t_desc = array(); + $t_desc = []; foreach ($sx->fields->children() as $fn => $fv) { if (!array_key_exists($fn, $t_desc)) { $t_desc[$fn] = trim($fv); @@ -477,7 +477,7 @@ class Xmlhttp implements ControllerProviderInterface } $desc = ''; foreach ($t_desc as $fn => $fv) { - $desc .= '

' . $fn . ': ' . str_replace(array('&', '<', '>'), array('&', '<', '>'), $fv) . '

' . "\n"; + $desc .= '

' . $fn . ': ' . str_replace(['&', '<', '>'], ['&', '<', '>'], $fv) . '

' . "\n"; } ob_start(); @@ -505,10 +505,10 @@ class Xmlhttp implements ControllerProviderInterface $ret->standalone = true; $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), - ), true))); + ], true))); if (null !== $request->get('bid')) { @@ -527,7 +527,7 @@ class Xmlhttp implements ControllerProviderInterface } } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function GetTermHtml(Application $app, Request $request) @@ -560,14 +560,14 @@ class Xmlhttp implements ControllerProviderInterface $nodes = $xpath->query($q); if ($nodes->length > 0) { $nts = 0; - $tts = array(); + $tts = []; // on dresse la liste des termes specifiques avec comme cle le synonyme // dans la langue pivot for ($n = $nodes->item(0)->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "te") { $nts++; $allsy = ""; - $tsy = array(); + $tsy = []; $firstksy = null; $ksy = $realksy = null; // on liste les sy pour fabriquer la cle @@ -587,16 +587,16 @@ class Xmlhttp implements ControllerProviderInterface $realksy = $ksy; $allsy = $t . ($allsy ? " ; " : "") . $allsy; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } else { $allsy .= ( $allsy ? " ; " : "") . $t; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } } } @@ -609,19 +609,19 @@ class Xmlhttp implements ControllerProviderInterface break; } } - $tts[$realksy . "_" . $uniq] = array( + $tts[$realksy . "_" . $uniq] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } else { - $tts[] = array( + $tts[] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } } elseif ($n->nodeName == "sy") { @@ -671,12 +671,12 @@ class Xmlhttp implements ControllerProviderInterface $ret->standalone = true; $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "sortsy" => $request->get('sortsy'), "debug" => $request->get('debug'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement("html")); @@ -705,14 +705,14 @@ class Xmlhttp implements ControllerProviderInterface $nodes = $xpath->query($q); if ($nodes->length > 0) { $nts = 0; - $tts = array(); + $tts = []; // on dresse la liste des termes specifiques avec comme cle le synonyme // dans la langue pivot for ($n = $nodes->item(0)->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "te") { $nts++; $allsy = ""; - $tsy = array(); + $tsy = []; $firstksy = null; $ksy = $realksy = null; // on liste les sy pour fabriquer la cle @@ -733,16 +733,16 @@ class Xmlhttp implements ControllerProviderInterface $realksy = $ksy; $allsy = $t . ($allsy ? " ; " : "") . $allsy; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } else { $allsy .= ( $allsy ? " ; " : "") . $t; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } } } @@ -755,19 +755,19 @@ class Xmlhttp implements ControllerProviderInterface break; } } - $tts[$realksy . "_" . $uniq] = array( + $tts[$realksy . "_" . $uniq] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } else { - $tts[] = array( + $tts[] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } } elseif ($n->nodeName == "sy") { @@ -810,7 +810,7 @@ class Xmlhttp implements ControllerProviderInterface $html->appendChild($ret->createTextNode($zhtml)); } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function OpenBranchJson(Application $app, Request $request) @@ -833,7 +833,7 @@ class Xmlhttp implements ControllerProviderInterface $connbas = \connection::getPDOConnection($app, $sbid); $dbname = \phrasea::sbas_labels($sbid, $app); - $t_nrec = array(); + $t_nrec = []; $lthid = strlen($thid); // count occurences @@ -844,7 +844,7 @@ class Xmlhttp implements ControllerProviderInterface FROM thit WHERE value LIKE :like '; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -860,7 +860,7 @@ class Xmlhttp implements ControllerProviderInterface GROUP BY k'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -877,7 +877,7 @@ class Xmlhttp implements ControllerProviderInterface GROUP BY k'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -893,7 +893,7 @@ class Xmlhttp implements ControllerProviderInterface GROUP BY k'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -948,7 +948,7 @@ class Xmlhttp implements ControllerProviderInterface // on dresse la liste des termes specifiques avec comme cle le synonyme dans la langue pivot $nts = 0; - $tts = array(); + $tts = []; for ($n = $node0->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == 'te' && !$n->getAttribute('delbranch') && substr($n->getAttribute('id'), 0, 1) != 'R') { $nts++; @@ -963,11 +963,11 @@ class Xmlhttp implements ControllerProviderInterface break; } } - $tts[$key0 . '_' . $uniq] = array( + $tts[$key0 . '_' . $uniq] = [ 'label' => $label, 'nts' => $nts0, 'n' => $n - ); + ]; } } @@ -1027,7 +1027,7 @@ class Xmlhttp implements ControllerProviderInterface } - return $app->json(array('parm' => array( + return $app->json(['parm' => [ 'sbid' => $request->get('sbid'), 'type' => $request->get('type'), 'id' => $request->get('id'), @@ -1036,7 +1036,7 @@ class Xmlhttp implements ControllerProviderInterface 'debug' => $request->get('debug'), 'root' => $request->get('root'), 'last' => $request->get('last'), - ), 'html' => $html)); + ], 'html' => $html]); } private function buildBranchLabel($dbname, $language, $n, &$key0, &$nts0) @@ -1165,7 +1165,7 @@ class Xmlhttp implements ControllerProviderInterface } } - return array($term, $context); + return [$term, $context]; } private function getBranchesHTML($bid, $srcnode, &$html, $depth) @@ -1230,12 +1230,12 @@ class Xmlhttp implements ControllerProviderInterface $ret->standalone = true; $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement('result')); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 't' => $request->get('t'), 'mod' => $request->get('mod'), 'debug' => $request->get('debug'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement('html')); @@ -1288,7 +1288,7 @@ class Xmlhttp implements ControllerProviderInterface $html->appendChild($ret->createTextNode($zhtml)); } - return new Response($zhtml, 200, array('Content-Type' => 'text/xml')); + return new Response($zhtml, 200, ['Content-Type' => 'text/xml']); } private function getBrancheXML($bid, $srcnode, &$html, $depth) @@ -1344,28 +1344,28 @@ class Xmlhttp implements ControllerProviderInterface public function ReplaceCandidateJson(Application $app, Request $request) { - $tsbas = array(); + $tsbas = []; - $ret = array( - 'ctermsDeleted' => array(), + $ret = [ + 'ctermsDeleted' => [], 'maxRecsUpdatable' => self::SEARCH_REPLACE_MAXREC, 'nRecsToUpdate' => 0, 'nRecsUpdated' => 0, 'msg' => '' - ); + ]; foreach ($request->get('id') as $id) { $id = explode('.', $id); $sbas_id = array_shift($id); if (!array_key_exists('b' . $sbas_id, $tsbas)) { - $tsbas['b' . $sbas_id] = array( + $tsbas['b' . $sbas_id] = [ 'sbas_id' => (int) $sbas_id, - 'tids' => array(), + 'tids' => [], 'domct' => null, - 'tvals' => array(), + 'tvals' => [], 'lid' => '', - 'trids' => array() - ); + 'trids' => [] + ]; } $tsbas['b' . $sbas_id]['tids'][] = implode('.', $id); } @@ -1402,7 +1402,7 @@ class Xmlhttp implements ControllerProviderInterface $field = $sy->parentNode->parentNode->getAttribute('field'); if (!array_key_exists($field, $tsbas[$ksbas]['tvals'])) { - $tsbas[$ksbas]['tvals'][$field] = array(); + $tsbas[$ksbas]['tvals'][$field] = []; } $tsbas[$ksbas]['tvals'][$field][] = $sy; } @@ -1443,8 +1443,8 @@ class Xmlhttp implements ControllerProviderInterface try { $record = $databox->get_record($rid); - $metadatask = array(); // datas to keep - $metadatasd = array(); // datas to delete + $metadatask = []; // datas to keep + $metadatasd = []; // datas to delete /* @var $field caption_field */ foreach ($record->get_caption()->get_fields(null, true) as $field) { @@ -1453,11 +1453,11 @@ class Xmlhttp implements ControllerProviderInterface $fname = $field->get_name(); if (!array_key_exists($fname, $sbas['tvals'])) { foreach ($field->get_values() as $v) { - $metadatask[] = array( + $metadatask[] = [ 'meta_struct_id' => $meta_struct_id, 'meta_id' => $v->getId(), 'value' => $v->getValue() - ); + ]; } } else { foreach ($field->get_values() as $v) { @@ -1470,17 +1470,17 @@ class Xmlhttp implements ControllerProviderInterface } if ($keep) { - $metadatask[] = array( + $metadatask[] = [ 'meta_struct_id' => $meta_struct_id, 'meta_id' => $v->getId(), 'value' => $v->getValue() - ); + ]; } else { - $metadatasd[] = array( + $metadatasd[] = [ 'meta_struct_id' => $meta_struct_id, 'meta_id' => $v->getId(), 'value' => $request->get('t') ? $request->get('t') : '' - ); + ]; } } } @@ -1590,13 +1590,13 @@ class Xmlhttp implements ControllerProviderInterface } - return $app->json(array('parm' => array( + return $app->json(['parm' => [ 'sbid' => $request->get('sbid'), 't' => $request->get('t'), 'field' => $request->get('field'), 'lng' => $request->get('lng'), 'debug' => $request->get('debug'), - ), 'html' => $html)); + ], 'html' => $html]); } private function buildTermLabel($language, $n, &$key0, &$nts0) @@ -1648,7 +1648,7 @@ class Xmlhttp implements ControllerProviderInterface // let's work on each 'te' (=ts) subnode $nts = 0; $ntsopened = 0; - $tts = array(); + $tts = []; for ($n = $srcnode->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == 'te') { if ($n->getAttribute('open')) { @@ -1661,7 +1661,7 @@ class Xmlhttp implements ControllerProviderInterface if (!isset($tts[$key0 . '_' . $uniq])) break; } - $tts[$key0 . '_' . $uniq] = array('label' => $label, 'nts' => $nts0, 'n' => $n); + $tts[$key0 . '_' . $uniq] = ['label' => $label, 'nts' => $nts0, 'n' => $n]; $ntsopened++; } $nts++; diff --git a/lib/Alchemy/Phrasea/Controller/User/Notifications.php b/lib/Alchemy/Phrasea/Controller/User/Notifications.php index 77081a2238..ad9e441fa8 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Notifications.php +++ b/lib/Alchemy/Phrasea/Controller/User/Notifications.php @@ -60,9 +60,9 @@ class Notifications implements ControllerProviderInterface $app['authentication']->getUser()->get_id() ); - return $app->json(array('success' => true, 'message' => '')); + return $app->json(['success' => true, 'message' => '']); } catch (\Exception $e) { - return $app->json(array('success' => false, 'message' => $e->getMessage())); + return $app->json(['success' => false, 'message' => $e->getMessage()]); } } diff --git a/lib/Alchemy/Phrasea/Controller/User/Preferences.php b/lib/Alchemy/Phrasea/Controller/User/Preferences.php index 318cb2bcf5..fa2b4f86b2 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Preferences.php +++ b/lib/Alchemy/Phrasea/Controller/User/Preferences.php @@ -65,7 +65,7 @@ class Preferences implements ControllerProviderInterface $msg = _('Preference saved !'); } - return new JsonResponse(array('success' => $success, 'message' => $msg)); + return new JsonResponse(['success' => $success, 'message' => $msg]); } /** @@ -92,6 +92,6 @@ class Preferences implements ControllerProviderInterface $msg = _('Preference saved !'); } - return new JsonResponse(array('success' => $success, 'message' => $msg)); + return new JsonResponse(['success' => $success, 'message' => $msg]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php b/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php index 7296201b8e..63d0bcd42b 100644 --- a/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php +++ b/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php @@ -42,7 +42,7 @@ class ConnectionTest implements ControllerProviderInterface $connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false; try { - $conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), false); + $conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, [], false); $connection_ok = true; } catch (\Exception $e) { @@ -50,7 +50,7 @@ class ConnectionTest implements ControllerProviderInterface if ($dbname && $connection_ok === true) { try { - $conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), false); + $conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, [], false); $db_ok = true; $sql = "SHOW TABLE STATUS"; @@ -75,13 +75,13 @@ class ConnectionTest implements ControllerProviderInterface } } - $datas = array( + $datas = [ 'connection' => $connection_ok , 'database' => $db_ok , 'is_empty' => $empty , 'is_appbox' => $is_appbox , 'is_databox' => $is_databox - ); + ]; return $app->json($datas); }); diff --git a/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php b/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php index 469772431c..410d063e30 100644 --- a/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php +++ b/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php @@ -32,18 +32,18 @@ class PathFileTest implements ControllerProviderInterface * @todo : check this as it would lead to a security issue */ $controllers->get('/path/', function (Application $app, Request $request) { - return $app->json(array( + return $app->json([ 'exists' => file_exists($request->query->get('path')) , 'file' => is_file($request->query->get('path')) , 'dir' => is_dir($request->query->get('path')) , 'readable' => is_readable($request->query->get('path')) , 'writeable' => is_writable($request->query->get('path')) , 'executable' => is_executable($request->query->get('path')) - )); + ]); }); $controllers->get('/url/', function (Application $app, Request $request) { - return $app->json(array('code' => \http_query::getHttpCodeFromUrl($request->query->get('url')))); + return $app->json(['code' => \http_query::getHttpCodeFromUrl($request->query->get('url'))]); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php index f2a41879f1..1bf4aee688 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php @@ -30,7 +30,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface }); $app['driver.binary-finder'] = $app->protect(function ($name, $configName) use ($app) { - $extraDirs = array(); + $extraDirs = []; if (is_dir($app['root.path'] . '/node_modules')) { $extraDirs[] = $app['root.path'] . '/node_modules/.bin'; @@ -54,7 +54,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find bower executable.'); } - return BowerDriver::create(array('bower.binaries' => $bowerBinary, 'timeout' => 300), $app['monolog']); + return BowerDriver::create(['bower.binaries' => $bowerBinary, 'timeout' => 300], $app['monolog']); }); $app['driver.recess'] = $app->share(function (Application $app) { @@ -64,7 +64,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find recess executable.'); } - return RecessDriver::create(array('recess.binaries' => $recessBinary), $app['monolog']); + return RecessDriver::create(['recess.binaries' => $recessBinary], $app['monolog']); }); $app['driver.composer'] = $app->share(function (Application $app) { @@ -74,7 +74,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find composer executable.'); } - return ComposerDriver::create(array('composer.binaries' => $composerBinary, 'timeout' => 300), $app['monolog']); + return ComposerDriver::create(['composer.binaries' => $composerBinary, 'timeout' => 300], $app['monolog']); }); $app['driver.uglifyjs'] = $app->share(function (Application $app) { @@ -84,7 +84,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find uglifyJs executable.'); } - return UglifyJsDriver::create(array('uglifyjs.binaries' => $uglifyJsBinary), $app['monolog']); + return UglifyJsDriver::create(['uglifyjs.binaries' => $uglifyJsBinary], $app['monolog']); }); $app['driver.grunt'] = $app->share(function (Application $app) { @@ -94,7 +94,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find grunt executable.'); } - return GruntDriver::create(array('grunt.binaries' => $gruntBinary), $app['monolog']); + return GruntDriver::create(['grunt.binaries' => $gruntBinary], $app['monolog']); }); } diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php index 5c2158e056..c5d0f2132b 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php @@ -21,21 +21,21 @@ class LessBuilderServiceProvider implements ServiceProviderInterface public function register(Application $app) { $app['phraseanet.less-assets'] = $app->share(function ($app) { - return array( + return [ $app['root.path'] . '/www/assets/bootstrap/img/glyphicons-halflings-white.png' => $app['root.path'] . '/www/skins/build/bootstrap/img/glyphicons-halflings-white.png', $app['root.path'] . '/www/assets/bootstrap/img/glyphicons-halflings.png' => $app['root.path'] . '/www/skins/build/bootstrap/img/glyphicons-halflings.png', - ); + ]; }); $app['phraseanet.less-mapping.base'] = $app->share(function ($app) { - return array(); + return []; }); $app['phraseanet.less-mapping.customizable'] = $app->share(function ($app) { - return array( + return [ $app['root.path'] . '/www/skins/login/less/login.less' => $app['root.path'] . '/www/assets/build/login.css', $app['root.path'] . '/www/skins/account/account.less' => $app['root.path'] . '/www/assets/build/account.css', - ); + ]; }); $app['phraseanet.less-mapping'] = $app->share(function ($app) { diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php index f0d656ca90..c85c11d036 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php @@ -71,9 +71,9 @@ class PluginServiceProvider implements ServiceProviderInterface }); $app['plugins.importer'] = $app->share(function (Application $app) { - return new Importer($app['plugins.import-strategy'], array( + return new Importer($app['plugins.import-strategy'], [ 'plugins.importer.folder-importer' => $app['plugins.importer.folder-importer'], - )); + ]); }); $app['plugins.importer.folder-importer'] = $app->share(function (Application $app) { diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php index c8b27ef3af..973e683b24 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php @@ -37,11 +37,11 @@ class TaskManagerServiceProvider implements ServiceProviderInterface $app['dispatcher'], $app['task-manager.logger'], $app['task-manager.task-list'], - array( + [ 'listener_protocol' => $options['protocol'], 'listener_host' => $options['host'], 'listener_port' => $options['port'], - ) + ] ); }); diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php b/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php index cf625fd8e2..9601fc2caa 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php @@ -162,10 +162,10 @@ class Configuration implements ConfigurationInterface public function delete() { $this->cache = null; - foreach (array( + foreach ([ $this->config, $this->compiled, - ) as $file) { + ] as $file) { $this->eraseFile($file); } } @@ -196,11 +196,11 @@ class Configuration implements ConfigurationInterface public function getTestConnectionParameters() { - return array( + return [ 'driver' => 'pdo_sqlite', 'path' => '/tmp/db.sqlite', 'charset' => 'UTF8', - ); + ]; } private function loadDefaultConfiguration() diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php index ecac06bd66..416aa292be 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php @@ -33,14 +33,14 @@ class ApiExceptionHandlerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::EXCEPTION => array('onSilexError', 0), - ); + return [ + KernelEvents::EXCEPTION => ['onSilexError', 0], + ]; } public function onSilexError(GetResponseForExceptionEvent $event) { - $headers = array(); + $headers = []; $e = $event->getException(); if ($e instanceof \API_V1_exception_methodnotallowed) { diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php index f0ea27a88e..b4a837ad29 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php @@ -29,9 +29,9 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::EXCEPTION => array('onSilexError', 20), - ); + return [ + KernelEvents::EXCEPTION => ['onSilexError', 20], + ]; } public function onSilexError(GetResponseForExceptionEvent $event) @@ -46,7 +46,7 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface $code = 500; $msg = _('Whoops, looks like something went wrong.'); - $headers = array(); + $headers = []; if ($e instanceof HttpExceptionInterface) { $headers = $e->getHeaders(); @@ -55,7 +55,7 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface } if (isset($headers['content-type']) && $headers['content-type'] == 'application/json') { - $msg = json_encode(array('msg' => $msg, 'code' => $code)); + $msg = json_encode(['msg' => $msg, 'code' => $code]); $event->setResponse(new Response($msg, $code, $headers)); } else { $event->setResponse($this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException())); diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php index b0ceeb3d09..77c6b8362d 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php @@ -35,9 +35,9 @@ class BridgeExceptionSubscriber implements EventSubscriberInterface $e = $event->getException(); $request = $event->getRequest(); - $params = array( + $params = [ 'account' => null, - 'elements' => array(), + 'elements' => [], 'message' => $e->getMessage(), 'error_message' => null, 'notice_message' => null, @@ -45,23 +45,23 @@ class BridgeExceptionSubscriber implements EventSubscriberInterface 'line' => $e->getLine(), 'r_method' => $request->getMethod(), 'r_action' => $request->getRequestUri(), - 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all()), - ); + 'r_parameters' => ($request->getMethod() == 'GET' ? [] : $request->request->all()), + ]; if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) { - $params = array_replace($params, array('account' => $this->app['bridge.account'])); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['account' => $this->app['bridge.account']]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, ['X-Status-Code' => 200]); } elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) { - $params = array_replace($params, array('account' => $this->app['bridge.account'])); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['account' => $this->app['bridge.account']]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, ['X-Status-Code' => 200]); } elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) { - $params = array_replace($params, array('account' => $this->app['bridge.account'])); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['account' => $this->app['bridge.account']]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, ['X-Status-Code' => 200]); } elseif ($e instanceof \Bridge_Exception_ApiDisabled) { - $params = array_replace($params, array('api' => $e->get_api())); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['api' => $e->get_api()]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, ['X-Status-Code' => 200]); } else { - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, array('X-Status-Code' => 200)); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, ['X-Status-Code' => 200]); } $response->headers->set('Phrasea-StatusCode', 200); @@ -74,6 +74,6 @@ class BridgeExceptionSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 20)); + return [KernelEvents::EXCEPTION => ['onSilexError', 20]]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php index b7b5f9a763..a8b3205ea2 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php @@ -32,10 +32,10 @@ class CookiesDisablerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('checkRoutePattern', 512), - KernelEvents::RESPONSE => array('removeCookies', -512), - ); + return [ + KernelEvents::REQUEST => ['checkRoutePattern', 512], + KernelEvents::RESPONSE => ['removeCookies', -512], + ]; } public function checkRoutePattern(GetResponseEvent $event) diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php index 23d24061ce..657c8d7db6 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php @@ -28,11 +28,11 @@ class DebuggerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('checkIp', 255), - ), - ); + return [ + KernelEvents::REQUEST => [ + ['checkIp', 255], + ], + ]; } public function checkIp(GetResponseEvent $event) @@ -46,12 +46,12 @@ class DebuggerSubscriber implements EventSubscriberInterface && isset($this->app['configuration']['debugger']['allowed-ips'])) { $allowedIps = $this->app['configuration']['debugger']['allowed-ips']; - $allowedIps = is_array($allowedIps) ? $allowedIps : array($allowedIps); + $allowedIps = is_array($allowedIps) ? $allowedIps : [$allowedIps]; } else { - $allowedIps = array(); + $allowedIps = []; } - $ips = array_merge(array('127.0.0.1', 'fe80::1', '::1'), $allowedIps); + $ips = array_merge(['127.0.0.1', 'fe80::1', '::1'], $allowedIps); if (!in_array($event->getRequest()->getClientIp(), $ips)) { throw new AccessDeniedHttpException('You are not allowed to access this file. Check index_dev.php for more information.'); diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php index f28c2662a9..6e58beb1a7 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php @@ -22,10 +22,10 @@ class FirewallSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', 0), - KernelEvents::EXCEPTION => array('onSilexError', 20), - ); + return [ + KernelEvents::RESPONSE => ['onKernelResponse', 0], + KernelEvents::EXCEPTION => ['onSilexError', 20], + ]; } public function onKernelResponse(FilterResponseEvent $event) @@ -43,7 +43,7 @@ class FirewallSubscriber implements EventSubscriberInterface $headers = $e->getHeaders(); if (isset($headers['X-Phraseanet-Redirect'])) { - $event->setResponse(new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, array('X-Status-Code' => 302))); + $event->setResponse(new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, ['X-Status-Code' => 302])); } } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php index d21e902e69..da7774bed5 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php @@ -27,12 +27,12 @@ class JsonRequestSubscriber implements EventSubscriberInterface || 0 === strpos($request->getPathInfo(), '/admin/collection/') || 0 === strpos($request->getPathInfo(), '/admin/databox/')) && $request->getRequestFormat() == 'json') { - $datas = array( + $datas = [ 'success' => false, 'message' => $exception->getMessage(), - ); + ]; - $event->setResponse(new JsonResponse($datas, 200, array('X-Status-Code' => 200))); + $event->setResponse(new JsonResponse($datas, 200, ['X-Status-Code' => 200])); } } @@ -41,6 +41,6 @@ class JsonRequestSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 10)); + return [KernelEvents::EXCEPTION => ['onSilexError', 10]]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php index 74c4372ff0..ad11289532 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php @@ -25,8 +25,8 @@ class LogoutSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( + return [ PhraseaEvents::LOGOUT => 'onLogout', - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php index f5c17feebe..e28a4ec374 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php @@ -27,15 +27,15 @@ class MaintenanceSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('checkForMaintenance', 0), - ); + return [ + KernelEvents::REQUEST => ['checkForMaintenance', 0], + ]; } public function checkForMaintenance(GetResponseEvent $event) { if ($this->app['configuration']->isSetup() && $this->app['configuration']['main']['maintenance']) { - $this->app->abort(503, 'Service Temporarily Unavailable', array('Retry-After' => 3600)); + $this->app->abort(503, 'Service Temporarily Unavailable', ['Retry-After' => 3600]); } } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php index 0f0a675fcc..205a4fb3a8 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php @@ -27,9 +27,9 @@ class PersistentCookieSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('checkPersistentCookie', 128), - ); + return [ + KernelEvents::REQUEST => ['checkPersistentCookie', 128], + ]; } public function checkPersistentCookie(GetResponseEvent $event) diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php index 24973b0a73..b6ccd33eb5 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php @@ -46,6 +46,6 @@ class PhraseaExceptionHandlerSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 0)); + return [KernelEvents::EXCEPTION => ['onSilexError', 0]]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php index ef908ba83a..8ffa88edca 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php @@ -30,20 +30,20 @@ class PhraseaLocaleSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('addLocale', 255), + return [ + KernelEvents::REQUEST => [ + ['addLocale', 255], // symfony locale is set on 16 priority, let's override it - array('addLocale', 17), - array('addLocale', 15), - ), - KernelEvents::RESPONSE => array( - array('addLocaleCookie', 8), - ), - KernelEvents::FINISH_REQUEST => array( - array('unsetLocale', -255), - ) - ); + ['addLocale', 17], + ['addLocale', 15], + ], + KernelEvents::RESPONSE => [ + ['addLocaleCookie', 8], + ], + KernelEvents::FINISH_REQUEST => [ + ['unsetLocale', -255], + ] + ]; } public function unsetLocale() diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php index 8be4c78530..f9aa1516db 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php @@ -28,9 +28,9 @@ class TrustedProxySubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('setProxyConf', 0), - ); + return [ + KernelEvents::REQUEST => ['setProxyConf', 0], + ]; } public function setProxyConf(GetResponseEvent $event) @@ -39,7 +39,7 @@ class TrustedProxySubscriber implements EventSubscriberInterface return; } - $proxies = isset($this->configuration['trusted-proxies']) ? $this->configuration['trusted-proxies'] : array(); + $proxies = isset($this->configuration['trusted-proxies']) ? $this->configuration['trusted-proxies'] : []; Request::setTrustedProxies($proxies); } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php index 72199b06ab..cdddd7c97e 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php @@ -28,9 +28,9 @@ class XSendFileSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('applyHeaders', 0), - ); + return [ + KernelEvents::REQUEST => ['applyHeaders', 0], + ]; } public function applyHeaders(GetResponseEvent $event) diff --git a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php index 3d074bb047..0fc372fb1f 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php @@ -32,7 +32,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface $options = $app['configuration']['border-manager']; - $registeredCheckers = array(); + $registeredCheckers = []; if ($options['enabled']) { foreach ($options['checkers'] as $checker) { @@ -50,7 +50,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface continue; } - $options = array(); + $options = []; if (isset($checker['options']) && is_array($checker['options'])) { $options = $checker['options']; @@ -60,7 +60,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface $checkerObj = new $className($app, $options); if (isset($checker['databoxes'])) { - $databoxes = array(); + $databoxes = []; foreach ($checker['databoxes'] as $sbas_id) { try { $databoxes[] = $app['phraseanet.appbox']->get_databox($sbas_id); @@ -73,7 +73,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface } if (isset($checker['collections'])) { - $collections = array(); + $collections = []; foreach ($checker['collections'] as $base_id) { try { $collections[] = \collection::get_from_base_id($app, $base_id); diff --git a/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php index 19ad24b047..41c8611e4b 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php @@ -68,7 +68,7 @@ class LocaleServiceProvider implements ServiceProviderInterface }); $app['locales.mapping'] = $app->share(function (Application $app) { - $codes = array(); + $codes = []; foreach ($app['locales.available'] as $code => $language) { $data = explode('_', $code); $codes[$data[0]] = $code; @@ -78,7 +78,7 @@ class LocaleServiceProvider implements ServiceProviderInterface }); $app['locales.I18n.available'] = $app->share(function (Application $app) { - $locales = array(); + $locales = []; foreach ($app['locales.available'] as $code => $language) { $data = explode('_', $code); diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 3231c022c4..a7ca7478f0 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -63,7 +63,7 @@ class ORMServiceProvider implements ServiceProviderInterface $annotationDriver = new AnnotationDriver( $annotationReader, - array($app['root.path'].'/lib/Alchemy/Phrasea/Model/Entities') + [$app['root.path'].'/lib/Alchemy/Phrasea/Model/Entities'] ); $driverChain->addDriver($annotationDriver, 'Alchemy\Phrasea\Model\Entities'); @@ -136,13 +136,13 @@ class ORMServiceProvider implements ServiceProviderInterface $platform = $em->getConnection()->getDatabasePlatform(); - $types = array( + $types = [ 'blob' => 'Alchemy\Phrasea\Model\Types\Blob', 'enum' => 'Alchemy\Phrasea\Model\Types\Blob', 'longblob' => 'Alchemy\Phrasea\Model\Types\LongBlob', 'varbinary' => 'Alchemy\Phrasea\Model\Types\VarBinary', 'binary' => 'Alchemy\Phrasea\Model\Types\Binary', - ); + ]; foreach ($types as $type => $class) { if (!Type::hasType($type)) { diff --git a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php index 4f1deeee40..b838772e92 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php @@ -24,7 +24,7 @@ class PluginServiceProvider implements ServiceProviderInterface { $app['twig'] = $app->share( $app->extend('twig', function ($twig, Application $app) { - $function = new \Twig_SimpleFunction('plugin_asset', array('Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset')); + $function = new \Twig_SimpleFunction('plugin_asset', ['Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset']); $twig->addFunction($function); return $twig; diff --git a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php index f5a0408d48..f5115839c2 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php @@ -21,7 +21,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface public function register(Application $app) { $app['registration.fields'] = $app->share(function (Application $app) { - return isset($app['configuration']['registration-fields']) ? $app['configuration']['registration-fields'] : array(); + return isset($app['configuration']['registration-fields']) ? $app['configuration']['registration-fields'] : []; }); $app['registration.enabled'] = $app->share(function (Application $app) { @@ -41,97 +41,97 @@ class RegistrationServiceProvider implements ServiceProviderInterface }); $app['registration.optional-fields'] = $app->share(function (Application $app) { - return array( - 'login'=> array( + return [ + 'login'=> [ 'label' => _('admin::compte-utilisateur identifiant'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), new NewLogin($app), - ) - ), - 'gender' => array( + ] + ], + 'gender' => [ 'label' => _('admin::compte-utilisateur sexe'), 'type' => 'choice', 'multiple' => false, 'expanded' => false, - 'choices' => array( + 'choices' => [ '0' => _('admin::compte-utilisateur:sexe: mademoiselle'), '1' => _('admin::compte-utilisateur:sexe: madame'), '2' => _('admin::compte-utilisateur:sexe: monsieur'), - ) - ), - 'firstname' => array( + ] + ], + 'firstname' => [ 'label' => _('admin::compte-utilisateur prenom'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'lastname' => array( + ] + ], + 'lastname' => [ 'label' => _('admin::compte-utilisateur nom'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'address' => array( + ] + ], + 'address' => [ 'label' => _('admin::compte-utilisateur adresse'), 'type' => 'textarea', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'zipcode' => array( + ] + ], + 'zipcode' => [ 'label' => _('admin::compte-utilisateur code postal'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'geonameid' => array( + ] + ], + 'geonameid' => [ 'label' => _('admin::compte-utilisateur ville'), 'type' => new \Alchemy\Phrasea\Form\Type\GeonameType(), - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'position' => array( + ] + ], + 'position' => [ 'label' => _('admin::compte-utilisateur poste'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'company' => array( + ] + ], + 'company' => [ 'label' => _('admin::compte-utilisateur societe'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'job' => array( + ] + ], + 'job' => [ 'label' => _('admin::compte-utilisateur activite'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'tel' => array( + ] + ], + 'tel' => [ 'label' => _('admin::compte-utilisateur tel'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'fax' => array( + ] + ], + 'fax' => [ 'label' => _('admin::compte-utilisateur fax'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - ); + ] + ], + ]; }); } diff --git a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php index 2ee275b615..470b1b2974 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php @@ -39,15 +39,15 @@ class TasksServiceProvider implements ServiceProviderInterface if (isset($app['configuration']['task-manager']) && isset($app['configuration']['task-manager']['listener'])) { $listenerConf = $app['configuration']['task-manager']['listener']; } else { - $listenerConf = array(); + $listenerConf = []; } - return array_replace(array( + return array_replace([ 'protocol' => 'tcp', 'host' => '127.0.0.1', 'port' => 6660, 'linger' => 500, - ), $listenerConf); + ], $listenerConf); }); $app['task-manager.job-factory'] = $app->share(function (Application $app) { @@ -71,7 +71,7 @@ class TasksServiceProvider implements ServiceProviderInterface }); $app['task-manager.available-jobs'] = $app->share(function (Application $app) { - return array( + return [ new FtpJob(), new ArchiveJob(), new BridgeJob(), @@ -80,7 +80,7 @@ class TasksServiceProvider implements ServiceProviderInterface new RecordMoverJob(), new SubdefsJob(), new WriteMetadataJob(), - ); + ]; }); } diff --git a/lib/Alchemy/Phrasea/Feed/Aggregate.php b/lib/Alchemy/Phrasea/Feed/Aggregate.php index a7b2d062fb..31b6aca024 100644 --- a/lib/Alchemy/Phrasea/Feed/Aggregate.php +++ b/lib/Alchemy/Phrasea/Feed/Aggregate.php @@ -54,7 +54,7 @@ class Aggregate implements FeedInterface $this->updatedOn = new \DateTime(); $this->em = $em; - $tmp_feeds = array(); + $tmp_feeds = []; foreach ($feeds as $feed) { $tmp_feeds[$feed->getId()] = $feed; @@ -77,7 +77,7 @@ class Aggregate implements FeedInterface public static function createFromUser(Application $app, \User_Adapter $user) { $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($user)); - $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(array('usrId' => $user->get_id())); + $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(['usrId' => $user->get_id()]); return new static($app['EM'], $feeds, $token); } @@ -114,7 +114,7 @@ class Aggregate implements FeedInterface return null; } - $feedIds = array(); + $feedIds = []; foreach ($this->feeds as $feed) { $feedIds[] = $feed->getId(); } @@ -200,7 +200,7 @@ class Aggregate implements FeedInterface public function getCountTotalEntries() { if (count($this->feeds) > 0) { - $feedIds = array(); + $feedIds = []; foreach ($this->feeds as $feed) { $feedIds[] = $feed->getId(); } @@ -237,6 +237,6 @@ class Aggregate implements FeedInterface */ public static function getPublic(Application $app) { - return new static($app['EM'], $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC'))); + return new static($app['EM'], $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC'])); } } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php index bce5da422a..759cd44e02 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php @@ -36,7 +36,7 @@ class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterf public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null) { $content = $this->format($feed, $page, $user, $generator, $app); - $response = new Response($content, 200, array('Content-Type' => 'application/atom+xml')); + $response = new Response($content, 200, ['Content-Type' => 'application/atom+xml']); return $response; } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php index 0e9d91af41..6dc48f7607 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php @@ -37,7 +37,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null) { $content = $this->format($feed, $page, $user, $generator, $app); - $response = new Response($content, 200, array('Content-Type' => 'application/rss+xml')); + $response = new Response($content, 200, ['Content-Type' => 'application/rss+xml']); return $response; } @@ -188,7 +188,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn $medium = strtolower($content->getRecord($app)->get_type()); - if ( ! in_array($medium, array('image', 'audio', 'video'))) { + if ( ! in_array($medium, ['image', 'audio', 'video'])) { return $this; } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php b/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php index 0a77fe9b51..8a9379f595 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php @@ -53,7 +53,7 @@ abstract class FeedFormatterAbstract $medium = strtolower($content->getRecord($app)->get_type()); - if ( ! in_array($medium, array('image', 'audio', 'video'))) { + if ( ! in_array($medium, ['image', 'audio', 'video'])) { return $this; } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php index 754f5d3ce6..381f4ffe93 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php @@ -38,7 +38,7 @@ class RssFormatter extends FeedFormatterAbstract implements FeedFormatterInterfa public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null) { $content = $this->format($feed, $page, $user, $generator, $app); - $response = new Response($content, 200, array('Content-Type' => 'application/rss+xml')); + $response = new Response($content, 200, ['Content-Type' => 'application/rss+xml']); return $response; } diff --git a/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php b/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php index 851121d921..a58d80705c 100644 --- a/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php +++ b/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php @@ -42,10 +42,10 @@ class AggregateLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array( + $params = [ 'token' => $this->getAggregateToken($user, $renew)->getValue(), 'format' => 'atom' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -56,10 +56,10 @@ class AggregateLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array( + $params = [ 'token' => $this->getAggregateToken($user, $renew)->getValue(), 'format' => 'rss' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -93,7 +93,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array('format' => 'atom'); + $params = ['format' => 'atom']; if (null !== $page) { $params['page'] = $page; } @@ -104,7 +104,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array('format' => 'rss'); + $params = ['format' => 'rss']; if (null !== $page) { $params['page'] = $page; } @@ -123,7 +123,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface { $token = $this->em ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findOneBy(array('usrId' => $user->get_id())); + ->findOneBy(['usrId' => $user->get_id()]); if (null === $token || true === $renew) { if (null === $token) { diff --git a/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php b/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php index 001465813f..7a892f5bae 100644 --- a/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php +++ b/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php @@ -50,11 +50,11 @@ class FeedLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array( + $params = [ 'token' => $this->getFeedToken($feed, $user, $renew)->getValue(), 'id' => $feed->getId(), 'format' => 'atom' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -65,11 +65,11 @@ class FeedLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array( + $params = [ 'token' => $this->getFeedToken($feed, $user, $renew)->getValue(), 'id' => $feed->getId(), 'format' => 'rss' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -103,10 +103,10 @@ class FeedLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array( + $params = [ 'id' => $feed->getId(), 'format' => 'atom' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -117,10 +117,10 @@ class FeedLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array( + $params = [ 'id' => $feed->getId(), 'format' => 'rss' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -139,7 +139,7 @@ class FeedLinkGenerator implements LinkGeneratorInterface { $token = $this->em ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findOneBy(array('usrId' => $user->get_id(), 'feed' => $feed->getId())); + ->findOneBy(['usrId' => $user->get_id(), 'feed' => $feed->getId()]); if (null === $token || true === $renew) { if (null === $token) { diff --git a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php index 81a9089898..571ff56819 100644 --- a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php +++ b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php @@ -7,7 +7,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; class LinkGeneratorCollection implements LinkGeneratorInterface { - private $generators = array(); + private $generators = []; /** * Adds a LinkGeneratorInterface to the internal array. diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php index 2a9b679734..0d2c7f7268 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php @@ -19,37 +19,37 @@ class PhraseaAuthenticationForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('login', 'text', array( + $builder->add('login', 'text', [ 'label' => _('Login'), 'required' => true, 'disabled' => $options['disabled'], - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ), - )); + ], + ]); - $builder->add('password', 'password', array( + $builder->add('password', 'password', [ 'label' => _('Password'), 'required' => true, 'disabled' => $options['disabled'], - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ), - )); + ], + ]); - $builder->add('remember-me', 'checkbox', array( + $builder->add('remember-me', 'checkbox', [ 'label' => _('Remember me'), 'mapped' => false, 'required' => false, - 'attr' => array( + 'attr' => [ 'checked' => 'checked', 'value' => '1', - ) - )); + ] + ]); - $builder->add('redirect', 'hidden', array( + $builder->add('redirect', 'hidden', [ 'required' => false, - )); + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php index 7bfb6b39ad..4612548bc3 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php @@ -19,14 +19,14 @@ class PhraseaForgotPasswordForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('email', 'email', array( + $builder->add('email', 'email', [ 'label' => _('E-mail'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), new Assert\Email() - ), - )); + ], + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php index 48b1e2c596..a3f78d258f 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php @@ -31,26 +31,26 @@ class PhraseaRecoverPasswordForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('token', 'hidden', array( + $builder->add('token', 'hidden', [ 'required' => true, - 'constraints' => array( + 'constraints' => [ new PasswordToken($this->app, $this->app['tokens']) - ) - )); + ] + ]); - $builder->add('password', 'repeated', array( + $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, 'invalid_message' => _('Please provide the same passwords.'), 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => array('label' => _('New password')), - 'second_options' => array('label' => _('New password (confirmation)')), - 'constraints' => array( + 'first_options' => ['label' => _('New password')], + 'second_options' => ['label' => _('New password (confirmation)')], + 'constraints' => [ new Assert\NotBlank(), - new Assert\Length(array('min' => 5)), - ), - )); + new Assert\Length(['min' => 5]), + ], + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php index 341662e016..3e7d49972c 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php @@ -24,7 +24,7 @@ class PhraseaRegisterForm extends AbstractType private $params; private $camelizer; - public function __construct(Application $app, array $available, array $params = array(), Camelizer $camelizer = null) + public function __construct(Application $app, array $available, array $params = [], Camelizer $camelizer = null) { $this->app = $app; $this->available = $available; @@ -34,46 +34,46 @@ class PhraseaRegisterForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('email', 'email', array( + $builder->add('email', 'email', [ 'label' => _('E-mail'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), new Assert\Email(), new \Alchemy\Phrasea\Form\Constraint\NewEmail($this->app), - ), - )); + ], + ]); - $builder->add('password', 'repeated', array( + $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, 'invalid_message' => _('Please provide the same passwords.'), 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => array('label' => _('Password')), - 'second_options' => array('label' => _('Password (confirmation)')), - 'constraints' => array( + 'first_options' => ['label' => _('Password')], + 'second_options' => ['label' => _('Password (confirmation)')], + 'constraints' => [ new Assert\NotBlank(), - new Assert\Length(array('min' => 5)), - ), - )); + new Assert\Length(['min' => 5]), + ], + ]); if ($this->app->hasTermsOfUse()) { - $builder->add('accept-tou', 'checkbox', array( + $builder->add('accept-tou', 'checkbox', [ 'label' => _('Terms of Use'), 'mapped' => false, - "constraints" => array( - new Assert\True(array( + "constraints" => [ + new Assert\True([ "message" => _("Please accept the Terms and conditions in order to register.") - ))), - )); + ])], + ]); } $builder->add('provider-id', 'hidden'); require_once $this->app['root.path'] . '/lib/classes/deprecated/inscript.api.php'; - $choices = array(); - $baseIds = array(); + $choices = []; + $baseIds = []; foreach (\giveMeBases($this->app) as $sbas_id => $baseInsc) { if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) { @@ -83,7 +83,7 @@ class PhraseaRegisterForm extends AbstractType $sbasName= \phrasea::sbas_names($sbas_id, $this->app); if (!isset($choices[$sbasName])) { - $choices[$sbasName] = array(); + $choices[$sbasName] = []; } $choices[$sbasName][$baseId] = \phrasea::bas_labels($baseId, $this->app); @@ -97,7 +97,7 @@ class PhraseaRegisterForm extends AbstractType $sbasName= \phrasea::sbas_names($sbas_id, $this->app); if (!isset($choices[$sbasName])) { - $choices[$sbasName] = array(); + $choices[$sbasName] = []; } $choices[$sbasName][$baseId] = \phrasea::bas_labels($baseId, $this->app); @@ -108,19 +108,19 @@ class PhraseaRegisterForm extends AbstractType } if (!$this->app['phraseanet.registry']->get('GV_autoselectDB')) { - $builder->add('collections', 'choice', array( + $builder->add('collections', 'choice', [ 'choices' => $choices, 'multiple' => true, 'expanded' => false, - 'constraints' => array( - new Assert\Choice(array( + 'constraints' => [ + new Assert\Choice([ 'choices' => $baseIds, 'minMessage' => _('You must select at least %s collection.'), 'multiple' => true, 'min' => 1, - )), - ), - )); + ]), + ], + ]); } foreach ($this->params as $param) { @@ -129,7 +129,7 @@ class PhraseaRegisterForm extends AbstractType throw new InvalidArgumentException(sprintf('%s is not a valid fieldname')); } if (isset($this->available[$name])) { - $options = array_merge($this->available[$name], array('required' => $param['required'])); + $options = array_merge($this->available[$name], ['required' => $param['required']]); if (!$param['required']) { unset($options['constraints']); } diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php index 04236af7cb..15c287fb4d 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php @@ -22,27 +22,27 @@ class PhraseaRenewPasswordForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('oldPassword', 'password', array( + $builder->add('oldPassword', 'password', [ 'label' => _('Current password'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank() - ) - )); + ] + ]); - $builder->add('password', 'repeated', array( + $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, 'invalid_message' => _('Please provide the same passwords.'), 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => array('label' => _('New password')), - 'second_options' => array('label' => _('New password (confirmation)')), - 'constraints' => array( + 'first_options' => ['label' => _('New password')], + 'second_options' => ['label' => _('New password (confirmation)')], + 'constraints' => [ new Assert\NotBlank(), - new Assert\Length(array('min' => 5)), - ), - )); + new Assert\Length(['min' => 5]), + ], + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/TaskForm.php b/lib/Alchemy/Phrasea/Form/TaskForm.php index 04b7489a5c..546d424e7d 100644 --- a/lib/Alchemy/Phrasea/Form/TaskForm.php +++ b/lib/Alchemy/Phrasea/Form/TaskForm.php @@ -21,36 +21,36 @@ class TaskForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('name', 'text', array( + $builder->add('name', 'text', [ 'label' => _('Task name'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ), - )); - $builder->add('period', 'integer', array( + ], + ]); + $builder->add('period', 'integer', [ 'label' => _('Task period (in seconds)'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - new Assert\GreaterThan(array('value' => 0)), - ), - )); - $builder->add('status', 'choice', array( + new Assert\GreaterThan(['value' => 0]), + ], + ]); + $builder->add('status', 'choice', [ 'label' => _('The task status'), - 'choices' => array( + 'choices' => [ Task::STATUS_STARTED => 'Started', Task::STATUS_STOPPED => 'Stopped', - ), - )); + ], + ]); $builder->add('settings', 'hidden'); } public function setDefaultOptions(OptionsResolverInterface $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Alchemy\Phrasea\Model\Entities\Task', - )); + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php index ea6c329b21..b32c4b48fb 100644 --- a/lib/Alchemy/Phrasea/Helper/Prod.php +++ b/lib/Alchemy/Phrasea/Helper/Prod.php @@ -21,13 +21,13 @@ class Prod extends Helper public function get_search_datas() { - $search_datas = array( - 'bases' => array(), - 'dates' => array(), - 'fields' => array() - ); + $search_datas = [ + 'bases' => [], + 'dates' => [], + 'fields' => [] + ]; - $bases = $fields = $dates = array(); + $bases = $fields = $dates = []; if (! $this->app['authentication']->getUser() instanceof \User_Adapter) { return $search_datas; @@ -38,21 +38,21 @@ class Prod extends Helper foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); - $bases[$sbas_id] = array( + $bases[$sbas_id] = [ 'thesaurus' => (trim($databox->get_thesaurus()) != ""), 'cterms' => false, - 'collections' => array(), + 'collections' => [], 'sbas_id' => $sbas_id - ); + ]; - foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { + foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]) as $coll) { $selected = (isset($searchSet['bases']) && isset($searchSet['bases'][$sbas_id])) ? (in_array($coll->get_base_id(), $searchSet['bases'][$sbas_id])) : true; $bases[$sbas_id]['collections'][] = - array( + [ 'selected' => $selected, 'base_id' => $coll->get_base_id() - ); + ]; } $meta_struct = $databox->get_meta_structure(); @@ -65,18 +65,18 @@ class Prod extends Helper if (isset($dates[$id])) $dates[$id]['sbas'][] = $sbas_id; else - $dates[$id] = array('sbas' => array($sbas_id), 'fieldname' => $name); + $dates[$id] = ['sbas' => [$sbas_id], 'fieldname' => $name]; } if (isset($fields[$name])) { $fields[$name]['sbas'][] = $sbas_id; } else { - $fields[$name] = array( - 'sbas' => array($sbas_id) + $fields[$name] = [ + 'sbas' => [$sbas_id] , 'fieldname' => $name , 'type' => $meta->get_type() , 'id' => $id - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Helper/Record/Helper.php b/lib/Alchemy/Phrasea/Helper/Record/Helper.php index d165cab385..5b2400f3e3 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Helper.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Helper.php @@ -62,13 +62,13 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper * * @var Array */ - protected $required_rights = array(); + protected $required_rights = []; /** * * @var Array */ - protected $required_sbas_rights = array(); + protected $required_sbas_rights = []; /** * @@ -125,7 +125,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper $storyWZ = $repository->findByUserAndId($app, $app['authentication']->getUser(), $Request->get('story')); - $this->selection->load_list(array($storyWZ->getRecord($this->app)->get_serialize_key()), $this->flatten_groupings); + $this->selection->load_list([$storyWZ->getRecord($this->app)->get_serialize_key()], $this->flatten_groupings); } else { $this->selection->load_list(explode(";", $Request->get('lst')), $this->flatten_groupings); } diff --git a/lib/Alchemy/Phrasea/Helper/Record/Push.php b/lib/Alchemy/Phrasea/Helper/Record/Push.php index 0fedb9767f..533db7f209 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Push.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Push.php @@ -25,6 +25,6 @@ use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; class Push extends RecordHelper { protected $flatten_groupings = true; - protected $required_rights = array('canpush'); + protected $required_rights = ['canpush']; } diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 916bd00e70..ca033cf0ac 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -29,7 +29,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper * * @var array */ - protected $users = array(); + protected $users = []; /** * @@ -49,7 +49,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $this->users = explode(';', $Request->get('users')); - $users = array(); + $users = []; foreach ($this->users as $usr_id) { $usr_id = (int) $usr_id; @@ -77,7 +77,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper protected function delete_user(\User_Adapter $user) { - $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); $this->app['acl']->get($user)->revoke_access_from_bases($list); @@ -90,7 +90,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper public function get_users_rights() { - $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); $sql = "SELECT b.sbas_id, @@ -154,7 +154,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $access = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $base_ids = array(); + $base_ids = []; foreach ($access as $acc) { $base_ids[$acc['base_id']] = $acc; } @@ -174,14 +174,14 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper ->execute()->get_results(); $this->users_datas = $rs; - $out = array( + $out = [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'main_user' => null, 'templates' => $templates - ); + ]; if (count($this->users) == 1) { $usr_id = array_pop($this->users); @@ -202,19 +202,19 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = \connection::getPDOConnection($this->app); $stmt = $conn->prepare($sql); - $stmt->execute(array(':base_id' => $this->base_id)); + $stmt->execute([':base_id' => $this->base_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->users_datas = $rs; - return array( + return [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'collection' => \collection::get_from_base_id($this->app, $this->base_id), - ); + ]; } public function get_masks() @@ -228,17 +228,17 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = $this->app['phraseanet.appbox']->get_connection(); $stmt = $conn->prepare($sql); - $stmt->execute(array(':base_id' => $this->base_id)); + $stmt->execute([':base_id' => $this->base_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $tbits_and = array(); - $tbits_xor = array(); + $tbits_and = []; + $tbits_xor = []; $nrows = 0; for ($bit = 0; $bit < 32; $bit++) - $tbits_and[$bit] = $tbits_xor[$bit] = array("nset" => 0); + $tbits_and[$bit] = $tbits_xor[$bit] = ["nset" => 0]; foreach ($rs as $row) { $sta_xor = strrev($row["mask_xor"]); @@ -255,8 +255,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $nrows++; } - $tbits_left = array(); - $tbits_right = array(); + $tbits_left = []; + $tbits_right = []; $sbas_id = \phrasea::sbasFromBas($this->app, $this->base_id); $databox = $this->app['phraseanet.appbox']->get_databox($sbas_id); @@ -296,22 +296,22 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper } } - $this->users_datas = array( + $this->users_datas = [ 'tbits_left' => $tbits_left, 'tbits_right' => $tbits_right, 'vand_and' => $vand_and, 'vand_or' => $vand_or, 'vxor_and' => $vxor_and, 'vxor_or' => $vxor_or - ); + ]; - return array( + return [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'collection' => \collection::get_from_base_id($this->app, $this->base_id), - ); + ]; } public function get_time() @@ -325,7 +325,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = \connection::getPDOConnection($this->app); $stmt = $conn->prepare($sql); - $stmt->execute(array(':base_id' => $this->base_id)); + $stmt->execute([':base_id' => $this->base_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -355,17 +355,17 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $limited_to = $date_obj_to->format('Y-m-d'); } - $datas = array('time_limited' => $time_limited, 'limited_from' => $limited_from, 'limited_to' => $limited_to); + $datas = ['time_limited' => $time_limited, 'limited_from' => $limited_from, 'limited_to' => $limited_to]; $this->users_datas = $datas; - return array( + return [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'collection' => \collection::get_from_base_id($this->app, $this->base_id), - ); + ]; } public function get_time_sbas() @@ -381,11 +381,11 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = \connection::getPDOConnection($this->app); $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $sbas_id)); + $stmt->execute([':sbas_id' => $sbas_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $time_limited = $limited_from = $limited_to = array(); + $time_limited = $limited_from = $limited_to = []; foreach ($rs as $row) { $time_limited[] = $row['time_limited']; @@ -417,39 +417,39 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $limited_to = false; } - $datas = array( + $datas = [ 'time_limited' => array_pop($time_limited), 'limited_from' => $limited_from, 'limited_to' => $limited_to - ); + ]; } else { - $datas = array( + $datas = [ 'time_limited' => 2, 'limited_from' => '', 'limited_to' => '' - ); + ]; } $this->users_datas = $datas; - return array( + return [ 'sbas_id' => $sbas_id, 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'databox' => $this->app['phraseanet.appbox']->get_databox($sbas_id), - ); + ]; } public function apply_rights() { $ACL = $this->app['acl']->get($this->app['authentication']->getUser()); - $base_ids = array_keys($ACL->get_granted_base(array('canadmin'))); + $base_ids = array_keys($ACL->get_granted_base(['canadmin'])); - $update = $create = $delete = $create_sbas = $update_sbas = array(); + $update = $create = $delete = $create_sbas = $update_sbas = []; foreach ($base_ids as $base_id) { - $rights = array( + $rights = [ 'access', 'actif', 'canputinalbum', @@ -467,7 +467,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper 'canpush', 'manage', 'modify_struct' - ); + ]; foreach ($rights as $k => $right) { if (($right == 'access' && !$ACL->has_access_to_base($base_id)) || ($right != 'access' && !$ACL->has_right_on_base($base_id, $right))) { @@ -503,12 +503,12 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $sbas_ids = $ACL->get_granted_sbas(); foreach ($sbas_ids as $databox) { - $rights = array( + $rights = [ 'bas_modif_th', 'bas_manage', 'bas_modify_struct', 'bas_chupub' - ); + ]; foreach ($rights as $k => $right) { if (!$ACL->has_right_on_sbas($databox->get_sbas_id(), $right)) { unset($rights[$k]); @@ -576,7 +576,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper return $this; } - $infos = array( + $infos = [ 'gender' , 'first_name' , 'last_name' @@ -589,7 +589,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper , 'activite' , 'telephone' , 'fax' - ); + ]; $parm = $this->unserializedRequestData($this->app['request'], $infos, 'user_infos'); @@ -649,7 +649,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper throw new AccessDeniedHttpException('You are not the owner of the template'); } - $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); foreach ($this->users as $usr_id) { $user = \User_adapter::getInstance($usr_id, $this->app); @@ -709,7 +709,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $activate = !!$this->request->get('limit'); - $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); foreach ($this->users as $usr_id) { $user = \User_Adapter::getInstance($usr_id, $this->app); @@ -728,7 +728,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper public function resetRights() { - $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); foreach ($this->users as $usr_id) { $user = \User_Adapter::getInstance($usr_id, $this->app); @@ -758,7 +758,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper private function unserializedRequestData(Request $request, array $indexes, $requestIndex) { - $parameters = $data = array(); + $parameters = $data = []; parse_str($request->get($requestIndex), $data); if (count($data) > 0) { diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index b711635cb0..feb7d54a4d 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -49,7 +49,7 @@ class Manage extends Helper $offset_start = (int) $request->get('offset_start'); $offset_start = $offset_start < 0 ? 0 : $offset_start; - $this->query_parms = array( + $this->query_parms = [ 'inactives' => $request->get('inactives') , 'like_field' => $request->get('like_field') , 'like_value' => $request->get('like_value') @@ -59,7 +59,7 @@ class Manage extends Helper , 'srt' => $request->get("srt", \User_Query::SORT_CREATIONDATE) , 'ord' => $request->get("ord", \User_Query::ORD_DESC) , 'offset_start' => 0 - ); + ]; $query = new \User_Query($this->app); @@ -73,7 +73,7 @@ class Manage extends Helper ->last_model_is($this->query_parms['last_model']) ->get_inactives($this->query_parms['inactives']) ->include_templates(false) - ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), array('canadmin')) + ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), ['canadmin']) ->execute(); return $this->results->get_results(); @@ -86,7 +86,7 @@ class Manage extends Helper $results_quantity = (int) $this->request->get('per_page'); $results_quantity = ($results_quantity < 10 || $results_quantity > 50) ? 20 : $results_quantity; - $this->query_parms = array( + $this->query_parms = [ 'inactives' => $this->request->get('inactives') , 'like_field' => $this->request->get('like_field') , 'like_value' => $this->request->get('like_value') @@ -97,7 +97,7 @@ class Manage extends Helper , 'ord' => $this->request->get("ord", \User_Query::ORD_DESC) , 'per_page' => $results_quantity , 'offset_start' => $offset_start - ); + ]; $query = new \User_Query($this->app); @@ -111,7 +111,7 @@ class Manage extends Helper ->last_model_is($this->query_parms['last_model']) ->get_inactives($this->query_parms['inactives']) ->include_templates(true) - ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), array('canadmin')) + ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), ['canadmin']) ->limit($offset_start, $results_quantity) ->execute(); @@ -139,13 +139,13 @@ class Manage extends Helper ->only_templates(true) ->execute()->get_results(); - return array( + return [ 'users' => $this->results, 'parm' => $this->query_parms, 'invite_user' => $invite, 'autoregister_user' => $autoregister, 'templates' => $templates - ); + ]; } public function create_newuser() @@ -159,7 +159,7 @@ class Manage extends Helper $conn = $this->app['phraseanet.appbox']->get_connection(); $sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':email' => $email)); + $stmt->execute([':email' => $email]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $count = count($row); @@ -181,7 +181,7 @@ class Manage extends Helper $urlToken = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->get_id()); if ($receiver && false !== $urlToken) { - $url = $this->app->url('login_renew_password', array('token' => $urlToken)); + $url = $this->app->url('login_renew_password', ['token' => $urlToken]); $mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url); $mail->setLogin($createdUser->get_login()); $this->app['notification.deliverer']->deliver($mail); @@ -194,7 +194,7 @@ class Manage extends Helper if ($receiver) { $expire = new \DateTime('+3 days'); $token = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->get_id(), $expire, $createdUser->get_email()); - $url = $this->app->url('login_register_confirm', array('code' => $token)); + $url = $this->app->url('login_register_confirm', ['code' => $token]); $mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $expire); $this->app['notification.deliverer']->deliver($mail); diff --git a/lib/Alchemy/Phrasea/Helper/WorkZone.php b/lib/Alchemy/Phrasea/Helper/WorkZone.php index 03017b0d13..dd7f4765b8 100644 --- a/lib/Alchemy/Phrasea/Helper/WorkZone.php +++ b/lib/Alchemy/Phrasea/Helper/WorkZone.php @@ -44,7 +44,7 @@ class WorkZone extends Helper /* @var $repo_baskets Alchemy\Phrasea\Model\Repositories\BasketRepository */ $repo_baskets = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $sort = in_array($sort, array('date', 'name')) ? $sort : 'name'; + $sort = in_array($sort, ['date', 'name']) ? $sort : 'name'; $ret = new ArrayCollection(); @@ -59,7 +59,7 @@ class WorkZone extends Helper $this->app['EM']->persist($basket); $this->app['EM']->flush(); - $baskets = array($basket); + $baskets = [$basket]; } $validations = $repo_baskets->findActiveValidationByUser($this->app['authentication']->getUser(), $sort); diff --git a/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php b/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php index fd709afbdd..cfa62e3e46 100644 --- a/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php +++ b/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php @@ -72,7 +72,7 @@ class ServeFileResponseFactory implements DeliverDataInterface private function sanitizeFilename($filename) { - return str_replace(array('/', '\\'), '', $filename); + return str_replace(['/', '\\'], '', $filename); } private function sanitizeFilenameFallback($filename) diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php b/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php index cfc09ffc92..c89a297269 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php @@ -15,7 +15,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; abstract class AbstractXSendFileMode { - protected $mapping = array(); + protected $mapping = []; /** * @params array $mapping diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php b/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php index 1102205288..d77aa63103 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php @@ -21,9 +21,9 @@ class ApacheMode extends AbstractXSendFileMode implements ModeInterface */ public function setHeaders(Request $request) { - $request->headers->add(array( + $request->headers->add([ 'X-Sendfile-Type' => 'X-SendFile', - )); + ]); } /** @@ -31,7 +31,7 @@ class ApacheMode extends AbstractXSendFileMode implements ModeInterface */ public function setMapping(array $mapping) { - $final = array(); + $final = []; foreach ($mapping as $entry) { if (!is_array($entry)) { @@ -46,9 +46,9 @@ class ApacheMode extends AbstractXSendFileMode implements ModeInterface continue; } - $final[] = array( + $final[] = [ 'directory' => $this->sanitizePath(realpath($entry['directory'])) - ); + ]; } $this->mapping = $final; diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php b/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php index 1d81d329b6..610af6d88a 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php @@ -21,17 +21,17 @@ class NginxMode extends AbstractXSendFileMode implements ModeInterface */ public function setHeaders(Request $request) { - $xAccelMapping = array(); + $xAccelMapping = []; foreach ($this->mapping as $entry) { $xAccelMapping[] = sprintf('%s=%s', $entry['mount-point'], $entry['directory']); } if (count($xAccelMapping) > 0 ) { - $request->headers->add(array( + $request->headers->add([ 'X-Sendfile-Type' => 'X-Accel-Redirect', 'X-Accel-Mapping' => implode(',', $xAccelMapping), - )); + ]); } } @@ -40,7 +40,7 @@ class NginxMode extends AbstractXSendFileMode implements ModeInterface */ public function setMapping(array $mapping) { - $final = array(); + $final = []; foreach ($mapping as $entry) { if (!is_array($entry)) { @@ -59,10 +59,10 @@ class NginxMode extends AbstractXSendFileMode implements ModeInterface continue; } - $final[] = array( + $final[] = [ 'directory' => $this->sanitizePath(realpath($entry['directory'])), 'mount-point' => $this->sanitizeMountPoint($entry['mount-point']) - ); + ]; } $this->mapping = $final; diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php b/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php index 10b67a811d..2f51791a2a 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php @@ -50,7 +50,7 @@ class XSendFileFactory { $conf = $app['configuration']['xsendfile']; - $mapping = array(); + $mapping = []; if (isset($conf['mapping'])) { $mapping = $conf['mapping']; diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php index 545d6ab407..af0a6de749 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php @@ -26,14 +26,14 @@ class Audio extends Provider public function __construct() { - $AVaudiosamplerate = array( + $AVaudiosamplerate = [ 8000, 11025, 16000, 22050, 32000, 44056, 44100, 47250, 48000, 50000, 50400, 88200, 96000 - ); + ]; $this->registerOption(new OptionType\Range(_('Audio Birate'), self::OPTION_AUDIOBITRATE, 32, 320, 128, 32)); $this->registerOption(new OptionType\Enum(_('AudioSamplerate'), self::OPTION_AUDIOSAMPLERATE, $AVaudiosamplerate)); - $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, array('libmp3lame', 'flac'), 'libmp3lame')); + $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, ['libmp3lame', 'flac'], 'libmp3lame')); } public function getType() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php index b9e1dfe71e..4550f67b48 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php @@ -19,7 +19,7 @@ namespace Alchemy\Phrasea\Media\Subdef; */ class FlexPaper extends Provider { - protected $options = array(); + protected $options = []; public function __construct() { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 9a7f6ee2e3..eda3ebab9b 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -26,7 +26,7 @@ class Image extends Provider const OPTION_STRIP = 'strip'; const OPTION_QUALITY = 'quality'; - protected $options = array(); + protected $options = []; public function __construct() { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php index e1b5549d3e..344acdf02e 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php @@ -28,7 +28,7 @@ class Multi implements OptionType { $this->displayName = $displayName; $this->name = $name; - $this->available = array(); + $this->available = []; foreach ($available as $a) { $this->available[$a] = false; } @@ -93,7 +93,7 @@ class Multi implements OptionType return $this->available; } - $value = array(); + $value = []; foreach ($this->available as $a => $selected) { if ($selected) { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php index a068f63a9f..4a000aef59 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php @@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Media\Subdef; */ abstract class Provider implements Subdef { - protected $options = array(); + protected $options = []; protected $spec; public function registerOption(OptionType\OptionType $option) diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Video.php b/lib/Alchemy/Phrasea/Media/Subdef/Video.php index 3a5f8d2293..07a12fdd56 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Video.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Video.php @@ -25,7 +25,7 @@ class Video extends Audio const OPTION_VCODEC = 'vcodec'; const OPTION_GOPSIZE = 'GOPsize'; - protected $options = array(); + protected $options = []; public function __construct() { @@ -35,9 +35,9 @@ class Video extends Audio $this->registerOption(new OptionType\Range(_('GOP size'), self::OPTION_GOPSIZE, 1, 300, 10)); $this->registerOption(new OptionType\Range(_('Dimension'), self::OPTION_SIZE, 64, 2000, 600, 16)); $this->registerOption(new OptionType\Range(_('Frame Rate'), self::OPTION_FRAMERATE, 1, 200, 20)); - $this->registerOption(new OptionType\Enum(_('Video Codec'), self::OPTION_VCODEC, array('libx264', 'libvpx', 'libtheora'), 'libx264')); + $this->registerOption(new OptionType\Enum(_('Video Codec'), self::OPTION_VCODEC, ['libx264', 'libvpx', 'libtheora'], 'libx264')); $this->unregisterOption(self::OPTION_ACODEC); - $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, array('libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'), 'libfaac')); + $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, ['libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'], 'libfaac')); } public function getType() diff --git a/lib/Alchemy/Phrasea/Metadata/TagProvider.php b/lib/Alchemy/Phrasea/Metadata/TagProvider.php index ad888ccdd3..26009ffe87 100644 --- a/lib/Alchemy/Phrasea/Metadata/TagProvider.php +++ b/lib/Alchemy/Phrasea/Metadata/TagProvider.php @@ -20,7 +20,7 @@ class TagProvider extends ExiftoolTagProvider parent::__construct(); $this['Phraseanet'] = $this->share(function () { - return array( + return [ 'PdfText' => new \Alchemy\Phrasea\Metadata\Tag\PdfText(), 'TfArchivedate' => new \Alchemy\Phrasea\Metadata\Tag\TfArchivedate(), 'TfAtime' => new \Alchemy\Phrasea\Metadata\Tag\TfAtime(), @@ -41,7 +41,7 @@ class TagProvider extends ExiftoolTagProvider 'TfRecordid' => new \Alchemy\Phrasea\Metadata\Tag\TfRecordid(), 'TfSize' => new \Alchemy\Phrasea\Metadata\Tag\TfSize(), 'TfWidth' => new \Alchemy\Phrasea\Metadata\Tag\TfWidth(), - ); + ]; }); } @@ -57,107 +57,107 @@ class TagProvider extends ExiftoolTagProvider { $table = parent::getLookupTable(); - $table['phraseanet'] = array( - 'pdftext' => array( + $table['phraseanet'] = [ + 'pdftext' => [ 'tagname' => 'PdfText', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\PdfText', - 'namespace' => 'Phraseanet'), - 'tfarchivedate' => array( + 'namespace' => 'Phraseanet'], + 'tfarchivedate' => [ 'tagname' => 'TfArchivedate', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfArchivedate', 'namespace' => 'Phraseanet' - ), - 'tfatime' => array( + ], + 'tfatime' => [ 'tagname' => 'TfAtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfAtime', 'namespace' => 'Phraseanet' - ), - 'tfbasename' => array( + ], + 'tfbasename' => [ 'tagname' => 'TfBasename', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBasename', 'namespace' => 'Phraseanet' - ), - 'tfbits' => array( + ], + 'tfbits' => [ 'tagname' => 'TfBits', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBits', 'namespace' => 'Phraseanet' - ), - 'tfchannels' => array( + ], + 'tfchannels' => [ 'tagname' => 'TfChannels', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfChannels', 'namespace' => 'Phraseanet' - ), - 'tTfCtime' => array( + ], + 'tTfCtime' => [ 'tagname' => 'TfCtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfCtime', 'namespace' => 'Phraseanet' - ), - 'tfdirname' => array( + ], + 'tfdirname' => [ 'tagname' => 'TfDirname', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDirname', 'namespace' => 'Phraseanet' - ), - 'tfduration' => array( + ], + 'tfduration' => [ 'tagname' => 'TfDuration', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDuration', 'namespace' => 'Phraseanet' - ), - 'tfeditdate' => array( + ], + 'tfeditdate' => [ 'tagname' => 'TfEditdate', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfEditdate', 'namespace' => 'Phraseanet' - ), - 'tfextension' => array( + ], + 'tfextension' => [ 'tagname' => 'TfExtension', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfExtension', 'namespace' => 'Phraseanet' - ), - 'tffilename' => array( + ], + 'tffilename' => [ 'tagname' => 'TfFilename', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilename', 'namespace' => 'Phraseanet' - ), - 'tffilepath' => array( + ], + 'tffilepath' => [ 'tagname' => 'TfFilepath', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilepath', 'namespace' => 'Phraseanet' - ), - 'tfheight' => array( + ], + 'tfheight' => [ 'tagname' => 'TfHeight', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfHeight', 'namespace' => 'Phraseanet' - ), - 'tfmimetype' => array( + ], + 'tfmimetype' => [ 'tagname' => 'TfMimetype', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMimetype', 'namespace' => 'Phraseanet' - ), - 'tfmtime' => array( + ], + 'tfmtime' => [ 'tagname' => 'TfMtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMtime', 'namespace' => 'Phraseanet' - ), - 'tfquarantine' => array( + ], + 'tfquarantine' => [ 'tagname' => 'TfQuarantine', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfQuarantine', 'namespace' => 'Phraseanet' - ), - 'tfrecordid' => array( + ], + 'tfrecordid' => [ 'tagname' => 'TfRecordid', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfRecordid', 'namespace' => 'Phraseanet' - ), - 'tfsize' => array( + ], + 'tfsize' => [ 'tagname' => 'TfSize', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfSize', 'namespace' => 'Phraseanet' - ), - 'tfwidth' => array( + ], + 'tfwidth' => [ 'tagname' => 'TfWidth', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfWidth', 'namespace' => 'Phraseanet' - ), - ); + ], + ]; return $table; } diff --git a/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php b/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php index 29473fda6c..61508b63e0 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php +++ b/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php @@ -425,7 +425,7 @@ class LazaretFile */ public function getRecordsToSubstitute(Application $app) { - $ret = array(); + $ret = []; $shaRecords = \record_adapter::get_record_by_sha( $app, $this->getCollection($app)->get_sbas_id(), $this->getSha256() diff --git a/lib/Alchemy/Phrasea/Model/Entities/Task.php b/lib/Alchemy/Phrasea/Model/Entities/Task.php index 93bed32811..696531795f 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Task.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Task.php @@ -198,7 +198,7 @@ class Task */ public function setStatus($status) { - if (!in_array($status, array(static::STATUS_STARTED, static::STATUS_STOPPED), true)) { + if (!in_array($status, [static::STATUS_STARTED, static::STATUS_STOPPED], true)) { throw new InvalidArgumentException('Invalid status value.'); } diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index 916039f696..3f20659a49 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -48,7 +48,7 @@ class User * * @var array */ - private static $defaultUserSettings = array( + private static $defaultUserSettings = [ 'view' => 'thumbs', 'images_per_page' => '20', 'images_size' => '120', @@ -70,7 +70,7 @@ class User 'basket_caption_display' => '0', 'basket_status_display' => '0', 'basket_title_display' => '0' - ); + ]; /** * @ORM\Column(type="integer") @@ -439,11 +439,11 @@ class User */ public function setGender($gender) { - if (null !== $gender && !in_array($gender, array( + if (null !== $gender && !in_array($gender, [ self::GENDER_MISS, self::GENDER_MR, self::GENDER_MRS - ))) { + ])) { throw new InvalidArgumentException(sprintf("Invalid gender %s.", $gender)); } @@ -1018,7 +1018,7 @@ class User */ public function isSpecial() { - return in_array($this->login, array(self::USER_GUEST, self::USER_AUTOREGISTER)); + return in_array($this->login, [self::USER_GUEST, self::USER_AUTOREGISTER]); } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php index 7763147922..865bd3c53f 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php @@ -111,7 +111,7 @@ class UsrListOwner */ public function setRole($role) { - if ( ! in_array($role, array(self::ROLE_ADMIN, self::ROLE_EDITOR, self::ROLE_USER))) + if ( ! in_array($role, [self::ROLE_ADMIN, self::ROLE_EDITOR, self::ROLE_USER])) throw new \Exception('Unknown role `' . $role . '`'); $this->role = $role; diff --git a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php index 64f87d1a9d..01eedfb30e 100644 --- a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php +++ b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php @@ -137,7 +137,7 @@ class UserManager private function cleanFtpExports(User $user) { $elements = $this->objectManager->getRepository('Alchemy\Phrasea\Model\Entities\FtpExport') - ->findBy(array('usrId' => $user->getId())); + ->findBy(['usrId' => $user->getId()]); foreach ($elements as $element) { $this->objectManager->remove($element); @@ -152,7 +152,7 @@ class UserManager private function cleanOrders(User $user) { $orders = $this->objectManager->getRepository('Alchemy\Phrasea\Model\Entities\Order') - ->findBy(array('usrId' => $user->getId())); + ->findBy(['usrId' => $user->getId()]); foreach ($orders as $order) { $this->objectManager->remove($order); @@ -166,13 +166,13 @@ class UserManager */ private function cleanProperties(User $user) { - foreach(array( + foreach ([ 'DELETE FROM `edit_presets` WHERE usr_id = :usr_id', 'DELETE FROM `sselnew` WHERE usr_id = :usr_id', 'DELETE FROM `tokens` WHERE usr_id = :usr_id', - ) as $sql) { + ] as $sql) { $stmt = $this->appboxConnection->prepare($sql); - $stmt->execute(array(':usr_id' => $user->getId())); + $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); } @@ -190,12 +190,12 @@ class UserManager */ private function cleanRights(User $user) { - foreach(array( + foreach ([ 'DELETE FROM `basusr` WHERE usr_id = :usr_id', 'DELETE FROM `sbasusr` WHERE usr_id = :usr_id', - ) as $sql) { + ] as $sql) { $stmt = $this->appboxConnection->prepare($sql); - $stmt->execute(array(':usr_id' => $user->getId())); + $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); } } diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php index 8b47cab291..430a466bc6 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php @@ -79,12 +79,12 @@ class ACLManipulator implements ManipulatorInterface { $collections = $databox->get_collections(); - $acl->update_rights_to_sbas($databox->get_sbas_id(), array( + $acl->update_rights_to_sbas($databox->get_sbas_id(), [ 'bas_manage' => '1', 'bas_modify_struct' => '1', 'bas_modif_th' => '1', 'bas_chupub' => '1' - )); + ]); $acl->give_access_to_base(array_map(function (\collection $collection) { return $collection->get_base_id(); @@ -108,7 +108,7 @@ class ACLManipulator implements ManipulatorInterface $acl->set_limits($baseId, false); $acl->remove_quotas_on_base($baseId); $acl->set_masks_on_base($baseId, '0', '0', '0', '0'); - $acl->update_rights_to_base($baseId, array( + $acl->update_rights_to_base($baseId, [ 'canputinalbum' => '1', 'candwnldhd' => '1', 'candwnldsubdef' => '1', @@ -127,7 +127,7 @@ class ACLManipulator implements ManipulatorInterface 'manage' => '1', 'modify_struct' => '1', 'bas_modify_struct' => '1' - )); + ]); } /** @@ -140,7 +140,7 @@ class ACLManipulator implements ManipulatorInterface private function makeTraversable($var) { if (!is_array($var) && !$var instanceof \Traversable) { - return array($var); + return [$var]; } return $var; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php index 5edf389598..01b75ad7ab 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php @@ -293,7 +293,7 @@ class UserManipulator implements ManipulatorInterface private function makeTraversable($var) { if (!is_array($var) && !$var instanceof \Traversable) { - return array($var); + return [$var]; } return $var; diff --git a/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php b/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php index a944af7e9c..aee7ec3d80 100644 --- a/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php +++ b/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php @@ -31,7 +31,7 @@ class MonologSQLLogger implements SQLLogger */ private $logger; private $start; - private $output = array(); + private $output = []; private $outputType; /** diff --git a/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php index 592c67c128..91e2d58863 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php @@ -20,7 +20,7 @@ class AuthFailureRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\AuthFailure f WHERE f.created < :date'; - $params = array('date' => $date->format('Y-m-d h:i:s')); + $params = ['date' => $date->format('Y-m-d h:i:s')]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -35,10 +35,10 @@ class AuthFailureRepository extends EntityRepository WHERE (f.username = :username OR f.ip = :ip) AND f.locked = true'; - $params = array( + $params = [ 'username' => $username, 'ip' => $ip, - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php index fededd3268..1cd35e8f08 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php @@ -26,11 +26,11 @@ class BasketElementRepository extends EntityRepository WHERE (b.usr_id = :usr_id OR p.usr_id = :same_usr_id) AND e.id = :element_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), 'same_usr_id' => $user->get_id(), 'element_id' => $element_id - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -55,10 +55,10 @@ class BasketElementRepository extends EntityRepository WHERE e.record_id = :record_id AND e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -75,9 +75,9 @@ class BasketElementRepository extends EntityRepository LEFT JOIN s.participants p WHERE e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $databox->get_sbas_id(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -103,11 +103,11 @@ class BasketElementRepository extends EntityRepository AND e.record_id = :record_id AND e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'usr_id' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -126,11 +126,11 @@ class BasketElementRepository extends EntityRepository AND e.record_id = :record_id AND e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'usr_id' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php index dd9595f534..e40653eed7 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php @@ -47,7 +47,7 @@ class BasketRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array('usr_id' => $user->get_id())); + $query->setParameters(['usr_id' => $user->get_id()]); return $query->getResult(); } @@ -74,11 +74,11 @@ class BasketRepository extends EntityRepository ) AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())'; - $params = array( + $params = [ 'usr_id_owner' => $user->get_id(), 'usr_id_ownertwo' => $user->get_id(), 'usr_id_participant' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -111,7 +111,7 @@ class BasketRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id())); + $query->setParameters([1 => $user->get_id(), 2 => $user->get_id()]); return $query->getResult(); } @@ -125,10 +125,10 @@ class BasketRepository extends EntityRepository WHERE e.record_id = :record_id AND e.sbas_id = e.sbas_id AND b.usr_id = :usr_id'; - $params = array( + $params = [ 'record_id' => $record->get_record_id(), 'usr_id' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -138,7 +138,7 @@ class BasketRepository extends EntityRepository public function findWorkzoneBasket(\User_Adapter $user, $query, $year, $type, $offset, $perPage) { - $params = array(); + $params = []; switch ($type) { case self::RECEIVED: @@ -146,9 +146,9 @@ class BasketRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\Basket b JOIN b.elements e WHERE b.usr_id = :usr_id AND b.pusher_id IS NOT NULL'; - $params = array( + $params = [ 'usr_id' => $user->get_id() - ); + ]; break; case self::VALIDATION_DONE: $dql = 'SELECT b @@ -157,10 +157,10 @@ class BasketRepository extends EntityRepository JOIN b.validation s JOIN s.participants p WHERE b.usr_id != ?1 AND p.usr_id = ?2'; - $params = array( + $params = [ 1 => $user->get_id() , 2 => $user->get_id() - ); + ]; break; case self::VALIDATION_SENT: $dql = 'SELECT b @@ -168,9 +168,9 @@ class BasketRepository extends EntityRepository JOIN b.elements e JOIN b.validation v WHERE b.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id() - ); + ]; break; default: $dql = 'SELECT b @@ -179,10 +179,10 @@ class BasketRepository extends EntityRepository LEFT JOIN b.validation s LEFT JOIN s.participants p WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), 'validating_usr_id' => $user->get_id() - ); + ]; break; case self::MYBASKETS: $dql = 'SELECT b @@ -191,9 +191,9 @@ class BasketRepository extends EntityRepository LEFT JOIN b.validation s LEFT JOIN s.participants p WHERE (b.usr_id = :usr_id)'; - $params = array( + $params = [ 'usr_id' => $user->get_id() - ); + ]; break; } @@ -249,7 +249,7 @@ class BasketRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array('usr_id' => $user->get_id())); + $query->setParameters(['usr_id' => $user->get_id()]); return $query->getResult(); } diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php index 272f0f22ba..3e3f38d75b 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php @@ -34,7 +34,7 @@ class FeedItemRepository extends EntityRepository AND f.public = true'; $query = $this->_em->createQuery($dql); - $query->setParameters(array('sbas_id' => $sbas_id, 'record_id' => $record_id)); + $query->setParameters(['sbas_id' => $sbas_id, 'record_id' => $record_id]); return count($query->getResult()) > 0; } @@ -50,7 +50,7 @@ class FeedItemRepository extends EntityRepository public function loadLatest(Application $app, $nbItems = 20) { $execution = 0; - $items = array(); + $items = []; do { $dql = 'SELECT i diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php index 94eaeb789e..472f40c56d 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php @@ -59,6 +59,6 @@ class FtpExportRepository extends EntityRepository */ public function findByUser(\User_Adapter $user) { - return $this->findBy(array('usrId' => $user->get_id())); + return $this->findBy(['usrId' => $user->get_id()]); } } diff --git a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php index d36e8d026a..c89ddb374d 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php @@ -21,7 +21,7 @@ class OrderRepository extends EntityRepository */ public function findByUser(\User_Adapter $user) { - return $this->findBy(array('usrId' => $user->get_id())); + return $this->findBy(['usrId' => $user->get_id()]); } /** @@ -66,7 +66,7 @@ class OrderRepository extends EntityRepository * * @return integer */ - public function countTotalOrders(array $baseIds = array()) + public function countTotalOrders(array $baseIds = []) { $qb = $this ->createQueryBuilder('o'); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php index b7b73a0c98..5847feb2d0 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php @@ -25,7 +25,7 @@ class StoryWZRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array('usr_id' => $user->get_id())); + $query->setParameters(['usr_id' => $user->get_id()]); $stories = $query->getResult(); @@ -41,7 +41,7 @@ class StoryWZRepository extends EntityRepository $this->getEntityManager()->flush(); if ($sort == 'name') { - $sortedStories = array(); + $sortedStories = []; foreach ($stories as $story) { $sortedStories[] = $story->getRecord($app)->get_title(); } @@ -87,11 +87,11 @@ class StoryWZRepository extends EntityRepository public function findUserStory(Application $app, \User_Adapter $user, \record_adapter $Story) { $story = $this->findOneBy( - array( + [ 'usr_id' => $user->get_id(), 'sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id(), - ) + ] ); if ($story) { @@ -113,10 +113,10 @@ class StoryWZRepository extends EntityRepository AND s.record_id = :record_id'; $query = $this->_em->createQuery($dql); - $query->setParameters(array( + $query->setParameters([ 'sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id(), - )); + ]); $stories = $query->getResult(); @@ -138,9 +138,9 @@ class StoryWZRepository extends EntityRepository $dql = 'SELECT s FROM Alchemy\Phrasea\Model\Entities\StoryWZ s WHERE s.sbas_id = :sbas_id'; $query = $this->_em->createQuery($dql); - $query->setParameters(array( + $query->setParameters([ 'sbas_id' => $databox->get_sbas_id(), - )); + ]); $stories = $query->getResult(); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php index 2181933111..f9283bc82a 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php @@ -47,7 +47,7 @@ class UserRepository extends EntityRepository */ public function findByLogin($login) { - return $this->findOneBy(array('login' => $login)); + return $this->findOneBy(['login' => $login]); } /** diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php index 34e4d43e97..dd5409293c 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php @@ -18,7 +18,7 @@ class UsrAuthProviderRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\UsrAuthProvider u WHERE u.usr_id = :usrId'; - $params = array('usrId' => $user->get_id()); + $params = ['usrId' => $user->get_id()]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -32,7 +32,7 @@ class UsrAuthProviderRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\UsrAuthProvider u WHERE u.provider = :providerId AND u.distant_id = :distantId'; - $params = array('providerId' => $providerId, 'distantId' => $distantId); + $params = ['providerId' => $providerId, 'distantId' => $distantId]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php index b9d2900ea1..9d41de33d0 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php @@ -28,9 +28,9 @@ class UsrListEntryRepository extends EntityRepository $dql = 'SELECT e FROM Alchemy\Phrasea\Model\Entities\UsrListEntry e WHERE e.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -60,10 +60,10 @@ class UsrListEntryRepository extends EntityRepository JOIN e.list l WHERE e.usr_id = :usr_id AND l.id = :list_id'; - $params = array( + $params = [ 'usr_id' => $usr_id, 'list_id' => $list->getId(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php index 7c66fb4fb1..eb3b8fb2a8 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php @@ -53,10 +53,10 @@ class UsrListOwnerRepository extends EntityRepository JOIN o.list l WHERE l.id = :list_id AND o.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $usr_id, 'list_id' => $list->getId() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php index a7fcc9e9ca..38a5e4aa4b 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php @@ -29,9 +29,9 @@ class UsrListRepository extends EntityRepository JOIN l.owners o WHERE o.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -74,10 +74,10 @@ class UsrListRepository extends EntityRepository JOIN l.owners o WHERE o.usr_id = :usr_id AND l.name LIKE :name'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), 'name' => $name . '%' - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Notification/Deliverer.php b/lib/Alchemy/Phrasea/Notification/Deliverer.php index 6a09287db5..7fa2781968 100644 --- a/lib/Alchemy/Phrasea/Notification/Deliverer.php +++ b/lib/Alchemy/Phrasea/Notification/Deliverer.php @@ -68,7 +68,7 @@ class Deliverer if (!$mail->getEmitter()) { throw new LogicException('You must provide an emitter for a ReadReceipt'); } - $message->setReadReceiptTo(array($mail->getEmitter()->getEmail() => $mail->getEmitter()->getName())); + $message->setReadReceiptTo([$mail->getEmitter()->getEmail() => $mail->getEmitter()->getName()]); } $ret = $this->mailer->send($message); diff --git a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php index 016b724962..2fd672a58a 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php @@ -47,7 +47,7 @@ abstract class AbstractMail implements MailInterface */ public function renderHTML() { - return $this->app['twig']->render('email-template.html.twig', array( + return $this->app['twig']->render('email-template.html.twig', [ 'phraseanetURL' => $this->getPhraseanetURL(), 'phraseanetTitle' => $this->getPhraseanetTitle(), 'logoUrl' => $this->getLogoUrl(), @@ -59,7 +59,7 @@ abstract class AbstractMail implements MailInterface 'expiration' => $this->getExpiration(), 'buttonUrl' => $this->getButtonURL(), 'buttonText' => $this->getButtonText(), - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php index 17cd0b220c..2776425cf8 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php @@ -45,6 +45,6 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getButtonURL() { - return $this->app->url('admin', array('section' => 'users')); + return $this->app->url('admin', ['section' => 'users']); } } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php index 0981334531..0516af5e60 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php @@ -65,6 +65,6 @@ class MailInfoUserRegistered extends AbstractMail */ public function getButtonURL() { - return $this->app->url('admin', array('section' => 'registrations')); + return $this->app->url('admin', ['section' => 'registrations']); } } diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index ec2d10562f..6f1b811801 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -36,7 +36,7 @@ class PDF { $this->app = $app; - $list = array(); + $list = []; foreach ($records as $record) { switch ($layout) { @@ -458,8 +458,8 @@ class PDF $this->pdf->SetFont(PhraseaPDF::FONT, '', 12); $t = str_replace( - array("<", ">", "&") - , array("<", ">", "&") + ["<", ">", "&"] + , ["<", ">", "&"] , strip_tags($field->get_serialized_values()) ); diff --git a/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php b/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php index e74656fd56..d0d6e363a0 100644 --- a/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php +++ b/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php @@ -17,7 +17,7 @@ class JsonValidationException extends RuntimeException { protected $errors; - public function __construct($message, $errors = array()) + public function __construct($message, $errors = []) { $this->errors = $errors; parent::__construct($message); diff --git a/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php b/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php index 79394d8fca..3ba13cf9bf 100644 --- a/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php +++ b/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php @@ -66,12 +66,12 @@ class ComposerInstaller throw new ComposerInstallException('Unable to install composer.', $e->getCode(), $e); } } else { - $process = ProcessBuilder::create(array( + $process = ProcessBuilder::create([ $this->phpExecutable, $this->composer, 'self-update' - ))->getProcess(); + ])->getProcess(); $process->run(); } - return ProcessBuilder::create(array($this->phpExecutable, $this->composer)); + return ProcessBuilder::create([$this->phpExecutable, $this->composer]); } } diff --git a/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php b/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php index 779909c690..ecbee28b98 100644 --- a/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php +++ b/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php @@ -67,17 +67,17 @@ class Manifest public function getServices() { - return $this->get('services') ? : array(); + return $this->get('services') ? : []; } public function getCommands() { - return $this->get('commands') ? : array(); + return $this->get('commands') ? : []; } public function getTwigPaths() { - return $this->get('twig-paths') ? : array(); + return $this->get('twig-paths') ? : []; } public function getExtra() diff --git a/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php b/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php index 26e9d18c5b..1f368f6c26 100644 --- a/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php +++ b/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php @@ -45,7 +45,7 @@ class ManifestValidator $this->validator->check($data, $this->schemaData); if (!$this->validator->isValid()) { - $errors = array(); + $errors = []; foreach ((array) $this->validator->getErrors() as $error) { $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message']; } @@ -53,7 +53,7 @@ class ManifestValidator } if (!preg_match('/^[a-z0-9-_]+$/', $data->name)) { - throw new JsonValidationException('Does not match the expected JSON schema', array('"name" must not contains only alphanumeric caracters')); + throw new JsonValidationException('Does not match the expected JSON schema', ['"name" must not contains only alphanumeric caracters']); } if (isset($data->{'minimum-phraseanet-version'})) { diff --git a/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php b/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php index c963a0c363..0f10b199f0 100644 --- a/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php +++ b/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php @@ -95,7 +95,7 @@ class PluginValidator } if (is_array($data)) { - return array_map(array($this, 'objectToArray'), $data); + return array_map([$this, 'objectToArray'], $data); } return $data; diff --git a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php index 10b54c187b..d9099e22a6 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php @@ -20,7 +20,7 @@ abstract class AbstractConfigurationPanel implements ConfigurationPanelInterface */ public function getAvailableDateFields(array $databoxes) { - $date_fields = array(); + $date_fields = []; foreach ($databoxes as $databox) { foreach ($databox->get_meta_structure() as $field) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php index 2c408ce979..5ae8ede86a 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php @@ -42,10 +42,10 @@ class ConfigurationPanel extends AbstractConfigurationPanel { $configuration = $this->getConfiguration(); - $params = array( + $params = [ 'configuration' => $configuration, 'available_sort'=> $this->searchEngine->getAvailableSort(), - ); + ]; return $app['twig']->render('admin/search-engine/phrasea.html.twig', $params); } @@ -56,9 +56,9 @@ class ConfigurationPanel extends AbstractConfigurationPanel public function post(Application $app, Request $request) { $configuration = $this->getConfiguration(); - $configuration['date_fields'] = array(); + $configuration['date_fields'] = []; - foreach ($request->request->get('date_fields', array()) as $field) { + foreach ($request->request->get('date_fields', []) as $field) { $configuration['date_fields'][] = $field; } @@ -75,14 +75,14 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : array(); + $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; if (!is_array($configuration)) { - $configuration = array(); + $configuration = []; } if (!isset($configuration['date_fields'])) { - $configuration['date_fields'] = array(); + $configuration['date_fields'] = []; } if (!isset($configuration['default_sort'])) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php index 81ab20947c..a5bcd9c604 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php @@ -32,11 +32,11 @@ class PhraseaEngine implements SearchEngineInterface private $app; private $dateFields; private $configuration; - private $queries = array(); - private $arrayq = array(); - private $colls = array(); - private $qp = array(); - private $needthesaurus = array(); + private $queries = []; + private $arrayq = []; + private $colls = []; + private $qp = []; + private $needthesaurus = []; private $configurationPanel; private $resetCacheNextQuery = false; @@ -63,7 +63,7 @@ class PhraseaEngine implements SearchEngineInterface public function getAvailableDateFields() { if (!$this->dateFields) { - $this->dateFields = array(); + $this->dateFields = []; foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_meta_structure() as $databox_field) { if ($databox_field->get_type() != \databox_field::TYPE_DATE) { @@ -109,7 +109,7 @@ class PhraseaEngine implements SearchEngineInterface { $date_fields = $this->getAvailableDateFields(); - $sort = array('' => _('No sort')); + $sort = ['' => _('No sort')]; foreach ($date_fields as $field) { $sort[$field] = $field; @@ -133,10 +133,10 @@ class PhraseaEngine implements SearchEngineInterface */ public function getAvailableOrder() { - return array( + return [ 'desc' => _('descendant'), 'asc' => _('ascendant'), - ); + ]; } /** @@ -214,9 +214,9 @@ class PhraseaEngine implements SearchEngineInterface */ public function getStatus() { - $status = array(); + $status = []; foreach (phrasea_info() as $key => $value) { - $status[] = array($key, $value); + $status[] = [$key, $value]; } return $status; @@ -239,7 +239,7 @@ class PhraseaEngine implements SearchEngineInterface */ public function getAvailableTypes() { - return array(self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY); + return [self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY]; } /** @@ -259,17 +259,17 @@ class PhraseaEngine implements SearchEngineInterface $sql = "DELETE FROM prop WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record->get_record_id())); + $stmt->execute([':record_id' => $record->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM idx WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record->get_record_id())); + $stmt->execute([':record_id' => $record->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM thit WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record->get_record_id())); + $stmt->execute([':record_id' => $record->get_record_id()]); $stmt->closeCursor(); unset($stmt, $connbas); @@ -377,7 +377,7 @@ class PhraseaEngine implements SearchEngineInterface $sql = 'SELECT query, query_time, duration, total FROM cache WHERE session_id = :ses_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':ses_id' => $this->app['session']->get('phrasea_session_id'))); + $stmt->execute([':ses_id' => $this->app['session']->get('phrasea_session_id')]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -398,7 +398,7 @@ class PhraseaEngine implements SearchEngineInterface $sql = 'SELECT query, query_time, duration, total FROM cache WHERE session_id = :ses_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':ses_id' => $this->app['session']->get('phrasea_session_id'))); + $stmt->execute([':ses_id' => $this->app['session']->get('phrasea_session_id')]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); } else { @@ -412,7 +412,7 @@ class PhraseaEngine implements SearchEngineInterface $this->app['session']->get('phrasea_session_id'), $offset + 1, $perPage, false ); - $rs = array(); + $rs = []; $error = _('Unable to execute query'); if (isset($res['results']) && is_array($res['results'])) { @@ -450,7 +450,7 @@ class PhraseaEngine implements SearchEngineInterface */ private function getSuggestions($query) { - $suggestions = array(); + $suggestions = []; if ($this->qp && isset($this->qp['main'])) { $suggestions = array_map(function ($value) use ($query) { @@ -512,7 +512,7 @@ class PhraseaEngine implements SearchEngineInterface * * @return PhraseaEngine */ - public static function create(Application $app, array $options = array()) + public static function create(Application $app, array $options = []) { return new static($app); } @@ -542,7 +542,7 @@ class PhraseaEngine implements SearchEngineInterface } foreach ($this->queries as $sbas_id => $qry) { - $BF = array(); + $BF = []; foreach ($this->options->getBusinessFieldsOn() as $collection) { // limit business field query to databox local collection @@ -575,12 +575,12 @@ class PhraseaEngine implements SearchEngineInterface SET query = :query, query_time = NOW(), duration = :duration, total = :total WHERE session_id = :ses_id'; - $params = array( + $params = [ 'query' => $query, ':ses_id' => $this->app['session']->get('phrasea_session_id'), ':duration' => $total_time, ':total' => $nbanswers, - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -602,7 +602,7 @@ class PhraseaEngine implements SearchEngineInterface */ public function excerpt($query, $fields, \record_adapter $record) { - $ret = array(); + $ret = []; $this->initialize(); $this->checkSession(); @@ -613,22 +613,22 @@ class PhraseaEngine implements SearchEngineInterface ); if (!isset($res['results']) || !is_array($res['results'])) { - return array(); + return []; } $rs = $res['results']; $res = array_shift($rs); if (!isset($res['xml'])) { - return array(); + return []; } $sxe = @simplexml_load_string($res['xml']); foreach ($fields as $name => $field) { if ($sxe && $sxe->description && $sxe->description->$name) { - $val = array(); + $val = []; foreach ($sxe->description->$name as $value) { - $val[] = str_replace(array('[[em]]', '[[/em]]'), array('', ''), (string) $value); + $val[] = str_replace(['[[em]]', '[[/em]]'], ['', ''], (string) $value); } $separator = $field['separator'] ? $field['separator'][0] : ''; $val = implode(' ' . $separator . ' ', $val); @@ -648,7 +648,7 @@ class PhraseaEngine implements SearchEngineInterface public function resetCache() { $this->resetCacheNextQuery = true; - $this->queries = $this->arrayq = $this->colls = $this->qp = $this->needthesaurus = array(); + $this->queries = $this->arrayq = $this->colls = $this->qp = $this->needthesaurus = []; return $this; } @@ -721,7 +721,7 @@ class PhraseaEngine implements SearchEngineInterface foreach ($this->options->getDataboxes() as $databox) { $sbas_id = $databox->get_sbas_id(); - $this->colls[$sbas_id] = array(); + $this->colls[$sbas_id] = []; foreach ($databox->get_collections() as $collection) { if (in_array($collection->get_base_id(), $base_ids)) { @@ -803,7 +803,7 @@ class PhraseaEngine implements SearchEngineInterface $sql = "SELECT session_id FROM cache WHERE lastaccess <= :date"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':date' => $date->format(DATE_ISO8601))); + $stmt->execute([':date' => $date->format(DATE_ISO8601)]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php index 24002f2f79..e0f08457e2 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php @@ -21,53 +21,53 @@ use Alchemy\Phrasea\Application; */ class PhraseaEngineQueryParser { - public $ops = array( - "et" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false), - "and" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false), - "ou" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false), - "or" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false), - "sauf" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false), - "except" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false), - "pres" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true), - "near" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true), - "avant" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true), - "before" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true), - "apres" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true), - "after" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true), - "dans" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false), - "in" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false) - ); - public $opk = array( - "<" => array("NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false), - ">" => array("NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false), - "<=" => array("NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false), - ">=" => array("NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false), - "<>" => array("NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false), - "=" => array("NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false), - ":" => array("NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false) - ); - public $spw = array( - "all" => array( + public $ops = [ + "et" => ["NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false], + "and" => ["NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false], + "ou" => ["NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false], + "or" => ["NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false], + "sauf" => ["NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false], + "except" => ["NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false], + "pres" => ["NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true], + "near" => ["NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true], + "avant" => ["NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true], + "before" => ["NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true], + "apres" => ["NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true], + "after" => ["NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true], + "dans" => ["NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false], + "in" => ["NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false] + ]; + public $opk = [ + "<" => ["NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false], + ">" => ["NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false], + "<=" => ["NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false], + ">=" => ["NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false], + "<>" => ["NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false], + "=" => ["NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false], + ":" => ["NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false] + ]; + public $spw = [ + "all" => [ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false - ), - "last" => array( + ], + "last" => [ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true - ), + ], // "first" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true), // "premiers" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true), - "tout" => array( + "tout" => [ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false - ), - "derniers" => array( + ], + "derniers" => [ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true - ) - ); - public $quoted_defaultop = array( + ] + ]; + public $quoted_defaultop = [ "VALUE" => "default_avant", "NODETYPE" => PHRASEA_OP_BEFORE, "PNUM" => 0 - ); - public $defaultop = array( + ]; + public $defaultop = [ "VALUE" => "and", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL - ); + ]; public $defaultlast = 12; public $phq; public $errmsg = ""; @@ -84,7 +84,7 @@ class PhraseaEngineQueryParser * * @var array */ - public $proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array()); + public $proposals = ["QRY" => "", "BASES" => [], "QUERIES" => []]; public $app; /** @@ -121,7 +121,7 @@ class PhraseaEngineQueryParser } } - $this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array()); + $this->proposals = ["QRY" => "", "BASES" => [], "QUERIES" => []]; $this->phq = $this->mb_trim($phq, 'UTF-8'); if ($this->phq != "") { return($this->maketree(0)); @@ -377,13 +377,13 @@ class PhraseaEngineQueryParser if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS")) { // on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6)) - $tmp = array("CLASS" => $tree["CLASS"], + $tmp = ["CLASS" => $tree["CLASS"], "NODETYPE" => $tree["NODETYPE"], "VALUE" => $tree["VALUE"], "PNUM" => $tree["PNUM"], "LB" => $tree["LB"], "RB" => $tree["RB"]["RB"], - "DEPTH" => $tree["LB"]["DEPTH"]); + "DEPTH" => $tree["LB"]["DEPTH"]]; $t = $tree["RB"]; $tree["RB"] = $t["LB"]; $t["LB"] = $tree; @@ -403,7 +403,7 @@ class PhraseaEngineQueryParser } if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"])) { - $tids = array(); + $tids = []; foreach ($tree["SREF"]["TIDS"] as $tid) { if ($tid["bid"] == $bid) $tids[] = $tid["pid"]; @@ -422,7 +422,7 @@ class PhraseaEngineQueryParser $tree["VALUE"] = array("^" . $val); } */ - $tree["VALUE"] = array(); + $tree["VALUE"] = []; foreach ($tids as $tid) $tree["VALUE"][] = str_replace(".", "d", $tid) . "d%";; } else { @@ -506,26 +506,26 @@ class PhraseaEngineQueryParser } if ($keepFullText) { // on fait un OU entre la recherche ft et une recherche th - $tmp = array("CLASS" => "OPS", + $tmp = ["CLASS" => "OPS", "NODETYPE" => PHRASEA_OP_OR, "VALUE" => "OR", "PNUM" => null, "DEPTH" => $simple["DEPTH"], "LB" => $simple, - "RB" => array("CLASS" => "OPK", + "RB" => ["CLASS" => "OPK", "NODETYPE" => PHRASEA_OP_COLON, "VALUE" => ":", // "CONTEXT"=>$context, "PNUM" => null, "DEPTH" => $simple["DEPTH"] + 1, - "LB" => array("CLASS" => "SIMPLE", + "LB" => ["CLASS" => "SIMPLE", "NODETYPE" => PHRASEA_KEYLIST, - "VALUE" => array("*"), + "VALUE" => ["*"], "DEPTH" => $simple["DEPTH"] + 2 - ), + ], "RB" => $simple - ) - ); + ] + ]; // on vire le contexte du coté fulltext unset($tmp["LB"]["CONTEXT"]); // ajoute le contexte si nécéssaire @@ -542,19 +542,19 @@ class PhraseaEngineQueryParser $tmp["RB"]["RB"]["PATH"] = $path; } else { // on remplace le ft par du th - $tmp = array("CLASS" => "OPK", + $tmp = ["CLASS" => "OPK", "NODETYPE" => PHRASEA_OP_COLON, "VALUE" => ":", // "CONTEXT"=>$context, "PNUM" => null, "DEPTH" => $simple["DEPTH"] + 1, - "LB" => array("CLASS" => "SIMPLE", + "LB" => ["CLASS" => "SIMPLE", "NODETYPE" => PHRASEA_KEYLIST, - "VALUE" => array("*"), + "VALUE" => ["*"], "DEPTH" => $simple["DEPTH"] + 1 - ), + ], "RB" => $simple - ); + ]; // ajoute le contexte si nécéssaire if ($context !== null) $tmp["CONTEXT"] = $context; @@ -577,7 +577,7 @@ class PhraseaEngineQueryParser print("thesaurus2:\n\$tree=" . var_export($tree, true) . "\n"); if ($depth == 0) - $this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array()); + $this->proposals["BASES"]["b$bid"] = ["BID" => $bid, "NAME" => $name, "TERMS" => []]; if (!$tree) { return(0); @@ -597,14 +597,14 @@ class PhraseaEngineQueryParser public function propAsHTML(&$node, &$html, $path, $depth = 0) { if ($depth > 0) { - $tsy = array(); + $tsy = []; $lngfound = "?"; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "sy") { $lng = $n->getAttribute("lng"); if (!array_key_exists($lng, $tsy)) - $tsy[$lng] = array(); - $zsy = array("v" => $n->getAttribute("v"), "w" => $n->getAttribute("w"), "k" => $n->getAttribute("k"), "lng" => $lng); + $tsy[$lng] = []; + $zsy = ["v" => $n->getAttribute("v"), "w" => $n->getAttribute("w"), "k" => $n->getAttribute("k"), "lng" => $lng]; if ($lngfound == "?" || ($lng == $this->lng && $lngfound != $lng)) { $lngfound = $lng; @@ -625,7 +625,7 @@ class PhraseaEngineQueryParser $ksug = $syfound["w"] . '(' . $syfound["k"] . ')'; $vsug = $syfound["w"] . ($syfound["k"] ? (' (' . $syfound["k"] . ')'):''); - $this->proposals['QUERIES'][$ksug] = array('value'=>$vsug, 'current'=>$node->getAttribute("marked")=="2", 'hits'=>null, 'lng'=>$syfound['lng']); + $this->proposals['QUERIES'][$ksug] = ['value'=>$vsug, 'current'=>$node->getAttribute("marked")=="2", 'hits'=>null, 'lng'=>$syfound['lng']]; $thtml = $syfound["v"]; $kjs = $syfound["k"] ? ("'" . \p4string::MakeString($syfound["k"], "js") . "'") : "null"; @@ -641,7 +641,7 @@ class PhraseaEngineQueryParser $html .= $tab . "\t" . $thtml . "\n"; } - $tsort = array(); + $tsort = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeType == XML_ELEMENT_NODE && $n->getAttribute("marked")) { // only 'te' marked $lngfound = '?'; @@ -748,7 +748,7 @@ class PhraseaEngineQueryParser $nodes = $dxp->query($x); if (!isset($tree["RB"]["SREF"]["TIDS"])) - $tree["RB"]["SREF"]["TIDS"] = array(); + $tree["RB"]["SREF"]["TIDS"] = []; if ($nodes->length >= 1) { if ($nodes->length == 1) { // on cherche un id simple, on utilisera la syntaxe sql 'like' (l'extension repérera elle méme la syntaxe car la value finira par '%') @@ -821,16 +821,16 @@ class PhraseaEngineQueryParser } } if (!$found) - $extendednode["SREF"]["TIDS"][] = array("bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p); + $extendednode["SREF"]["TIDS"][] = ["bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p]; // on liste les propositions de thésaurus pour ce node (dans l'arbre simple) if (!isset($this->proposals["BASES"]["b$bid"]["TERMS"][$path])) { - // $this->proposals["TERMS"][$path] = array("TERM"=>implode(" ", $extendednode["VALUE"]), "PROPOSALS"=>array()); + // $this->proposals["TERMS"][$path] = array("TERM"=>implode(" ", $extendednode["VALUE"]), "PROPOSALS"=>[]); $term = implode(" ", $extendednode["VALUE"]); if (isset($extendednode["CONTEXT"]) && $extendednode["CONTEXT"]) { $term .= " (" . $extendednode["CONTEXT"] . ")"; } - $this->proposals["BASES"]["b$bid"]["TERMS"][$path] = array("TERM" => $term); // , "PROPOSALS"=>array() ); //, "PROPOSALS_TREE"=>new DOMDocument("1.0", "UTF-8")); + $this->proposals["BASES"]["b$bid"]["TERMS"][$path] = ["TERM" => $term]; // , "PROPOSALS"=>[] ); //, "PROPOSALS_TREE"=>new DOMDocument("1.0", "UTF-8")); } // printf("<%s id='%s'>
\n", $DOMnode->tagName, $DOMnode->getAttribute("id")); // printf("found node <%s id='%s' w='%s' k='%s'>
\n", $DOMnode->nodeName, $DOMnode->getAttribute('id'), $DOMnode->getAttribute('w'), $DOMnode->getAttribute('k')); @@ -854,7 +854,7 @@ class PhraseaEngineQueryParser public function astext_ambigu($tree, &$ambiguites, $mouseCallback = "void", $depth = 0) { if ($depth == 0) { - $ambiguites = array("n" => 0, "refs" => array()); + $ambiguites = ["n" => 0, "refs" => []]; } switch ($tree["CLASS"]) { case "SIMPLE": @@ -914,7 +914,7 @@ class PhraseaEngineQueryParser } if ($depth == 0) { - $t_ambiguites = array(); + $t_ambiguites = []; $r = ($this->astext_ambigu($tree, $t_ambiguites, $mouseCallback)); $t_ambiguites["query"] = $r; @@ -984,26 +984,26 @@ class PhraseaEngineQueryParser $pnum++; } else { if ($treetmp == null) { - $treetmp = array("CLASS" => $tree["CLASS"], + $treetmp = ["CLASS" => $tree["CLASS"], "NODETYPE" => $tree["NODETYPE"], "VALUE" => $tree["VALUE"][$i], "PNUM" => $tree["PNUM"], - "DEPTH" => $tree["DEPTH"]); + "DEPTH" => $tree["DEPTH"]]; $pnum = 0; } else { $dop = $tree["CLASS"] == "QSIMPLE" ? $this->quoted_defaultop : $this->defaultop; - $treetmp = array("CLASS" => "OPS", + $treetmp = ["CLASS" => "OPS", "VALUE" => $dop["VALUE"], "NODETYPE" => $dop["NODETYPE"], "PNUM" => $pnum, // peut-être écrasé par defaultop "DEPTH" => $depth, "LB" => $treetmp, - "RB" => array("CLASS" => $tree["CLASS"], + "RB" => ["CLASS" => $tree["CLASS"], "NODETYPE" => $tree["NODETYPE"], "VALUE" => $tree["VALUE"][$i], "PNUM" => $tree["PNUM"], - "DEPTH" => $tree["DEPTH"]) - ); + "DEPTH" => $tree["DEPTH"]] + ]; if (array_key_exists("PNUM", $dop)) $treetmp["PNUM"] = $dop["PNUM"]; $pnum = 0; @@ -1031,7 +1031,7 @@ class PhraseaEngineQueryParser if ($tree["NODETYPE"] == PHRASEA_OP_OR && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE") && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE")) { $tree["CLASS"] = "SIMPLE"; $tree["NODETYPE"] = PHRASEA_KEYLIST; - $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : array($tree["LB"]["VALUE"]); + $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : [$tree["LB"]["VALUE"]]; if (is_array($tree["RB"]["VALUE"])) { foreach ($tree["RB"]["VALUE"] as $v) $tree["VALUE"][] = $v; @@ -1094,41 +1094,41 @@ class PhraseaEngineQueryParser ## creation branche gauche avec ">=" // print("changeNodeEquals2\n"); // print("creation branche gauche ( '>=' ) \n"); - $newTreeLB = array("CLASS" => "OPK", + $newTreeLB = ["CLASS" => "OPK", "VALUE" => ">=", "NODETYPE" => PHRASEA_OP_GEQT, "PNUM" => NULL, "DEPTH" => 0, "LB" => $oneBranch["LB"], - "RB" => array("CLASS" => "SIMPLE", + "RB" => ["CLASS" => "SIMPLE", "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], false), "NODETYPE" => PHRASEA_KEYLIST, "PNUM" => NULL, - "DEPTH" => 0) - ); + "DEPTH" => 0] + ]; - $newTreeRB = array("CLASS" => "OPK", + $newTreeRB = ["CLASS" => "OPK", "VALUE" => "<=", "NODETYPE" => PHRASEA_OP_LEQT, "PNUM" => NULL, "DEPTH" => 0, "LB" => $oneBranch["LB"], - "RB" => array("CLASS" => "SIMPLE", + "RB" => ["CLASS" => "SIMPLE", "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], true), "NODETYPE" => PHRASEA_KEYLIST, "PNUM" => NULL, - "DEPTH" => 0) - ); + "DEPTH" => 0] + ]; // print("fin creation branche droite avec '<=' \n"); ## fin creation branche droite ( "<=" ) - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL, "DEPTH" => 0, "LB" => $newTreeLB, - "RB" => $newTreeRB); + "RB" => $newTreeRB]; return $tree; } @@ -1282,7 +1282,7 @@ class PhraseaEngineQueryParser public function distrib_in(&$tree, $depth = 0) { - $opdistrib = array(PHRASEA_OP_AND, PHRASEA_OP_OR, PHRASEA_OP_EXCEPT, PHRASEA_OP_NEAR, PHRASEA_OP_BEFORE, PHRASEA_OP_AFTER); // ces opérateurs sont 'distribuables' autour d'un 'IN' + $opdistrib = [PHRASEA_OP_AND, PHRASEA_OP_OR, PHRASEA_OP_EXCEPT, PHRASEA_OP_NEAR, PHRASEA_OP_BEFORE, PHRASEA_OP_AFTER]; // ces opérateurs sont 'distribuables' autour d'un 'IN' if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") { if ($tree["NODETYPE"] == PHRASEA_OP_IN || $tree["CLASS"] == "OPK") { @@ -1308,12 +1308,12 @@ class PhraseaEngineQueryParser $tree["LB"]["VALUE"] = $m_v; $tree["LB"]["PNUM"] = $m_n; - $tree["RB"] = array("CLASS" => $m_t, + $tree["RB"] = ["CLASS" => $m_t, "NODETYPE" => $m_o, "VALUE" => $m_v, "PNUM" => $m_n, "LB" => $tree["LB"]["RB"], - "RB" => $tree["RB"]); + "RB" => $tree["RB"]]; $tree["LB"]["RB"] = $tree["RB"]["RB"]; // return; @@ -1338,12 +1338,12 @@ class PhraseaEngineQueryParser $tree["RB"]["VALUE"] = $m_v; $tree["RB"]["PNUM"] = $m_n; - $tree["LB"] = array("CLASS" => $m_t, + $tree["LB"] = ["CLASS" => $m_t, "NODETYPE" => $m_o, "VALUE" => $m_v, "PNUM" => $m_n, "LB" => $tree["LB"], - "RB" => $tree["RB"]["LB"]); + "RB" => $tree["RB"]["LB"]]; $tree["RB"]["LB"] = $tree["LB"]["LB"]; } @@ -1355,7 +1355,7 @@ class PhraseaEngineQueryParser public function makequery($tree) { - $a = array($tree["NODETYPE"]); + $a = [$tree["NODETYPE"]]; switch ($tree["CLASS"]) { case "PHRASEA_KW_LAST": if ($tree["PNUM"] !== NULL) @@ -1436,13 +1436,13 @@ class PhraseaEngineQueryParser $tree = null; } else { // ici on applique l'opérateur par défaut - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => $this->defaultop["VALUE"], "NODETYPE" => $this->defaultop["NODETYPE"], "PNUM" => $this->defaultop["PNUM"], "DEPTH" => $depth, "LB" => $tree, - "RB" => $this->maketree($depth + 1)); + "RB" => $this->maketree($depth + 1)]; } } if (!$tree) { @@ -1483,13 +1483,13 @@ class PhraseaEngineQueryParser $tree = null; } else { // ici on applique l'opérateur par défaut - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => $this->defaultop["VALUE"], "NODETYPE" => $this->defaultop["NODETYPE"], "PNUM" => $this->defaultop["PNUM"], "DEPTH" => $depth, "LB" => $tree, - "RB" => $this->maketree($depth + 1, true)); + "RB" => $this->maketree($depth + 1, true)]; } } if (!$tree) { @@ -1587,7 +1587,7 @@ class PhraseaEngineQueryParser return(null); } - return(array("CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); + return(["CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null]); break; case "TOK_WORD": if ($t["CLASS"] == "TOK_WORD" && isset($this->ops[$t["VALUE"]]) && !$inquote) { @@ -1620,7 +1620,7 @@ class PhraseaEngineQueryParser } } - return(array("CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); + return(["CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null]); } else { // ce mot n'est pas un opérateur $pnum = null; @@ -1672,7 +1672,7 @@ class PhraseaEngineQueryParser } } if (!$tree) { - return(array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth)); + return(["CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, "DEPTH" => $depth]); } switch ($tree["CLASS"]) { case "SIMPLE": @@ -1680,24 +1680,24 @@ class PhraseaEngineQueryParser if ($type == "SIMPLE" || $type == "QSIMPLE") $tree["VALUE"][] = $t["VALUE"]; else { - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, - "RB" => array("CLASS" => $type, + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), + "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, - "DEPTH" => $depth)); + "DEPTH" => $depth]]; } return($tree); case "OPS": case "OPK": if ($tree["RB"] == null) { - $tree["RB"] = array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth); + $tree["RB"] = ["CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, "DEPTH" => $depth]; return($tree); } else { @@ -1707,43 +1707,43 @@ class PhraseaEngineQueryParser return($tree); } if (($tree["RB"]["CLASS"] == "PHRASEA_KW_LAST" || $tree["RB"]["CLASS"] == "PHRASEA_KW_ALL") && $tree["RB"]["DEPTH"] == $depth) { - $tree["RB"] = array("CLASS" => "OPS", + $tree["RB"] = ["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => null, "DEPTH" => $depth, "LB" => $tree["RB"], - "RB" => array("CLASS" => $type, + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), + "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, - "DEPTH" => $depth)); + "DEPTH" => $depth]]; return($tree); } - return(array("CLASS" => "OPS", + return(["CLASS" => "OPS", "VALUE" => $this->defaultop["VALUE"], "NODETYPE" => $this->defaultop["NODETYPE"], "PNUM" => $this->defaultop["PNUM"], "DEPTH" => $depth, "LB" => $tree, - "RB" => array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth) - )); + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, "DEPTH" => $depth] + ]); } case "PHRASEA_KW_LAST": case "PHRASEA_KW_ALL": - return(array("CLASS" => "OPS", + return(["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, - "RB" => array("CLASS" => $type, + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), + "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, - "DEPTH" => $depth))); + "DEPTH" => $depth]]); } } @@ -1764,7 +1764,7 @@ class PhraseaEngineQueryParser if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $c2 = $c . substr($this->phq, 1, 1); if ($c2 == "<=" || $c2 == ">=" || $c2 == "<>") { @@ -1774,47 +1774,47 @@ class PhraseaEngineQueryParser $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); } - return(array("CLASS" => "TOK_CMP", "VALUE" => $c)); + return(["CLASS" => "TOK_CMP", "VALUE" => $c]); break; case "=": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_CMP", "VALUE" => "=")); + return(["CLASS" => "TOK_CMP", "VALUE" => "="]); break; case ":": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_CMP", "VALUE" => ":")); + return(["CLASS" => "TOK_CMP", "VALUE" => ":"]); break; case "(": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_LP", "VALUE" => "(")); + return(["CLASS" => "TOK_LP", "VALUE" => "("]); break; case ")": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_RP", "VALUE" => ")")); + return(["CLASS" => "TOK_RP", "VALUE" => ")"]); break; case "[": // if($inquote) @@ -1833,7 +1833,7 @@ class PhraseaEngineQueryParser } $context = $this->app['unicode']->remove_indexer_chars($context); - return(array("CLASS" => "TOK_CONTEXT", "VALUE" => $context)); + return(["CLASS" => "TOK_CONTEXT", "VALUE" => $context]); break; /* case "]": @@ -1850,7 +1850,7 @@ class PhraseaEngineQueryParser case "\"": $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_QUOTE", "VALUE" => "\"")); + return(["CLASS" => "TOK_QUOTE", "VALUE" => "\""]); break; default: $l = mb_strlen($this->phq, 'UTF-8'); @@ -1865,7 +1865,7 @@ class PhraseaEngineQueryParser break; } // if ($c_utf8 == "(" || $c_utf8 == ")" || $c_utf8 == "[" || $c_utf8 == "]" || $c_utf8 == "=" || $c_utf8 == ":" || $c_utf8 == "<" || $c_utf8 == ">" || $c_utf8 == "\"") - if (in_array($c_utf8, array("(", ")", "[", "]", "=", ":", "<", ">", "\""))) { + if (in_array($c_utf8, ["(", ")", "[", "]", "=", ":", "<", ">", "\""])) { // ces caractéres sont des délimiteurs avec un sens, il faut les garder $this->phq = $this->mb_ltrim(mb_substr($this->phq, $i, 99999, 'UTF-8'), 'UTF-8'); } else { @@ -1873,9 +1873,9 @@ class PhraseaEngineQueryParser $this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8'); } if ($t != "") { - return(array("CLASS" => "TOK_WORD", "VALUE" => $t)); + return(["CLASS" => "TOK_WORD", "VALUE" => $t]); } else { - return(array("CLASS" => "TOK_VOID", "VALUE" => $t)); + return(["CLASS" => "TOK_VOID", "VALUE" => $t]); } break; } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php index ba669fee48..621bf619dd 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php @@ -238,5 +238,5 @@ interface SearchEngineInterface * @param Application $app * @param array $options */ - public static function create(Application $app, array $options = array()); + public static function create(Application $app, array $options = []); } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php index 69d5c34f73..9151893caa 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php @@ -33,7 +33,7 @@ class SearchEngineLogger $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':log_id' => $this->app['phraseanet.logger']($databox)->get_id(), ':date' => date("Y-m-d H:i:s"), ':query' => $query, @@ -41,7 +41,7 @@ class SearchEngineLogger ':colls' => implode(',', array_map(function ($coll_id) { return (int) $coll_id; }, $coll_ids)), - )); + ]); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php index 62b2b4b115..38cc7b7a2f 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php @@ -46,19 +46,19 @@ class SearchEngineOptions * * @var array */ - protected $collections = array(); + protected $collections = []; /** * * @var array */ - protected $fields = array(); + protected $fields = []; /** * * @var array */ - protected $status = array(); + protected $status = []; /** * @@ -76,7 +76,7 @@ class SearchEngineOptions * * @var array */ - protected $date_fields = array(); + protected $date_fields = []; /** * @@ -101,7 +101,7 @@ class SearchEngineOptions * @var string */ protected $sort_ord = self::SORT_MODE_DESC; - protected $business_fields = array(); + protected $business_fields = []; /** * Defines locale code to use for query @@ -163,7 +163,7 @@ class SearchEngineOptions */ public function disallowBusinessFields() { - $this->business_fields = array(); + $this->business_fields = []; return $this; } @@ -284,7 +284,7 @@ class SearchEngineOptions */ public function getDataboxes() { - $databoxes = array(); + $databoxes = []; foreach ($this->collections as $collection) { $databoxes[$collection->get_databox()->get_sbas_id()] = $collection->get_databox(); @@ -320,7 +320,7 @@ class SearchEngineOptions */ public function setStatus(Array $status) { - $tmp = array(); + $tmp = []; foreach ($status as $n => $options) { if (count($options) > 1) { continue; @@ -467,17 +467,17 @@ class SearchEngineOptions */ public function serialize() { - $ret = array(); + $ret = []; foreach ($this as $key => $value) { if ($value instanceof \DateTime) { $value = $value->format(DATE_ATOM); } - if (in_array($key, array('date_fields', 'fields'))) { + if (in_array($key, ['date_fields', 'fields'])) { $value = array_map(function (\databox_field $field) { return $field->get_databox()->get_sbas_id() . '_' . $field->get_id(); }, $value); } - if (in_array($key, array('collections', 'business_fields'))) { + if (in_array($key, ['collections', 'business_fields'])) { $value = array_map(function ($collection) { return $collection->get_base_id(); }, $value); @@ -516,19 +516,19 @@ class SearchEngineOptions case is_null($value): $value = null; break; - case in_array($key, array('date_min', 'date_max')): + case in_array($key, ['date_min', 'date_max']): $value = \DateTime::createFromFormat(DATE_ATOM, $value); break; case $value instanceof stdClass: $tmpvalue = (array) $value; - $value = array(); + $value = []; foreach ($tmpvalue as $k => $data) { $k = ctype_digit($k) ? (int) $k : $k; $value[$k] = $data; } break; - case in_array($key, array('date_fields', 'fields')): + case in_array($key, ['date_fields', 'fields']): $value = array_map(function ($serialized) use ($app) { $data = explode('_', $serialized); @@ -536,7 +536,7 @@ class SearchEngineOptions return \collection::get_from_base_id($app, $base_id); }, $value); break; - case in_array($key, array('collections', 'business_fields')): + case in_array($key, ['collections', 'business_fields']): $value = array_map(function ($base_id) use ($app) { return \collection::get_from_base_id($app, $base_id); }, $value); @@ -637,7 +637,7 @@ class SearchEngineOptions } }); - $databoxes = array(); + $databoxes = []; foreach ($bas as $collection) { if (!isset($databoxes[$collection->get_sbas_id()])) { @@ -653,10 +653,10 @@ class SearchEngineOptions $options->allowBusinessFieldsOn($BF); } - $status = is_array($request->get('status')) ? $request->get('status') : array(); - $fields = is_array($request->get('fields')) ? $request->get('fields') : array(); + $status = is_array($request->get('status')) ? $request->get('status') : []; + $fields = is_array($request->get('fields')) ? $request->get('fields') : []; - $databoxFields = array(); + $databoxFields = []; foreach ($databoxes as $databox) { foreach ($fields as $field) { @@ -690,7 +690,7 @@ class SearchEngineOptions $options->setMinDate($min_date); $options->setMaxDate($max_date); - $databoxDateFields = array(); + $databoxDateFields = []; foreach ($databoxes as $databox) { foreach (explode('|', $request->get('date_field')) as $field) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php index 172cf271eb..bf3131021d 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php @@ -73,9 +73,9 @@ class SearchEngineSuggestion */ public function toArray() { - return array( + return [ 'query' => $this->getSuggestion(), 'hits' => $this->getHits(), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php index 4738b3eb92..3584c402a0 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php @@ -45,12 +45,12 @@ class ConfigurationPanel extends AbstractConfigurationPanel { $configuration = $this->getConfiguration(); - $params = array( + $params = [ 'configuration' => $configuration, 'configfile' => $this->generateSphinxConf($app['phraseanet.appbox']->get_databoxes(), $configuration), 'charsets' => $this->getAvailableCharsets(), 'date_fields' => $this->getAvailableDateFields($app['phraseanet.appbox']->get_databoxes()), - ); + ]; return $app['twig']->render('admin/search-engine/sphinx-search.html.twig', $params); } @@ -61,13 +61,13 @@ class ConfigurationPanel extends AbstractConfigurationPanel public function post(Application $app, Request $request) { $configuration = $this->getConfiguration(); - $configuration['charset_tables'] = array(); - $configuration['date_fields'] = array(); + $configuration['charset_tables'] = []; + $configuration['date_fields'] = []; - foreach ($request->request->get('charset_tables', array()) as $table) { + foreach ($request->request->get('charset_tables', []) as $table) { $configuration['charset_tables'][] = $table; } - foreach ($request->request->get('date_fields', array()) as $field) { + foreach ($request->request->get('date_fields', []) as $field) { $configuration['date_fields'][] = $field; } @@ -86,7 +86,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : array(); + $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; return self::populateConfiguration($configuration); } @@ -114,7 +114,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel return $this->charsets; } - $this->charsets = array(); + $this->charsets = []; $finder = new Finder(); $finder->in(__DIR__ . '/Charset/')->files()->name('*.php'); @@ -208,7 +208,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel $index_crc = $this->searchEngine->CRCdatabox($databox); - $date_selects = $date_left_joins = $date_fields = array(); + $date_selects = $date_left_joins = $date_fields = []; foreach ($configuration['date_fields'] as $name) { $field = $databox->get_meta_structure()->get_element_by_name($name); @@ -738,13 +738,13 @@ searchd */ public static function populateConfiguration(array $configuration) { - return array_replace(array( - 'charset_tables' => array("common", "latin"), - 'date_fields' => array(), + return array_replace([ + 'charset_tables' => ["common", "latin"], + 'date_fields' => [], 'host' => '127.0.0.1', 'port' => 9312, 'rt_host' => '127.0.0.1', 'rt_port' => 9306, - ), $configuration); + ], $configuration); } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php index 6aeb06d832..1500ecc922 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php @@ -123,11 +123,11 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function getAvailableSort() { - return array( + return [ 'relevance' => _('pertinence'), 'created_on' => _('date dajout'), 'random' => _('aleatoire'), - ); + ]; } /** @@ -135,10 +135,10 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function getAvailableOrder() { - return array( + return [ 'desc' => _('descendant'), 'asc' => _('ascendant'), - ); + ]; } /** @@ -195,7 +195,7 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function getAvailableTypes() { - return array(self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY); + return [self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY]; } /** @@ -207,8 +207,8 @@ class SphinxSearchEngine implements SearchEngineInterface throw new RuntimeException('Unable to connect to sphinx real-time index'); } - $all_datas = array(); - $status = array(); + $all_datas = []; + $status = []; $binStatus = strrev($record->get_status()); @@ -220,13 +220,13 @@ class SphinxSearchEngine implements SearchEngineInterface $sql_date_fields = $this->getSqlDateFields($record); - $indexes = array( + $indexes = [ "metas_realtime" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_fr_" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_nl_" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_de_" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_en_" . $this->CRCdatabox($record->get_databox()), - ); + ]; foreach ($record->get_caption()->get_fields(null, true) as $field) { if (!$field->is_indexable()) { @@ -263,13 +263,13 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $indexes = array( + $indexes = [ "docs_realtime" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_fr_" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_nl_" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_en_" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_de_" . $this->CRCdatabox($record->get_databox()), - ); + ]; foreach ($indexes as $index) { $this->rt_conn->exec("REPLACE INTO " @@ -303,27 +303,27 @@ class SphinxSearchEngine implements SearchEngineInterface } $CRCdatabox = $this->CRCdatabox($record->get_databox()); - $indexes = array( + $indexes = [ "metadatas" . $CRCdatabox, "metadatas" . $CRCdatabox . "_stemmed_en", "metadatas" . $CRCdatabox . "_stemmed_fr", "metadatas" . $CRCdatabox . "_stemmed_de", "metadatas" . $CRCdatabox . "_stemmed_nl", - ); - $RTindexes = array( + ]; + $RTindexes = [ "metas_realtime" . $CRCdatabox, "metas_realtime_stemmed_fr_" . $CRCdatabox, "metas_realtime_stemmed_en_" . $CRCdatabox, "metas_realtime_stemmed_nl_" . $CRCdatabox, "metas_realtime_stemmed_de_" . $CRCdatabox, - ); + ]; foreach ($record->get_caption()->get_fields(null, true) as $field) { foreach ($field->get_values() as $value) { foreach ($indexes as $index) { - $this->sphinx->UpdateAttributes($index, array("deleted"), array($value->getId() => array(1))); + $this->sphinx->UpdateAttributes($index, ["deleted"], [$value->getId() => [1]]); } foreach ($RTindexes as $index) { @@ -332,23 +332,23 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $indexes = array( + $indexes = [ "documents" . $CRCdatabox, "documents" . $CRCdatabox . "_stemmed_fr", "documents" . $CRCdatabox . "_stemmed_en", "documents" . $CRCdatabox . "_stemmed_de", "documents" . $CRCdatabox . "_stemmed_nl" - ); - $RTindexes = array( + ]; + $RTindexes = [ "docs_realtime" . $CRCdatabox, "docs_realtime_stemmed_fr_" . $CRCdatabox, "docs_realtime_stemmed_en_" . $CRCdatabox, "docs_realtime_stemmed_nl_" . $CRCdatabox, "docs_realtime_stemmed_de_" . $CRCdatabox, - ); + ]; foreach ($indexes as $index) { - $this->sphinx->UpdateAttributes($index, array("deleted"), array($record->get_record_id() => array(1))); + $this->sphinx->UpdateAttributes($index, ["deleted"], [$record->get_record_id() => [1]]); } foreach ($RTindexes as $index) { @@ -461,7 +461,7 @@ class SphinxSearchEngine implements SearchEngineInterface $preg = preg_match('/\s?(recordid|storyid)\s?=\s?([0-9]+)/i', $query, $matches, 0, 0); if ($preg > 0) { - $this->sphinx->SetFilter('record_id', array($matches[2])); + $this->sphinx->SetFilter('record_id', [$matches[2]]); $query = ''; } @@ -483,7 +483,7 @@ class SphinxSearchEngine implements SearchEngineInterface $total = $available = $duration = 0; $suggestions = new ArrayCollection(); - $propositions = array(); + $propositions = []; } else { $error = $res['error']; $warning = $res['warning']; @@ -551,12 +551,12 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $opts = array( + $opts = [ 'before_match' => "", 'after_match' => "", - ); + ]; - $fields_to_send = array(); + $fields_to_send = []; foreach ($fields as $k => $f) { $fields_to_send[$k] = $f['value']; @@ -578,7 +578,7 @@ class SphinxSearchEngine implements SearchEngineInterface * * @return SphinxSearchEngine */ - public static function create(Application $app, array $options = array()) + public static function create(Application $app, array $options = []) { $options = ConfigurationPanel::populateConfiguration($options); @@ -595,7 +595,7 @@ class SphinxSearchEngine implements SearchEngineInterface { return sprintf("%u", crc32( str_replace( - array('.', '%') + ['.', '%'] , '_' , sprintf('%s_%s_%s_%s', $databox->get_host(), $databox->get_port(), $databox->get_user(), $databox->get_dbname()) ) @@ -614,7 +614,7 @@ class SphinxSearchEngine implements SearchEngineInterface { $this->resetSphinx(); - $filters = array(); + $filters = []; foreach ($options->getCollections() as $collection) { $filters[] = sprintf("%u", crc32($collection->get_databox()->get_sbas_id() . '_' . $collection->get_coll_id())); @@ -622,8 +622,8 @@ class SphinxSearchEngine implements SearchEngineInterface $this->sphinx->SetFilter('crc_sbas_coll', $filters); - $this->sphinx->SetFilter('deleted', array(0)); - $this->sphinx->SetFilter('parent_record_id', array($options->getSearchType())); + $this->sphinx->SetFilter('deleted', [0]); + $this->sphinx->SetFilter('parent_record_id', [$options->getSearchType()]); if ($options->getDateFields() && ($options->getMaxDate() || $options->getMinDate())) { foreach (array_unique(array_map(function (\databox_field $field) { @@ -638,7 +638,7 @@ class SphinxSearchEngine implements SearchEngineInterface if ($options->getFields()) { - $filters = array(); + $filters = []; foreach ($options->getFields() as $field) { $filters[] = sprintf("%u", crc32($field->get_databox()->get_sbas_id() . '_' . $field->get_id())); } @@ -648,14 +648,14 @@ class SphinxSearchEngine implements SearchEngineInterface if ($options->getBusinessFieldsOn()) { - $crc_coll_business = array(); + $crc_coll_business = []; foreach ($options->getBusinessFieldsOn() as $collection) { $crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_1')); $crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_0')); } - $non_business = array(); + $non_business = []; foreach ($options->getCollections() as $collection) { foreach ($options->getBusinessFieldsOn() as $BFcollection) { @@ -672,7 +672,7 @@ class SphinxSearchEngine implements SearchEngineInterface $this->sphinx->SetFilter('crc_coll_business', $crc_coll_business); } elseif ($options->getFields()) { - $this->sphinx->SetFilter('business', array(0)); + $this->sphinx->SetFilter('business', [0]); } /** @@ -686,12 +686,12 @@ class SphinxSearchEngine implements SearchEngineInterface if (!array_key_exists($databox->get_sbas_id(), $status_opts[$n])) continue; $crc = sprintf("%u", crc32($databox->get_sbas_id() . '_' . $n)); - $this->sphinx->SetFilter('status', array($crc), ($status_opts[$n][$databox->get_sbas_id()] == '0')); + $this->sphinx->SetFilter('status', [$crc], ($status_opts[$n][$databox->get_sbas_id()] == '0')); } } if ($options->getRecordType()) { - $this->sphinx->SetFilter('crc_type', array(sprintf("%u", crc32($options->getRecordType())))); + $this->sphinx->SetFilter('crc_type', [sprintf("%u", crc32($options->getRecordType()))]); } $order = ''; @@ -727,7 +727,7 @@ class SphinxSearchEngine implements SearchEngineInterface { $configuration = $this->getConfiguration(); - $sql_fields = array(); + $sql_fields = []; foreach ($configuration['date_fields'] as $field_name) { @@ -756,7 +756,7 @@ class SphinxSearchEngine implements SearchEngineInterface */ private function cleanupQuery($query) { - return str_replace(array("all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-", "+"), ' ', $query); + return str_replace(["all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-", "+"], ' ', $query); } /** @@ -770,7 +770,7 @@ class SphinxSearchEngine implements SearchEngineInterface // First we split the query into simple words $words = explode(" ", $this->cleanupQuery(mb_strtolower($query))); - $tmpWords = array(); + $tmpWords = []; foreach ($words as $word) { if (trim($word) === '') { @@ -781,10 +781,10 @@ class SphinxSearchEngine implements SearchEngineInterface $words = array_unique($tmpWords); - $altVersions = array(); + $altVersions = []; foreach ($words as $word) { - $altVersions[$word] = array($word); + $altVersions[$word] = [$word]; } // As we got words, we look for alternate word for each of them @@ -814,10 +814,10 @@ class SphinxSearchEngine implements SearchEngineInterface } // We now build an array of all possibilities based on the original query - $queries = array($query); + $queries = [$query]; foreach ($altVersions as $word => $versions) { - $tmp_queries = array(); + $tmp_queries = []; foreach ($versions as $version) { foreach ($queries as $alt_query) { $tmp_queries[] = $alt_query; @@ -828,7 +828,7 @@ class SphinxSearchEngine implements SearchEngineInterface $queries = array_unique(array_merge($queries, $tmp_queries)); } - $suggestions = array(); + $suggestions = []; $max_results = 0; foreach ($queries as $alt_query) { @@ -842,7 +842,7 @@ class SphinxSearchEngine implements SearchEngineInterface } } - usort($suggestions, array('self', 'suggestionsHitSorter')); + usort($suggestions, ['self', 'suggestionsHitSorter']); $tmpSuggestions = new ArrayCollection(); foreach ($suggestions as $key => $suggestion) { @@ -891,7 +891,7 @@ class SphinxSearchEngine implements SearchEngineInterface $this->suggestionClient->SetSortMode(SPH_SORT_EXTENDED, "@weight DESC"); $this->suggestionClient->SetLimits(0, 10); - $indexes = array(); + $indexes = []; foreach ($this->options->getDataboxes() as $databox) { $indexes[] = 'suggest' . $this->CRCdatabox($databox); @@ -901,14 +901,14 @@ class SphinxSearchEngine implements SearchEngineInterface $res = $this->suggestionClient->Query($query, $index); if ($this->suggestionClient->Status() === false) { - return array(); + return []; } if (!$res || !isset($res["matches"])) { - return array(); + return []; } - $words = array(); + $words = []; foreach ($res["matches"] as $match) { $words[] = $match['attrs']['keyword']; } @@ -920,7 +920,7 @@ class SphinxSearchEngine implements SearchEngineInterface { $index = '*'; - $index_keys = array(); + $index_keys = []; foreach ($this->options->getDataboxes() as $databox) { $index_keys[] = $this->CRCdatabox($databox); @@ -976,9 +976,9 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $query = str_ireplace(array(' ou ', ' or '), '|', $query); - $query = str_ireplace(array(' sauf ', ' except '), ' -', $query); - $query = str_ireplace(array(' and ', ' et '), ' +', $query); + $query = str_ireplace([' ou ', ' or '], '|', $query); + $query = str_ireplace([' sauf ', ' except '], ' -', $query); + $query = str_ireplace([' and ', ' et '], ' +', $query); return $query; } @@ -1019,7 +1019,7 @@ class SphinxSearchEngine implements SearchEngineInterface protected function BuildDictionarySQL($dictionnary, $threshold) { - $out = array(); + $out = []; $n = 1; $lines = explode("\n", $dictionnary); diff --git a/lib/Alchemy/Phrasea/Security/Firewall.php b/lib/Alchemy/Phrasea/Security/Firewall.php index fad8a1eb9e..ee065b5520 100644 --- a/lib/Alchemy/Phrasea/Security/Firewall.php +++ b/lib/Alchemy/Phrasea/Security/Firewall.php @@ -16,9 +16,9 @@ class Firewall public function requireSetUp() { if (!$this->app['phraseanet.configuration-tester']->isInstalled()) { - $this->app->abort(302, 'Phraseanet is not installed', array( + $this->app->abort(302, 'Phraseanet is not installed', [ 'X-Phraseanet-Redirect' => $this->app->path('setup') - )); + ]); } return null; @@ -115,9 +115,9 @@ class Firewall public function requireAuthentication() { if (!$this->app['authentication']->isAuthenticated()) { - $this->app->abort(302, 'You are not authenticated', array( + $this->app->abort(302, 'You are not authenticated', [ 'X-Phraseanet-Redirect' => $this->app->path('homepage') - )); + ]); } return $this; @@ -126,9 +126,9 @@ class Firewall public function requireNotAuthenticated() { if ($this->app['authentication']->isAuthenticated()) { - $this->app->abort(302, 'You are authenticated', array( + $this->app->abort(302, 'You are authenticated', [ 'X-Phraseanet-Redirect' => $this->app->path('prod') - )); + ]); } return $this; @@ -136,7 +136,7 @@ class Firewall public function requireOrdersAdmin() { - if (false === !!count($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('order_master')))) { + if (false === !!count($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['order_master']))) { $this->app->abort(403, 'You are not an order admin'); } diff --git a/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php b/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php index 39c96a37bc..42972cbf6b 100644 --- a/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php +++ b/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php @@ -39,11 +39,11 @@ class ConfigurationTester { $this->app = $app; - $this->versionProbes = array( + $this->versionProbes = [ new Probe31($this->app), new Probe35($this->app), new Probe38($this->app), - ); + ]; } public function getRequirements() @@ -52,7 +52,7 @@ class ConfigurationTester return $this->requirements; } - $this->requirements = array( + $this->requirements = [ BinariesProbe::create($this->app), CacheServerProbe::create($this->app), DataboxStructureProbe::create($this->app), @@ -64,7 +64,7 @@ class ConfigurationTester SearchEngineProbe::create($this->app), SubdefsPathsProbe::create($this->app), SystemProbe::create($this->app), - ); + ]; return $this->requirements; } @@ -136,7 +136,7 @@ class ConfigurationTester public function getMigrations() { - $migrations = array(); + $migrations = []; if ($this->isUpToDate()) { return $migrations; diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php index 6dd2131c17..6f390e48a0 100644 --- a/lib/Alchemy/Phrasea/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Setup/Installer.php @@ -24,7 +24,7 @@ class Installer $this->app = $app; } - public function install($email, $password, \connection_interface $abConn, $serverName, $dataPath, \connection_interface $dbConn = null, $template = null, array $binaryData = array()) + public function install($email, $password, \connection_interface $abConn, $serverName, $dataPath, \connection_interface $dbConn = null, $template = null, array $binaryData = []) { $this->rollbackInstall($abConn, $dbConn); @@ -79,27 +79,27 @@ class Installer $template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $template . '-simple.xml'); $databox = \databox::create($this->app, $dbConn, $template, $this->app['phraseanet.registry']); $this->app['acl']->get($this->app['authentication']->getUser()) - ->give_access_to_sbas(array($databox->get_sbas_id())) + ->give_access_to_sbas([$databox->get_sbas_id()]) ->update_rights_to_sbas( - $databox->get_sbas_id(), array( + $databox->get_sbas_id(), [ 'bas_manage' => 1, 'bas_modify_struct' => 1, 'bas_modif_th' => 1, 'bas_chupub' => 1 - ) + ] ); $collection = \collection::create($this->app, $databox, $this->app['phraseanet.appbox'], 'test', $this->app['authentication']->getUser()); - $this->app['acl']->get($this->app['authentication']->getUser())->give_access_to_base(array($collection->get_base_id())); - $this->app['acl']->get($this->app['authentication']->getUser())->update_rights_to_base($collection->get_base_id(), array( + $this->app['acl']->get($this->app['authentication']->getUser())->give_access_to_base([$collection->get_base_id()]); + $this->app['acl']->get($this->app['authentication']->getUser())->update_rights_to_base($collection->get_base_id(), [ 'canpush' => 1, 'cancmd' => 1 , 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1 , 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1 , 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1 , 'modify_struct' => 1, 'nowatermark' => 1 - ) + ] ); - foreach (array('PhraseanetIndexer', 'Subdefs', 'WriteMetadata') as $jobName) { + foreach (['PhraseanetIndexer', 'Subdefs', 'WriteMetadata'] as $jobName) { $job = $this->app['task-manager.job-factory']->create($jobName); $this->app['manipulator.task']->create( $job->getName(), diff --git a/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php index 985520a241..e83f5d5b7f 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php @@ -18,7 +18,7 @@ class BinariesProbe extends BinariesRequirements implements ProbeInterface { public function __construct(array $binaries) { - parent::__construct(array_filter(array( + parent::__construct(array_filter([ 'php_binary' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null, 'pdf2swf_binary' => isset($binaries['pdf2swf_binary']) ? $binaries['pdf2swf_binary'] : null, 'unoconv_binary' => isset($binaries['unoconv_binary']) ? $binaries['unoconv_binary'] : null, @@ -29,7 +29,7 @@ class BinariesProbe extends BinariesRequirements implements ProbeInterface 'ffmpeg_binary' => isset($binaries['ffmpeg_binary']) ? $binaries['ffmpeg_binary'] : null, 'ffprobe_binary' => isset($binaries['ffprobe_binary']) ? $binaries['ffprobe_binary'] : null, 'recess_binary' => isset($binaries['recess_binary']) ? $binaries['recess_binary'] : null, - ))); + ])); } /** diff --git a/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php index 605cb1c2b2..addd80f127 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php @@ -22,9 +22,9 @@ class FilesystemProbe extends FilesystemRequirements implements ProbeInterface $baseDir = realpath(__DIR__ . '/../../../../../'); - $paths = array( + $paths = [ $baseDir . '/config/configuration.yml', - ); + ]; foreach ($paths as $path) { $this->addRecommendation( @@ -34,7 +34,7 @@ class FilesystemProbe extends FilesystemRequirements implements ProbeInterface ); } - $path = array(); + $path = []; if ($registry->is_set('GV_base_datapath_noweb')) { $paths[] = $registry->get('GV_base_datapath_noweb'); diff --git a/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php index 19b001b702..9317bbe8fd 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php @@ -18,9 +18,9 @@ class PhraseaProbe extends PhraseaRequirements implements ProbeInterface { public function __construct(Application $app) { - parent::__construct(array( + parent::__construct([ // here goes the custom setting - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Setup/RequirementCollection.php b/lib/Alchemy/Phrasea/Setup/RequirementCollection.php index 607352d9a7..bc48c71428 100644 --- a/lib/Alchemy/Phrasea/Setup/RequirementCollection.php +++ b/lib/Alchemy/Phrasea/Setup/RequirementCollection.php @@ -11,8 +11,8 @@ namespace Alchemy\Phrasea\Setup; */ class RequirementCollection implements RequirementCollectionInterface { - private $requirements = array(); - private $informations = array(); + private $requirements = []; + private $informations = []; private $name; /** @@ -114,7 +114,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getRequirements() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if (!$req->isOptional()) { $array[] = $req; @@ -129,7 +129,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getFailedRequirements() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if (!$req->isFulfilled() && !$req->isOptional()) { $array[] = $req; @@ -144,7 +144,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getRecommendations() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if ($req->isOptional()) { $array[] = $req; @@ -159,7 +159,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getFailedRecommendations() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if (!$req->isFulfilled() && $req->isOptional()) { $array[] = $req; diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php index 61ab381327..59cf7cd631 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php @@ -24,7 +24,7 @@ class BinariesRequirements extends RequirementCollection implements RequirementI const MP4BOX_VERSION = '0.4.0'; const EXIFTOOL_VERSION = '9.15'; - public function __construct($binaries = array()) + public function __construct($binaries = []) { $this->setName('Binaries'); diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php index 4656a5b1bc..4cdeb3088d 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php @@ -21,7 +21,7 @@ class FilesystemRequirements extends RequirementCollection implements Requiremen $this->setName('Filesystem'); - $paths = array( + $paths = [ $baseDir . '/config', $baseDir . '/config/stamp', $baseDir . '/config/status', @@ -41,7 +41,7 @@ class FilesystemRequirements extends RequirementCollection implements Requiremen $baseDir . '/tmp/desc_tmp', $baseDir . '/tmp/download', $baseDir . '/tmp/batches' - ); + ]; foreach ($paths as $path) { $this->addRequirement( diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php index 7d295782eb..830095deb5 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php @@ -19,7 +19,7 @@ class PhraseaRequirements extends RequirementCollection implements RequirementIn const PHRASEA_EXTENSION_VERSION = '1.21.1.0'; const PHRASEA_INDEXER_VERSION = '3.10.2.3'; - public function __construct($binaries = array()) + public function __construct($binaries = []) { $this->setName('Phrasea'); diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php index e7c84a4720..f7124afd55 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php @@ -48,7 +48,7 @@ class SystemRequirements extends RequirementCollection implements RequirementInt ); if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { - $timezones = array(); + $timezones = []; foreach (\DateTimeZone::listAbbreviations() as $abbreviations) { foreach ($abbreviations as $abbreviation) { $timezones[$abbreviation['timezone_id']] = true; diff --git a/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php b/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php index ee273acda6..ba164bde32 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php +++ b/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php @@ -36,21 +36,21 @@ class MailChecker $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $users = array(); + $users = []; foreach ($rs as $row) { if (!isset($users[$row['usr_mail']])) { - $users[$row['usr_mail']] = array(); + $users[$row['usr_mail']] = []; } $users[$row['usr_mail']][] = $row; } - $badUsers = array(); + $badUsers = []; foreach ($users as $email => $usrs) { if (count($usrs) > 1) { - $badUsers[$email] = array(); + $badUsers[$email] = []; foreach ($usrs as $usrInfo) { $badUsers[$email][$usrInfo['usr_id']] = $usrInfo; } diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php index 4f40d208db..0c205a4def 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php @@ -38,13 +38,13 @@ class Migration31 implements MigrationInterface $retrieve_old_credentials = function () { require __DIR__ . '/../../../../../../config/connexion.inc'; - return array( + return [ 'hostname' => $hostname, 'port' => $port, 'user' => $user, 'password' => $password, 'dbname' => $dbname, - ); + ]; }; $params = $retrieve_old_credentials(); @@ -110,19 +110,19 @@ class Migration31 implements MigrationInterface break; } - $stmt->execute(array( + $stmt->execute([ ':key' => $datas['name'], ':value' => $val, ':type' => $type, - )); + ]); } } - $stmt->execute(array( + $stmt->execute([ ':key' => 'GV_sit', ':value' => GV_sit, ':type' => \registry::TYPE_STRING, - )); + ]); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php index 66e9260c36..31e46bfe3d 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php @@ -38,13 +38,13 @@ class Migration35 implements MigrationInterface $retrieve_old_credentials = function () { require __DIR__ . '/../../../../../../config/connexion.inc'; - return array( + return [ 'hostname' => $hostname, 'port' => $port, 'user' => $user, 'password' => $password, 'dbname' => $dbname, - ); + ]; }; foreach ($retrieve_old_credentials() as $key => $value) { @@ -55,9 +55,9 @@ class Migration35 implements MigrationInterface $retrieve_old_parameters = function () { require __DIR__ . '/../../../../../../config/config.inc'; - return array( + return [ 'servername' => $servername - ); + ]; }; $old_parameters = $retrieve_old_parameters(); diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php index fb1eb3522e..f82813214a 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php @@ -58,12 +58,12 @@ class Migration38 implements MigrationInterface $app['configuration']->setConfig($conf); - foreach (array( + foreach ([ $this->configYaml, $this->connexionsYaml, $this->binariesYaml, $this->servicesYaml - ) as $file) { + ] as $file) { if (is_file($file)) { rename($file, $file.'.bkp'); } @@ -103,7 +103,7 @@ class Migration38 implements MigrationInterface if (isset($services['Cache'][$opcodeCacheService]['options'])) { $conf['main']['opcodecache']['options'] = $services['Cache'][$opcodeCacheService]['options']; } else { - $conf['main']['opcodecache']['options'] = array(); + $conf['main']['opcodecache']['options'] = []; } } if (null !== $cacheService) { @@ -111,7 +111,7 @@ class Migration38 implements MigrationInterface if (isset($services['Cache'][$cacheService]['options'])) { $conf['main']['cache']['options'] = $services['Cache'][$cacheService]['options']; } else { - $conf['main']['cache']['options'] = array(); + $conf['main']['cache']['options'] = []; } } $conf['border-manager'] = $services['Border']['border_manager']['options']; diff --git a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php index 035896f35e..f9e42b8fb2 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php +++ b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php @@ -19,7 +19,7 @@ use Alchemy\Phrasea\Application; class PreSchemaUpgradeCollection { /** @var PreSchemaUpgradeInterface[] */ - private $upgrades = array(); + private $upgrades = []; public function __construct() { diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php index 4fc9280ce8..44154c1d50 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php @@ -56,7 +56,7 @@ abstract class AbstractEditor implements EditorInterface } } - return new Response($dom->saveXML(), 200, array('Content-type' => 'text/xml')); + return new Response($dom->saveXML(), 200, ['Content-type' => 'text/xml']); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php index 7759649769..5a20eaa494 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php @@ -55,7 +55,7 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'base_id' => static::FORM_TYPE_INTEGER, 'hotfolder' => static::FORM_TYPE_STRING, 'move_archived' => static::FORM_TYPE_BOOLEAN, @@ -63,6 +63,6 @@ EOF; 'delfolder' => static::FORM_TYPE_BOOLEAN, 'copy_spe' => static::FORM_TYPE_BOOLEAN, 'cold' => static::FORM_TYPE_INTEGER, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php index a9c1e9f8f9..54d3888deb 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php @@ -45,6 +45,6 @@ EOF; protected function getFormProperties() { - return array(); + return []; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php index 343d9718e6..fa6efdddba 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php @@ -50,9 +50,9 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'proxy' => static::FORM_TYPE_STRING, 'proxyport' => static::FORM_TYPE_STRING, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php index 723836695f..6ef283074e 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php @@ -58,7 +58,7 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'proxy' => static::FORM_TYPE_STRING, 'proxyport' => static::FORM_TYPE_STRING, 'passive' => static::FORM_TYPE_BOOLEAN, @@ -69,6 +69,6 @@ EOF; 'localpath' => static::FORM_TYPE_STRING, 'port' => static::FORM_TYPE_INTEGER, 'host' => static::FORM_TYPE_STRING, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php index 316dfd2643..a36fee73bf 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php @@ -77,7 +77,7 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'host' => static::FORM_TYPE_STRING, 'port' => static::FORM_TYPE_INTEGER, 'base' => static::FORM_TYPE_STRING, @@ -91,6 +91,6 @@ EOF; 'debugmask' => static::FORM_TYPE_INTEGER, 'stem' => static::FORM_TYPE_STRING, 'sortempty' => static::FORM_TYPE_STRING, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php index 95493cbdae..31cc7443c2 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php @@ -37,7 +37,7 @@ class RecordMoverEditor extends AbstractEditor public function facility(Application $app, Request $request) { - $ret = array('tasks' => array()); + $ret = ['tasks' => []]; $job = new RecordMoverJob(); switch ($request->get('ACT')) { case 'CALCTEST': @@ -141,6 +141,6 @@ EOF; */ protected function getFormProperties() { - return array('logsql' => static::FORM_TYPE_BOOLEAN); + return ['logsql' => static::FORM_TYPE_BOOLEAN]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php index 7b5eb9b17c..6545eea93c 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php @@ -49,8 +49,8 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'embedded' => static::FORM_TYPE_BOOLEAN, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php index 2ee993f2dc..467c54cbb0 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php @@ -49,8 +49,8 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'cleardoc' => static::FORM_TYPE_BOOLEAN, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php b/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php index 8e50a92781..7e49a27bb1 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php +++ b/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php @@ -31,9 +31,9 @@ class FinishedJobRemoverSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( - JobEvents::FINISHED => array($this, 'onJobFinish'), - ); + return [ + JobEvents::FINISHED => [$this, 'onJobFinish'], + ]; } public function onJobFinish(JobFinishedEvent $event) diff --git a/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php b/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php index 0a5fdd8748..9d9f6a55f2 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php +++ b/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php @@ -29,9 +29,9 @@ class PhraseanetIndexerStopperSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( - TaskManagerEvents::STOP_REQUEST => array('onStopRequest'), - ); + return [ + TaskManagerEvents::STOP_REQUEST => ['onStopRequest'], + ]; } public function onStopRequest(JobEvent $event) diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php index 44fc0eab3f..69f4dc4c8f 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php @@ -81,7 +81,7 @@ class ArchiveJob extends AbstractJob $databox = $app['phraseanet.appbox']->get_databox($sbasId); - $TColls = array(); + $TColls = []; $collection = null; foreach ($databox->get_collections() as $coll) { $TColls['c' . $coll->get_coll_id()] = $coll->get_coll_id(); @@ -92,8 +92,8 @@ class ArchiveJob extends AbstractJob $server_coll_id = $collection->get_coll_id(); // mask(s) of accepted files - $tmask = array(); - $tmaskgrp = array(); + $tmask = []; + $tmaskgrp = []; $cold = min(max((int) $settings->cold, self::MINCOLD), self::MAXCOLD); $stat0 = $stat1 = "0"; @@ -123,26 +123,26 @@ class ArchiveJob extends AbstractJob // load masks if ($settings->files && $settings->files->file) { foreach ($settings->files->file as $ft) { - $tmask[] = array( + $tmask[] = [ "mask" => (string) $ft["mask"] , "caption" => (string) $ft["caption"] , "accept" => (string) $ft["accept"] - ); + ]; } } if ($settings->files && $settings->files->grouping) { foreach ($settings->files->grouping as $ft) { - $tmaskgrp[] = array( + $tmaskgrp[] = [ "mask" => (string) $ft["mask"] , "caption" => (string) $ft["caption"] , "representation" => (string) $ft["representation"] , "accept" => (string) $ft["accept"] - ); + ]; } } if (count($tmask) == 0) { // no mask defined : accept all kind of files - $tmask[] = array("mask" => ".*", "caption" => "", "accept" => ""); + $tmask[] = ["mask" => ".*", "caption" => "", "accept" => ""]; } while ($this->isStarted()) { @@ -282,7 +282,7 @@ class ArchiveJob extends AbstractJob $n = $node->appendChild($dom->createElement('file')); $n->setAttribute('name', $file); $stat = stat($path . '/' . $file); - foreach (array("size", "ctime", "mtime") as $k) { + foreach (["size", "ctime", "mtime"] as $k) { $n->setAttribute($k, $stat[$k]); } $nnew++; @@ -345,7 +345,7 @@ class ArchiveJob extends AbstractJob $this->listFilesPhase2($app, $dom, $dnl->item(0), $path . '/' . $file, $depth + 1); } else { $stat = stat($path . '/' . $file); - foreach (array("size", "ctime", "mtime") as $k) { + foreach (["size", "ctime", "mtime"] as $k) { if ($dnl->item(0)->getAttribute($k) != $stat[$k]) { $this->setBranchHot($dom, $dnl->item(0)); break; @@ -374,7 +374,7 @@ class ArchiveJob extends AbstractJob } // make xml lighter (free ram) - foreach (array("size", "ctime", "mtime") as $k) { + foreach (["size", "ctime", "mtime"] as $k) { $n->removeAttribute($k); } @@ -398,7 +398,7 @@ class ArchiveJob extends AbstractJob // this group in new (to be created) // do we need one (or both) linked file ? (caption or representation) $err = false; - $flink = array('caption' => null, 'representation' => null); + $flink = ['caption' => null, 'representation' => null]; foreach ($flink as $linkName => $v) { if (isset($grpSettings[$linkName]) && $grpSettings[$linkName] != '') { @@ -438,7 +438,7 @@ class ArchiveJob extends AbstractJob // something is missing, the whole group goes error, ... $n->setAttribute('grp', 'todelete'); - $this->setAllChildren($dom, $n, array('error' => '1')); + $this->setAllChildren($dom, $n, ['error' => '1']); // bubble to the top for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode) { @@ -498,7 +498,7 @@ class ArchiveJob extends AbstractJob return $ret; } - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { usleep(10); @@ -567,7 +567,7 @@ class ArchiveJob extends AbstractJob return; } - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { usleep(10); @@ -681,7 +681,7 @@ class ArchiveJob extends AbstractJob return $ret; } - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { usleep(10); @@ -1042,7 +1042,7 @@ class ArchiveJob extends AbstractJob $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas()); - $metaFields = array(); + $metaFields = []; if ($captionFile !== null && true === $app['filesystem']->exists($captionFile)) { $metaFields = $this->readXMLForDatabox($app, $metadatasStructure, $captionFile); $captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile)); @@ -1096,7 +1096,7 @@ class ArchiveJob extends AbstractJob */ private function archiveFilesToGrp(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, $grp_rid, $stat0, $stat1, $moveError, $moveArchived) { - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if (!$this->isStarted()) { break; @@ -1420,7 +1420,7 @@ class ArchiveJob extends AbstractJob $metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, $values)); } else { - $metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, array($field))); + $metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, [$field])); } } @@ -1448,7 +1448,7 @@ class ArchiveJob extends AbstractJob private function listFolder($path) { - $list = array(); + $list = []; if ($hdir = opendir($path)) { while (false !== $file = readdir($hdir)) { $list[] = $file; diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php index b925381fe5..27b3422449 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php @@ -55,13 +55,13 @@ class BridgeJob extends AbstractJob { $app = $data->getApplication(); - $status = array( + $status = [ \Bridge_Element::STATUS_PENDING, \Bridge_Element::STATUS_PROCESSING, \Bridge_Element::STATUS_PROCESSING_SERVER - ); + ]; - $params = array(); + $params = []; $n = 1; foreach ($status as $stat) { @@ -96,7 +96,7 @@ class BridgeJob extends AbstractJob $this->log('error', sprintf("An error occured : %s", $e->getMessage())); $sql = 'UPDATE bridge_elements SET status = :status WHERE id = :id'; - $params = array(':status' => \Bridge_Element::STATUS_ERROR, ':id' => $row['id']); + $params = [':status' => \Bridge_Element::STATUS_ERROR, ':id' => $row['id']]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -154,13 +154,13 @@ class BridgeJob extends AbstractJob switch ($status) { case \Bridge_Element::STATUS_ERROR: - $params = array( + $params = [ 'usr_id' => $account->get_user()->get_id(), 'reason' => $error_message, 'account_id' => $account->get_id(), 'sbas_id' => $element->get_record()->get_sbas_id(), 'record_id' => $element->get_record()->get_record_id(), - ); + ]; $app['events-manager']->trigger('__BRIDGE_UPLOAD_FAIL__', $params); break; diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php index 28f6594f3e..55b029d240 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php @@ -159,16 +159,16 @@ class FtpJob extends AbstractJob } } - $obj = array(); + $obj = []; $basefolder = ''; - if (!in_array(trim($export->getDestfolder()), array('.', './', ''))) { + if (!in_array(trim($export->getDestfolder()), ['.', './', ''])) { $basefolder = \p4string::addEndSlash($export->getDestfolder()); } $basefolder .= $export->getFoldertocreate(); - if (in_array(trim($basefolder), array('.', './', ''))) { + if (in_array(trim($basefolder), ['.', './', ''])) { $basefolder = '/'; } @@ -229,10 +229,10 @@ class FtpJob extends AbstractJob $ftp_client->put($remotefile, $localfile); - $obj[] = array( + $obj[] = [ "name" => $subdef, "size" => filesize($localfile), "shortXml" => ($sdcaption ? $sdcaption : '') - ); + ]; if ($subdef == 'caption') { unlink($localfile); @@ -340,7 +340,7 @@ class FtpJob extends AbstractJob private function send_mails(Application $app, FtpExport $export) { - $transferts = array(); + $transferts = []; $transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes'); foreach ($export->getElements() as $element) { diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php index c431db59d2..44842edf87 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php @@ -67,14 +67,14 @@ class FtpPullJob extends AbstractJob $ssl = (Boolean) (string) $settings->ssl; $passive = (Boolean) (string) $settings->passive; - foreach (array( + foreach ([ 'localpath' => $localPath, 'host' => $host, 'port' => $host, 'user' => $user, 'password' => $password, 'ftppath' => $ftpPath, - ) as $name => $value) { + ] as $name => $value) { if (trim($value) === '') { // maybe throw an exception to consider the job as failing ? $this->log('error', sprintf('setting `%s` must be set', $name)); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php index abec06b4cf..425f848032 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php @@ -101,7 +101,7 @@ class PhraseanetIndexerJob extends AbstractJob private function getCommandline($indexerPath, Application $app, Task $task) { - $cmd = array($indexerPath, '-o'); + $cmd = [$indexerPath, '-o']; $settings = simplexml_load_string($task->getSettings()); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php index 720d360df6..d8b280b638 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php @@ -123,7 +123,7 @@ class RecordMoverJob extends AbstractJob private function getData(Application $app, array $tasks, $logsql) { - $ret = array(); + $ret = []; foreach ($tasks as $sxtask) { if (!$this->isStarted()) { @@ -150,11 +150,11 @@ class RecordMoverJob extends AbstractJob $stmt = $databox->get_connection()->prepare($task['sql']['real']['sql']); $stmt->execute(); while ($this->isStarted() && false !== $row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $tmp = array( + $tmp = [ 'sbas_id' => $task['sbas_id'], 'record_id' => $row['record_id'], 'action' => $task['action'] - ); + ]; $rec = $databox->get_record($row['record_id']); switch ($task['action']) { @@ -188,7 +188,7 @@ class RecordMoverJob extends AbstractJob { $sbas_id = (int) $sxtask['sbas_id']; - $ret = array( + $ret = [ 'name' => $sxtask['name'] ? (string) $sxtask['name'] : 'sans nom', 'name_htmlencoded' => \p4string::MakeString(($sxtask['name'] ? $sxtask['name'] : 'sans nom'), 'html'), 'active' => trim($sxtask['active']) === '1', @@ -199,7 +199,7 @@ class RecordMoverJob extends AbstractJob 'sql' => null, 'err' => '', 'err_htmlencoded' => '', - ); + ]; try { $dbox = $app['phraseanet.appbox']->get_databox($sbas_id); @@ -229,7 +229,7 @@ class RecordMoverJob extends AbstractJob private function calcUPDATE(Application $app, $sbas_id, &$sxtask, $playTest) { - $tws = array(); // NEGATION of updates, used to build the 'test' sql + $tws = []; // NEGATION of updates, used to build the 'test' sql // // set coll_id ? if (($x = (int) ($sxtask->to->coll['id'])) > 0) { @@ -238,8 +238,8 @@ class RecordMoverJob extends AbstractJob // set status ? $x = $sxtask->to->status['mask']; - $mx = str_replace(' ', '0', ltrim(str_replace(array('0', 'x'), array(' ', ' '), $x))); - $ma = str_replace(' ', '0', ltrim(str_replace(array('x', '0'), array(' ', '1'), $x))); + $mx = str_replace(' ', '0', ltrim(str_replace(['0', 'x'], [' ', ' '], $x))); + $ma = str_replace(' ', '0', ltrim(str_replace(['x', '0'], [' ', '1'], $x))); if ($mx && $ma) $tws[] = '((status ^ 0b' . $mx . ') & 0b' . $ma . ')!=0'; elseif ($mx) @@ -266,18 +266,18 @@ class RecordMoverJob extends AbstractJob if (count($tw) > 0) $sql .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')'); - $ret = array( - 'real' => array( + $ret = [ + 'real' => [ 'sql' => $sql, 'sql_htmlencoded' => htmlentities($sql), - ), - 'test' => array( + ], + 'test' => [ 'sql' => $sql_test, 'sql_htmlencoded' => htmlentities($sql_test), 'result' => NULL, 'err' => NULL - ) - ); + ] + ]; if ($playTest) { $ret['test']['result'] = $this->playTest($app, $sbas_id, $sql_test); @@ -302,18 +302,18 @@ class RecordMoverJob extends AbstractJob if (count($tw) > 0) $sql .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')'); - $ret = array( - 'real' => array( + $ret = [ + 'real' => [ 'sql' => $sql, 'sql_htmlencoded' => htmlentities($sql), - ), - 'test' => array( + ], + 'test' => [ 'sql' => $sql_test, 'sql_htmlencoded' => htmlentities($sql_test), 'result' => NULL, 'err' => NULL - ) - ); + ] + ]; if ($playTest) { $ret['test']['result'] = $this->playTest($app, $sbas_id, $sql_test); @@ -325,12 +325,12 @@ class RecordMoverJob extends AbstractJob private function playTest(Application $app, $sbas_id, $sql) { $connbas = \connection::getPDOConnection($app, $sbas_id); - $result = array('rids' => array(), 'err' => '', 'n' => null); + $result = ['rids' => [], 'err' => '', 'n' => null]; $result['n'] = $connbas->query('SELECT COUNT(*) AS n FROM (' . $sql . ') AS x')->fetchColumn(); $stmt = $connbas->prepare('SELECT record_id FROM (' . $sql . ') AS x LIMIT 10'); - if ($stmt->execute(array())) { + if ($stmt->execute([])) { while (($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { $result['rids'][] = $row['record_id']; } @@ -346,7 +346,7 @@ class RecordMoverJob extends AbstractJob { $connbas = \connection::getPDOConnection($app, $sbas_id); - $tw = array(); + $tw = []; $join = ''; $ijoin = 0; @@ -367,7 +367,7 @@ class RecordMoverJob extends AbstractJob foreach ($sxtask->from->text as $x) { $ijoin++; $comp = strtoupper($x['compare']); - if (in_array($comp, array('<', '>', '<=', '>=', '=', '!='))) { + if (in_array($comp, ['<', '>', '<=', '>=', '=', '!='])) { $s = 'p' . $ijoin . '.name=\'' . $x['field'] . '\' AND p' . $ijoin . '.value' . $comp; $s .= '' . $connbas->quote($x['value']) . ''; @@ -419,8 +419,8 @@ class RecordMoverJob extends AbstractJob // criteria $x = $sxtask->from->status['mask']; - $mx = str_replace(' ', '0', ltrim(str_replace(array('0', 'x'), array(' ', ' '), $x))); - $ma = str_replace(' ', '0', ltrim(str_replace(array('x', '0'), array(' ', '1'), $x))); + $mx = str_replace(' ', '0', ltrim(str_replace(['0', 'x'], [' ', ' '], $x))); + $ma = str_replace(' ', '0', ltrim(str_replace(['x', '0'], [' ', '1'], $x))); if ($mx && $ma) { $tw[] = '((status^0b' . $mx . ')&0b' . $ma . ')=0'; } elseif ($mx) { @@ -429,6 +429,6 @@ class RecordMoverJob extends AbstractJob $tw[] = '(status&0b' . $ma . ")=0"; } - return array($tw, $join); + return [$tw, $join]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php index e39c16ece2..5ae298d45a 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php @@ -92,7 +92,7 @@ class SubdefsJob extends AbstractJob WHERE record_id=:record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $stmt->closeCursor(); // rewrite metadata @@ -101,7 +101,7 @@ class SubdefsJob extends AbstractJob jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ') WHERE record_id=:record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $stmt->closeCursor(); unset($record); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php index 1905543e83..3eb1a1b153 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php @@ -68,7 +68,7 @@ class WriteMetadataJob extends AbstractJob $connbas = $databox->get_connection(); $subdefgroups = $databox->get_subdef_structure(); - $metasubdefs = array(); + $metasubdefs = []; foreach ($subdefgroups as $type => $subdefs) { foreach ($subdefs as $sub) { @@ -96,7 +96,7 @@ class WriteMetadataJob extends AbstractJob $type = $record->get_type(); $subdefs = $record->get_subdefs(); - $tsub = array(); + $tsub = []; foreach ($subdefs as $name => $subdef) { $write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document'); @@ -137,7 +137,7 @@ class WriteMetadataJob extends AbstractJob $datas = $field->get_values(); if ($meta->is_multi()) { - $values = array(); + $values = []; foreach ($datas as $data) { $values[] = $data->getValue(); } @@ -167,7 +167,7 @@ class WriteMetadataJob extends AbstractJob $sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . ' WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $stmt->closeCursor(); } } diff --git a/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php b/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php index 099b2a31c2..384846e3f5 100644 --- a/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php +++ b/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php @@ -35,11 +35,11 @@ class LiveInformation { $data = $this->notifier->notify(Notifier::MESSAGE_INFORMATIONS); - return array( + return [ 'configuration' => $this->status->getStatus(), 'actual' => isset($data['manager']) ? TaskManagerStatus::STATUS_STARTED : TaskManagerStatus::STATUS_STOPPED, 'process-id' => isset($data['manager']) ? $data['manager']['process-id'] : null, - ); + ]; } /** @@ -50,12 +50,12 @@ class LiveInformation public function getTask(Task $task) { $data = $this->notifier->notify(Notifier::MESSAGE_INFORMATIONS); - $taskData = (isset($data['jobs']) && isset($data['jobs'][$task->getId()])) ? $data['jobs'][$task->getId()] : array(); + $taskData = (isset($data['jobs']) && isset($data['jobs'][$task->getId()])) ? $data['jobs'][$task->getId()] : []; - return array( + return [ 'configuration' => $this->status->getStatus(), 'actual' => isset($taskData['status']) ? $taskData['status'] : Task::STATUS_STOPPED, 'process-id' => isset($taskData['process-id']) ? $taskData['process-id'] : null, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Notifier.php b/lib/Alchemy/Phrasea/TaskManager/Notifier.php index 48a2e08b7c..1d8bae86a6 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Notifier.php +++ b/lib/Alchemy/Phrasea/TaskManager/Notifier.php @@ -91,7 +91,7 @@ class Notifier * * @return Notifier */ - public static function create(array $options = array()) + public static function create(array $options = []) { $context = new \ZMQContext(); $socket = $context->getSocket(\ZMQ::SOCKET_REQ); diff --git a/lib/Alchemy/Phrasea/TaskManager/TaskList.php b/lib/Alchemy/Phrasea/TaskManager/TaskList.php index 766f31b235..df78679f0c 100644 --- a/lib/Alchemy/Phrasea/TaskManager/TaskList.php +++ b/lib/Alchemy/Phrasea/TaskManager/TaskList.php @@ -36,13 +36,13 @@ class TaskList implements TaskListInterface */ public function refresh() { - return array_map(array($this, 'entityToTask'), $this->repository->findActiveTasks()); + return array_map([$this, 'entityToTask'], $this->repository->findActiveTasks()); } public function entityToTask(TaskEntity $task) { $name = $task->getId() ; - $arguments = array($this->phpExec); + $arguments = [$this->phpExec]; if ($this->phpConf) { $arguments[] = '-c'; diff --git a/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php b/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php index 11bccfb1fe..64bf49a223 100644 --- a/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php +++ b/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php @@ -78,7 +78,7 @@ class TaskManagerStatus private function ensureConfigurationSchema() { if (!isset($this->conf['task-manager'])) { - $this->conf['task-manager'] = array('status' => static::STATUS_STARTED); + $this->conf['task-manager'] = ['status' => static::STATUS_STARTED]; return; } @@ -95,6 +95,6 @@ class TaskManagerStatus private function isValidStatus($status) { - return in_array($status, array(static::STATUS_STARTED, static::STATUS_STOPPED)); + return in_array($status, [static::STATUS_STARTED, static::STATUS_STOPPED]); } } diff --git a/lib/Alchemy/Phrasea/Twig/BytesConverter.php b/lib/Alchemy/Phrasea/Twig/BytesConverter.php index fda3004dba..bf06f70646 100644 --- a/lib/Alchemy/Phrasea/Twig/BytesConverter.php +++ b/lib/Alchemy/Phrasea/Twig/BytesConverter.php @@ -17,7 +17,7 @@ class BytesConverter extends \Twig_Extension public function __construct() { - $this->unit = array(); + $this->unit = []; $this->unit['B'] = 'Bytes'; // 8 bits $this->unit['KB'] = 'Kilobytes'; // 1024 bytes $this->unit['MB'] = 'Megabytes'; // 1048576 bytes @@ -36,14 +36,14 @@ class BytesConverter extends \Twig_Extension public function getFilters() { - return array( + return [ 'bytesTo*' => new \Twig_Filter_Method($this, 'bytes2Filter') - ); + ]; } public function bytes2Filter($suffix, $bytes, $precision = 2) { - $auto = array('Human', 'Auto'); + $auto = ['Human', 'Auto']; $unit = array_keys($this->unit); if ($bytes <= 0) { diff --git a/lib/Alchemy/Phrasea/Twig/Camelize.php b/lib/Alchemy/Phrasea/Twig/Camelize.php index 3d2b524ccb..5bd9472fee 100644 --- a/lib/Alchemy/Phrasea/Twig/Camelize.php +++ b/lib/Alchemy/Phrasea/Twig/Camelize.php @@ -40,9 +40,9 @@ class Camelize extends \Twig_Extension */ public function getFilters() { - return array( + return [ 'camelize' => new \Twig_Filter_Method($this, 'toCamelCase'), - ); + ]; } public function toCamelCase($str, $separator = '-', $pascalCase = false) diff --git a/lib/Alchemy/Phrasea/Twig/JSUniqueID.php b/lib/Alchemy/Phrasea/Twig/JSUniqueID.php index 1962c31ad8..cc9cc5370a 100644 --- a/lib/Alchemy/Phrasea/Twig/JSUniqueID.php +++ b/lib/Alchemy/Phrasea/Twig/JSUniqueID.php @@ -20,13 +20,13 @@ class JSUniqueID extends \Twig_Extension */ public function getFilters() { - return array( + return [ 'JSUniqueID' => new \Twig_Filter_Method($this, 'JSUniqueID'), - ); + ]; } public function JSUniqueID($prefix = null, $suffix = null) { - return $prefix . 'id' . str_replace(array(',', '.'), '-', microtime(true)) . base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36) . $suffix; + return $prefix . 'id' . str_replace([',', '.'], '-', microtime(true)) . base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36) . $suffix; } } diff --git a/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php b/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php index 7c122c398f..37d95a17b9 100644 --- a/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php +++ b/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php @@ -61,7 +61,7 @@ class ComposerSetup throw new RuntimeException('Unable to move to target directory for composer install.'); } - $process = ProcessBuilder::create(array($this->phpExecutable, $installer))->getProcess(); + $process = ProcessBuilder::create([$this->phpExecutable, $installer])->getProcess(); try { $process->run(); diff --git a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php index df9bcd6a0a..3eacc9604e 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php +++ b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php @@ -40,7 +40,7 @@ class Compiler $this->filesystem->mkdir(dirname($target)); if (!$files instanceof \Traversable) { - $files = new \ArrayObject(is_array($files) ? $files : array($files)); + $files = new \ArrayObject(is_array($files) ? $files : [$files]); } $files = (array) $files; diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php index a4738d6744..e4a6f494e4 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php +++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php @@ -65,7 +65,7 @@ class UserProvider implements ControlProviderInterface ->like(\User_Query::LIKE_LOGIN, $query) ->like_match(\User_Query::LIKE_MATCH_OR) ->include_phantoms(true) - ->on_bases_where_i_am($this->app['acl']->get($for_user), array('canadmin')) + ->on_bases_where_i_am($this->app['acl']->get($for_user), ['canadmin']) ->limit(0, 50) ->execute()->get_results(); diff --git a/lib/Alchemy/Phrasea/Vocabulary/Controller.php b/lib/Alchemy/Phrasea/Vocabulary/Controller.php index 9d463a2922..4e80871782 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/Controller.php +++ b/lib/Alchemy/Phrasea/Vocabulary/Controller.php @@ -52,8 +52,8 @@ class Controller */ public static function getAvailable(Application $app) { - return array( + return [ new ControlProvider\UserProvider($app) - ); + ]; } } diff --git a/lib/classes/ACL.php b/lib/classes/ACL.php index 8c4c5ea498..7b0e1a0cf8 100644 --- a/lib/classes/ACL.php +++ b/lib/classes/ACL.php @@ -65,7 +65,7 @@ class ACL implements cache_cacheableInterface * * @var Array */ - protected $_global_rights = array( + protected $_global_rights = [ 'taskmanager' => false, 'manageusers' => false, 'order' => false, @@ -86,7 +86,7 @@ class ACL implements cache_cacheableInterface 'bas_chupub' => false, 'candwnldpreview' => true, 'candwnldhd' => true - ); + ]; /** * @@ -151,13 +151,13 @@ class ACL implements cache_cacheableInterface VALUES (null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)'; - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':sbas_id' => $record->get_sbas_id() , ':record_id' => $record->get_record_id() , ':case' => $action , ':pusher' => $pusher->get_id() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -175,13 +175,13 @@ class ACL implements cache_cacheableInterface VALUES (null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)'; - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':sbas_id' => $record->get_sbas_id() , ':record_id' => $record->get_record_id() , ':case' => $action , ':pusher' => $pusher->get_id() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -278,7 +278,7 @@ class ACL implements cache_cacheableInterface return $this; } - $sbas_ids = array(); + $sbas_ids = []; foreach ($base_ids as $base_id) { $sbas_ids[] = phrasea::sbasFromBas($this->app, $base_id); @@ -286,10 +286,10 @@ class ACL implements cache_cacheableInterface $sbas_ids = array_unique($sbas_ids); - $sbas_rights = array('bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub'); + $sbas_rights = ['bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub']; - $sbas_to_acces = array(); - $rights_to_give = array(); + $sbas_to_acces = []; + $rights_to_give = []; foreach ($this->app['acl']->get($template_user)->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); @@ -314,27 +314,27 @@ class ACL implements cache_cacheableInterface $this->update_rights_to_sbas($sbas_id, $rights); } - $bas_rights = array('canputinalbum', 'candwnldhd' + $bas_rights = ['canputinalbum', 'candwnldhd' , 'candwnldpreview', 'cancmd' , 'canadmin', 'actif', 'canreport', 'canpush' , 'canaddrecord', 'canmodifrecord', 'candeleterecord' , 'chgstatus', 'imgtools' , 'manage', 'modify_struct' , 'nowatermark', 'order_master' - ); + ]; - $bas_to_acces = $masks_to_give = $rights_to_give = array(); + $bas_to_acces = $masks_to_give = $rights_to_give = []; /** * map masks (and+xor) of template to masks to apply to user on base * (and_and, and_or, xor_and, xor_or) */ - $sbmap = array( - '00' => array('aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'), - '01' => array('aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'), - '10' => array('aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'), - '11' => array('aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1') - ); + $sbmap = [ + '00' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], + '01' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], + '10' => ['aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'], + '11' => ['aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1'] + ]; foreach ($this->app['acl']->get($template_user)->get_granted_base() as $collection) { $base_id = $collection->get_base_id(); @@ -371,7 +371,7 @@ class ACL implements cache_cacheableInterface . databox_status::dec2bin($this->app, $mask_xor) , -32 ); - $m = array('aa' => '', 'ao' => '', 'xa' => '', 'xo' => ''); + $m = ['aa' => '', 'ao' => '', 'xa' => '', 'xo' => '']; for ($i = 0; $i < 32; $i++) { $ax = $mand[$i] . $mxor[$i]; @@ -380,12 +380,12 @@ class ACL implements cache_cacheableInterface } } - $masks_to_give[$base_id] = array( + $masks_to_give[$base_id] = [ 'aa' => $m['aa'] , 'ao' => $m['ao'] , 'xa' => $m['xa'] , 'xo' => $m['xo'] - ); + ]; } $this->give_access_to_base($bas_to_acces); @@ -678,10 +678,10 @@ class ACL implements cache_cacheableInterface * @param array|null $sbas_ids Optionnal sbas_id to restrict the query on * @return array An array of collection */ - public function get_granted_base(Array $rights = array(), array $sbas_ids = null) + public function get_granted_base(Array $rights = [], array $sbas_ids = null) { $this->load_rights_bas(); - $ret = array(); + $ret = []; foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) { @@ -725,16 +725,16 @@ class ACL implements cache_cacheableInterface * @param Array $rights * @return Array */ - public function get_granted_sbas($rights = array()) + public function get_granted_sbas($rights = []) { if (is_string($rights)) - $rights = array($rights); + $rights = [$rights]; assert(is_array($rights)); $this->load_rights_sbas(); - $ret = array(); + $ret = []; foreach ($this->_rights_sbas as $sbas_id => $datas) { $continue = false; @@ -770,10 +770,10 @@ class ACL implements cache_cacheableInterface $sql = 'UPDATE usr SET create_db = :create_db WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':create_db' => $boolean ? '1' : '0', ':usr_id' => $this->user->get_id() - )); + ]); $stmt->closeCursor(); $this->delete_data_from_cache(self::CACHE_IS_ADMIN); @@ -808,13 +808,13 @@ class ACL implements cache_cacheableInterface FROM records_rights WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); - $this->_rights_records_preview = array(); - $this->_rights_records_document = array(); + $this->_rights_records_preview = []; + $this->_rights_records_document = []; foreach ($rs as $row) { $currentid = $row["sbas_id"] . "_" . $row["record_id"]; @@ -823,10 +823,10 @@ class ACL implements cache_cacheableInterface $this->_rights_records_preview[$currentid] = $currentid; } - $datas = array( + $datas = [ 'preview' => $this->_rights_records_preview , 'document' => $this->_rights_records_document - ); + ]; $this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS); @@ -850,7 +850,7 @@ class ACL implements cache_cacheableInterface FROM usr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); @@ -887,11 +887,11 @@ class ACL implements cache_cacheableInterface AND sbas.sbas_id = sbasusr.sbas_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $this->_rights_sbas = array(); + $this->_rights_sbas = []; $this->_global_rights['bas_modif_th'] = false; $this->_global_rights['bas_modify_struct'] = false; @@ -948,11 +948,11 @@ class ACL implements cache_cacheableInterface AND s.sbas_id = b.sbas_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $this->_rights_bas = $this->_limited = array(); + $this->_rights_bas = $this->_limited = []; $this->_global_rights['manageusers'] = false; $this->_global_rights['coll_manage'] = false; @@ -1009,10 +1009,10 @@ class ACL implements cache_cacheableInterface if ($row['time_limited'] == '1' && ($row['limited_from'] !== '' || $row['limited_to'] !== '')) { - $this->_limited[$row['base_id']] = array( + $this->_limited[$row['base_id']] = [ 'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null , 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null - ); + ]; } $this->_rights_bas[$row['base_id']]['imgtools'] @@ -1128,7 +1128,7 @@ class ACL implements cache_cacheableInterface $usr_id = $this->user->get_id(); foreach ($base_ids as $base_id) { - if (!$stmt_del->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id))) { + if (!$stmt_del->execute([':base_id' => $base_id, ':usr_id' => $usr_id])) { throw new Exception('Error while deleteing some rights'); } } @@ -1148,12 +1148,12 @@ class ACL implements cache_cacheableInterface VALUES (null, :base_id, :usr_id, "1")'; $stmt_ins = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_ins); $usr_id = $this->user->get_id(); - $to_update = array(); + $to_update = []; $this->load_rights_bas(); foreach ($base_ids as $base_id) { if (!isset($this->_rights_bas[$base_id])) { - $stmt_ins->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id)); + $stmt_ins->execute([':base_id' => $base_id, ':usr_id' => $usr_id]); } elseif ($this->_rights_bas[$base_id]['actif'] === false) { $to_update[] = $base_id; } @@ -1164,7 +1164,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id AND base_id = :base_id'; $stmt_upd = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_upd); foreach ($to_update as $base_id) { - $stmt_upd->execute(array(':usr_id' => $usr_id, ':base_id' => $base_id)); + $stmt_upd->execute([':usr_id' => $usr_id, ':base_id' => $base_id]); } $stmt_upd->closeCursor(); @@ -1188,7 +1188,7 @@ class ACL implements cache_cacheableInterface foreach ($sbas_ids as $sbas_id) { if (!$this->has_access_to_sbas($sbas_id)) - $stmt_ins->execute(array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id)); + $stmt_ins->execute([':sbas_id' => $sbas_id, ':usr_id' => $usr_id]); } $this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS); @@ -1207,12 +1207,12 @@ class ACL implements cache_cacheableInterface { if (!$this->has_access_to_base($base_id) && (!isset($rights['actif']) || $rights['actif'] == '1')) { - $this->give_access_to_base(array($base_id)); + $this->give_access_to_base([$base_id]); } $sql_up = "UPDATE basusr SET "; - $sql_args = $params = array(); + $sql_args = $params = []; foreach ($rights as $right => $v) { $sql_args[] = " " . $right . " = :" . $right; switch ($right) { @@ -1237,7 +1237,7 @@ class ACL implements cache_cacheableInterface $params = array_merge( $params - , array(':base_id' => $base_id, ':usr_id' => $usr_id) + , [':base_id' => $base_id, ':usr_id' => $usr_id] ); $stmt_up = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_up); @@ -1262,7 +1262,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id_2 AND b.base_id = bu.base_id)'; $usr_id = $this->user->get_id(); - $params = array(':usr_id_1' => $usr_id, ':usr_id_2' => $usr_id); + $params = [':usr_id_1' => $usr_id, ':usr_id_2' => $usr_id]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -1282,13 +1282,13 @@ class ACL implements cache_cacheableInterface public function update_rights_to_sbas($sbas_id, $rights) { if (!$this->has_access_to_sbas($sbas_id)) - $this->give_access_to_sbas(array($sbas_id)); + $this->give_access_to_sbas([$sbas_id]); $sql_up = "UPDATE sbasusr SET "; - $sql_args = array(); + $sql_args = []; $usr_id = $this->user->get_id(); - $params = array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id); + $params = [':sbas_id' => $sbas_id, ':usr_id' => $usr_id]; foreach ($rights as $right => $v) { $sql_args[] = " " . $right . " = :" . $right; @@ -1324,7 +1324,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id AND base_id = :base_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id(), ':base_id' => $base_id)); + $stmt->execute([':usr_id' => $this->user->get_id(), ':base_id' => $base_id]); $stmt->closeCursor(); unset($stmt); @@ -1340,13 +1340,13 @@ class ACL implements cache_cacheableInterface AND usr_id = :usr_id AND MONTH(lastconn) != MONTH(NOW()) AND restrict_dwnld = 1'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $stmt->closeCursor(); $sql = "UPDATE basusr SET lastconn=now() WHERE usr_id = :usr_id AND actif = 1"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $stmt->closeCursor(); unset($stmt); @@ -1368,12 +1368,12 @@ class ACL implements cache_cacheableInterface SET remain_dwnld = :restes, restrict_dwnld = 1, month_dwnld_max = :droits WHERE usr_id = :usr_id AND base_id = :base_id '; - $params = array( + $params = [ ':usr_id' => $this->user->get_id(), ':base_id' => $base_id, ':restes' => $restes, ':droits' => $droits - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -1390,10 +1390,10 @@ class ACL implements cache_cacheableInterface $sql = 'SELECT * FROM basusr WHERE base_id = :base_from AND usr_id = :usr_id'; - $params = array( + $params = [ ':base_from' => $base_id_from, ':usr_id' => $this->user->get_id() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -1404,12 +1404,12 @@ class ACL implements cache_cacheableInterface return $this; } - $this->give_access_to_base(array($base_id_dest)); + $this->give_access_to_base([$base_id_dest]); - $rights = array( + $rights = [ 'mask_and' => $row['mask_and'], 'mask_xor' => $row['mask_xor'], - ); + ]; if ($row['canputinalbum']) $rights['canputinalbum'] = true; @@ -1476,15 +1476,15 @@ class ACL implements cache_cacheableInterface $stmt = $databox->get_connection()->prepare($sql); $iord = 0; - foreach ($this->get_granted_base(array(), array($databox->get_sbas_id())) as $collection) { - $stmt->execute(array( + foreach ($this->get_granted_base([], [$databox->get_sbas_id()]) as $collection) { + $stmt->execute([ ':site_id' => $this->app['configuration']['main']['key'], ':usr_id' => $this->user->get_id(), ':coll_id' => $collection->get_coll_id(), ':mask_and' => $this->get_mask_and($collection->get_base_id()), ':mask_xor' => $this->get_mask_xor($collection->get_base_id()), ':ord' => $iord++ - )); + ]); } $stmt->closeCursor(); @@ -1504,10 +1504,10 @@ class ACL implements cache_cacheableInterface public function delete_injected_rights_sbas(databox $databox) { $sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site'; - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':site' => $this->app['configuration']['main']['key'] - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -1517,13 +1517,13 @@ class ACL implements cache_cacheableInterface public function set_masks_on_base($base_id, $and_and, $and_or, $xor_and, $xor_or) { - $vhex = array(); - $datas = array( + $vhex = []; + $datas = [ 'and_and' => $and_and, 'and_or' => $and_or, 'xor_and' => $xor_and, 'xor_or' => $xor_or - ); + ]; foreach ($datas as $name => $f) { $vhex[$name] = "0x"; @@ -1545,7 +1545,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id and base_id = :base_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $base_id, ':usr_id' => $this->user->get_id())); + $stmt->execute([':base_id' => $base_id, ':usr_id' => $this->user->get_id()]); $stmt->closeCursor(); unset($stmt); @@ -1596,12 +1596,12 @@ class ACL implements cache_cacheableInterface WHERE base_id = :base_id AND usr_id = :usr_id'; } - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':base_id' => $base_id , 'limited_from' => ($limit_from ? $limit_from->format(DATE_ISO8601) : null) , 'limited_to' => ($limit_to ? $limit_to->format(DATE_ISO8601) : null) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); @@ -1623,11 +1623,11 @@ class ACL implements cache_cacheableInterface { $sql = 'SELECT base_id FROM basusr WHERE order_master="1" AND usr_id= :usr_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $collections = array(); + $collections = []; foreach ($rs as $row) { $collections[] = \collection::get_from_base_id($this->app, $row['base_id']); @@ -1650,11 +1650,11 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id AND base_id = :base_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':master' => $bool ? 1 : 0, ':usr_id' => $this->user->get_id(), ':base_id' => $collection->get_base_id() - )); + ]); $stmt->closeCursor(); return $this; diff --git a/lib/classes/API/OAuth2/Account.php b/lib/classes/API/OAuth2/Account.php index c6603eb57d..48bcd16a5e 100644 --- a/lib/classes/API/OAuth2/Account.php +++ b/lib/classes/API/OAuth2/Account.php @@ -88,7 +88,7 @@ class API_OAuth2_Account WHERE api_account_id = :api_account_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':api_account_id' => $this->id)); + $stmt->execute([':api_account_id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -150,10 +150,10 @@ class API_OAuth2_Account $sql = 'UPDATE api_accounts SET revoked = :revoked WHERE api_account_id = :account_id'; - $params = array( + $params = [ ':revoked' => ($boolean ? '1' : '0') , 'account_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -218,7 +218,7 @@ class API_OAuth2_Account $sql = 'DELETE FROM api_accounts WHERE api_account_id = :account_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array('account_id' => $this->id)); + $stmt->execute(['account_id' => $this->id]); $stmt->closeCursor(); return; @@ -231,13 +231,13 @@ class API_OAuth2_Account VALUES (null, :usr_id, :revoked, :api_version, :application_id, :created)'; $datetime = new Datetime(); - $params = array( + $params = [ ':usr_id' => $user->get_id() , ':application_id' => $application->get_id() , ':api_version' => API_OAuth2_Adapter::API_VERSION , ':revoked' => 0 , ':created' => $datetime->format("Y-m-d H:i:s") - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -253,10 +253,10 @@ class API_OAuth2_Account $sql = 'SELECT api_account_id FROM api_accounts WHERE usr_id = :usr_id AND application_id = :application_id'; - $params = array( + $params = [ ":usr_id" => $user->get_id(), ":application_id" => $application->get_id() - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/API/OAuth2/Adapter.php b/lib/classes/API/OAuth2/Adapter.php index 88026704e8..86b0618d5c 100644 --- a/lib/classes/API/OAuth2/Adapter.php +++ b/lib/classes/API/OAuth2/Adapter.php @@ -55,12 +55,12 @@ class API_OAuth2_Adapter extends OAuth2 * * @var array */ - protected $token_type = array("bearer" => "Bearer"); + protected $token_type = ["bearer" => "Bearer"]; /** * @var array */ - protected $authentication_scheme = array("authorization", "uri", "body"); + protected $authentication_scheme = ["authorization", "uri", "body"]; /** * @@ -95,7 +95,7 @@ class API_OAuth2_Adapter extends OAuth2 public function __construct(Application $app) { parent::__construct(); - $this->params = array(); + $this->params = []; $this->app = $app; return $this; @@ -227,7 +227,7 @@ class API_OAuth2_Adapter extends OAuth2 try { $token = API_OAuth2_Token::load_by_oauth_token($this->app, $oauth_token); - $result = array( + $result = [ 'scope' => $token->get_scope() , 'expires' => $token->get_expires() , 'client_id' => $token->get_account()->get_application()->get_client_id() @@ -235,7 +235,7 @@ class API_OAuth2_Adapter extends OAuth2 , 'revoked' => ($token->get_account()->is_revoked() ? '1' : '0') , 'usr_id' => $token->get_account()->get_user()->get_id() , 'oauth_token' => $token->get_value() - ); + ]; } catch (Exception $e) { @@ -272,10 +272,10 @@ class API_OAuth2_Adapter extends OAuth2 */ protected function getSupportedGrantTypes() { - return array( + return [ OAUTH2_GRANT_TYPE_AUTH_CODE, OAUTH2_GRANT_TYPE_USER_CREDENTIALS - ); + ]; } /** @@ -286,7 +286,7 @@ class API_OAuth2_Adapter extends OAuth2 */ protected function getSupportedScopes() { - return array(); + return []; } /** @@ -300,12 +300,12 @@ class API_OAuth2_Adapter extends OAuth2 try { $code = new API_OAuth2_AuthCode($this->app, $code); - return array( + return [ 'redirect_uri' => $code->get_redirect_uri() , 'client_id' => $code->get_account()->get_application()->get_client_id() , 'expires' => $code->get_expires() , 'account_id' => $code->get_account()->get_id() - ); + ]; } catch (Exception $e) { } @@ -352,11 +352,11 @@ class API_OAuth2_Adapter extends OAuth2 try { $token = new API_OAuth2_RefreshToken($this->app, $refresh_token); - return array( + return [ 'token' => $token->get_value() , 'expires' => $token->get_expires()->format('U') , 'client_id' => $token->get_account()->get_application()->get_client_id() - ); + ]; } catch (Exception $e) { } @@ -383,11 +383,11 @@ class API_OAuth2_Adapter extends OAuth2 public function getAuthorizationRequestParameters(Request $request) { - $datas = array( + $datas = [ 'response_type' => $request->get('response_type', false) , 'client_id' => $request->get('client_id', false) , 'redirect_uri' => $request->get('redirect_uri', false) - ); + ]; $scope = $request->get('scope', false); $state = $request->get('state', false); @@ -400,21 +400,21 @@ class API_OAuth2_Adapter extends OAuth2 $datas["scope"] = $scope; } - $filters = array( - "client_id" => array( + $filters = [ + "client_id" => [ "filter" => FILTER_VALIDATE_REGEXP - , "options" => array("regexp" => OAUTH2_CLIENT_ID_REGEXP) + , "options" => ["regexp" => OAUTH2_CLIENT_ID_REGEXP] , "flags" => FILTER_REQUIRE_SCALAR - ) - , "response_type" => array( + ] + , "response_type" => [ "filter" => FILTER_VALIDATE_REGEXP - , "options" => array("regexp" => OAUTH2_AUTH_RESPONSE_TYPE_REGEXP) + , "options" => ["regexp" => OAUTH2_AUTH_RESPONSE_TYPE_REGEXP] , "flags" => FILTER_REQUIRE_SCALAR - ) - , "redirect_uri" => array("filter" => FILTER_SANITIZE_URL) - , "state" => array("flags" => FILTER_REQUIRE_SCALAR) - , "scope" => array("flags" => FILTER_REQUIRE_SCALAR) - ); + ] + , "redirect_uri" => ["filter" => FILTER_SANITIZE_URL] + , "state" => ["flags" => FILTER_REQUIRE_SCALAR] + , "scope" => ["flags" => FILTER_REQUIRE_SCALAR] + ]; $input = filter_var_array($datas, $filters); @@ -544,13 +544,13 @@ class API_OAuth2_Adapter extends OAuth2 * @param array $params * @return string */ - public function finishNativeClientAuthorization($is_authorized, $params = array()) + public function finishNativeClientAuthorization($is_authorized, $params = []) { - $result = array(); - $params += array( + $result = []; + $params += [ 'scope' => NULL, 'state' => NULL, - ); + ]; extract($params); if ($state !== NULL) @@ -632,12 +632,12 @@ class API_OAuth2_Adapter extends OAuth2 return TRUE; } - public function finishClientAuthorization($is_authorized, $params = array()) + public function finishClientAuthorization($is_authorized, $params = []) { - $params += array( + $params += [ 'scope' => NULL, 'state' => NULL, - ); + ]; extract($params); if ($state !== NULL) @@ -659,17 +659,17 @@ class API_OAuth2_Adapter extends OAuth2 */ public function grantAccessToken() { - $filters = array( - "grant_type" => array("filter" => FILTER_VALIDATE_REGEXP, "options" => array("regexp" => OAUTH2_GRANT_TYPE_REGEXP), "flags" => FILTER_REQUIRE_SCALAR), - "scope" => array("flags" => FILTER_REQUIRE_SCALAR), - "code" => array("flags" => FILTER_REQUIRE_SCALAR), - "redirect_uri" => array("filter" => FILTER_SANITIZE_URL), - "username" => array("flags" => FILTER_REQUIRE_SCALAR), - "password" => array("flags" => FILTER_REQUIRE_SCALAR), - "assertion_type" => array("flags" => FILTER_REQUIRE_SCALAR), - "assertion" => array("flags" => FILTER_REQUIRE_SCALAR), - "refresh_token" => array("flags" => FILTER_REQUIRE_SCALAR), - ); + $filters = [ + "grant_type" => ["filter" => FILTER_VALIDATE_REGEXP, "options" => ["regexp" => OAUTH2_GRANT_TYPE_REGEXP], "flags" => FILTER_REQUIRE_SCALAR], + "scope" => ["flags" => FILTER_REQUIRE_SCALAR], + "code" => ["flags" => FILTER_REQUIRE_SCALAR], + "redirect_uri" => ["filter" => FILTER_SANITIZE_URL], + "username" => ["flags" => FILTER_REQUIRE_SCALAR], + "password" => ["flags" => FILTER_REQUIRE_SCALAR], + "assertion_type" => ["flags" => FILTER_REQUIRE_SCALAR], + "assertion" => ["flags" => FILTER_REQUIRE_SCALAR], + "refresh_token" => ["flags" => FILTER_REQUIRE_SCALAR], + ]; $input = filter_input_array(INPUT_POST, $filters); @@ -773,10 +773,10 @@ class API_OAuth2_Adapter extends OAuth2 protected function createAccessToken($account_id, $scope = NULL) { - $token = array( + $token = [ "access_token" => $this->genAccessToken(), "scope" => $scope - ); + ]; if ($this->enable_expire) $token['expires_in'] = $this->getVariable('access_token_lifetime', OAUTH2_DEFAULT_ACCESS_TOKEN_LIFETIME); @@ -810,11 +810,11 @@ class API_OAuth2_Adapter extends OAuth2 $account = API_OAuth2_Account::load_with_user($this->app, $application, $user); - return array( + return [ 'redirect_uri' => $application->get_redirect_uri() , 'client_id' => $application->get_client_id() , 'account_id' => $account->get_id() - ); + ]; } catch (AccountLockedException $e) { return false; } catch (RequireCaptchaException $e) { diff --git a/lib/classes/API/OAuth2/Application.php b/lib/classes/API/OAuth2/Application.php index a213dfa7ef..32b49e65e3 100644 --- a/lib/classes/API/OAuth2/Application.php +++ b/lib/classes/API/OAuth2/Application.php @@ -147,7 +147,7 @@ class API_OAuth2_Application WHERE application_id = :application_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':application_id' => $this->id)); + $stmt->execute([':application_id' => $this->id]); if (0 === $stmt->rowCount()) { throw new NotFoundHttpException(sprintf('Application with id %d not found', $this->id)); @@ -215,7 +215,7 @@ class API_OAuth2_Application */ public function set_type($type) { - if ( ! in_array($type, array(self::DESKTOP_TYPE, self::WEB_TYPE))) + if ( ! in_array($type, [self::DESKTOP_TYPE, self::WEB_TYPE])) throw new Exception_InvalidArgument(); $this->type = $type; @@ -226,10 +226,10 @@ class API_OAuth2_Application $sql = 'UPDATE api_applications SET type = :type, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':type' => $this->type , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -259,10 +259,10 @@ class API_OAuth2_Application $sql = 'UPDATE api_applications SET name = :name, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':name' => $this->name , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -293,10 +293,10 @@ class API_OAuth2_Application SET description = :description, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':description' => $this->description , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -327,10 +327,10 @@ class API_OAuth2_Application SET website = :website, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':website' => $this->website , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -361,10 +361,10 @@ class API_OAuth2_Application SET activated = :activated, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':activated' => $this->activated , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -395,10 +395,10 @@ class API_OAuth2_Application SET grant_password = :grant_password, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':grant_password' => $this->grant_password , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -447,10 +447,10 @@ class API_OAuth2_Application SET client_id = :client_id, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':client_id' => $this->client_id , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -481,10 +481,10 @@ class API_OAuth2_Application SET client_secret = :client_secret, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':client_secret' => $this->client_secret , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -514,10 +514,10 @@ class API_OAuth2_Application SET redirect_uri = :redirect_uri, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':redirect_uri' => $this->redirect_uri , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -536,10 +536,10 @@ class API_OAuth2_Application $sql = 'SELECT api_account_id FROM api_accounts WHERE usr_id = :usr_id AND application_id = :id'; - $params = array( + $params = [ ':usr_id' => $user->get_id() , ':id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -566,7 +566,7 @@ class API_OAuth2_Application WHERE application_id = :application_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':application_id' => $this->get_id())); + $stmt->execute([':application_id' => $this->get_id()]); $stmt->closeCursor(); return; @@ -582,11 +582,11 @@ class API_OAuth2_Application WHERE application_id = :application_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':application_id' => $this->get_id())); + $stmt->execute([':application_id' => $this->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $accounts = array(); + $accounts = []; foreach ($rs as $row) { $accounts[] = new API_OAuth2_Account($this->app, $row['api_account_id']); @@ -618,7 +618,7 @@ class API_OAuth2_Application $client_secret = API_OAuth2_Token::generate_token(); $client_token = API_OAuth2_Token::generate_token(); - $params = array( + $params = [ ':usr_id' => $user ? $user->get_id() : null, ':name' => $name, ':client_id' => $client_token, @@ -626,7 +626,7 @@ class API_OAuth2_Application ':nonce' => $nonce, ':activated' => 1, ':grant_password' => 0 - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -655,7 +655,7 @@ class API_OAuth2_Application WHERE client_id = :client_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':client_id' => $client_id)); + $stmt->execute([':client_id' => $client_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -672,11 +672,11 @@ class API_OAuth2_Application WHERE a.creator = :usr_id AND a.application_id = b.application_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $apps = array(); + $apps = []; foreach ($rs as $row) { $apps[] = new API_OAuth2_Application($app, $row['application_id']); } @@ -691,11 +691,11 @@ class API_OAuth2_Application WHERE usr_id = :usr_id AND c.application_id = a.application_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $apps = array(); + $apps = []; foreach ($rs as $row) { $apps[] = new API_OAuth2_Application($app, $row['application_id']); } @@ -712,11 +712,11 @@ class API_OAuth2_Application AND revoked = 0'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $apps = array(); + $apps = []; foreach ($rs as $row) { $apps[] = new API_OAuth2_Application($app, $row['application_id']); } diff --git a/lib/classes/API/OAuth2/AuthCode.php b/lib/classes/API/OAuth2/AuthCode.php index 6c380026ad..c5dcc6dba5 100644 --- a/lib/classes/API/OAuth2/AuthCode.php +++ b/lib/classes/API/OAuth2/AuthCode.php @@ -40,7 +40,7 @@ class API_OAuth2_AuthCode FROM api_oauth_codes WHERE code = :code'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':code' => $this->code)); + $stmt->execute([':code' => $this->code]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -82,7 +82,7 @@ class API_OAuth2_AuthCode $sql = 'UPDATE api_oauth_codes SET redirect_uri = :redirect_uri WHERE code = :code'; - $params = array(':redirect_uri' => $redirect_uri, ':code' => $this->code); + $params = [':redirect_uri' => $redirect_uri, ':code' => $this->code]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -112,7 +112,7 @@ class API_OAuth2_AuthCode $sql = 'UPDATE api_oauth_codes SET scope = :scope WHERE code = :code'; - $params = array(':scope' => $scope, ':code' => $this->code); + $params = [':scope' => $scope, ':code' => $this->code]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -128,7 +128,7 @@ class API_OAuth2_AuthCode $sql = 'DELETE FROM api_oauth_codes WHERE code = :code'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':code' => $this->code)); + $stmt->execute([':code' => $this->code]); $stmt->closeCursor(); return; @@ -147,12 +147,12 @@ class API_OAuth2_AuthCode $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array(":account_id" => $account->get_id()); + $params = [":account_id" => $account->get_id()]; $stmt->execute($params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $codes = array(); + $codes = []; foreach ($rs as $row) { $codes[] = new API_OAuth2_AuthCode($app, $row['code']); @@ -177,11 +177,11 @@ class API_OAuth2_AuthCode $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array( + $params = [ ":code" => $code, ":account_id" => $account->get_id(), ":expires" => $expires - ); + ]; $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/classes/API/OAuth2/Form/DevAppDesktop.php b/lib/classes/API/OAuth2/Form/DevAppDesktop.php index b8b0fdddd6..bad53804cd 100644 --- a/lib/classes/API/OAuth2/Form/DevAppDesktop.php +++ b/lib/classes/API/OAuth2/Form/DevAppDesktop.php @@ -144,8 +144,8 @@ class API_OAuth2_Form_DevAppDesktop */ public static function loadValidatorMetadata(ClassMetadata $metadata) { - $blank = array('message' => _('Cette valeur ne peut être vide')); - $url = array('message' => _('Url non valide')); + $blank = ['message' => _('Cette valeur ne peut être vide')]; + $url = ['message' => _('Url non valide')]; $metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); diff --git a/lib/classes/API/OAuth2/Form/DevAppInternet.php b/lib/classes/API/OAuth2/Form/DevAppInternet.php index 7e57318a63..0720f6dcc0 100644 --- a/lib/classes/API/OAuth2/Form/DevAppInternet.php +++ b/lib/classes/API/OAuth2/Form/DevAppInternet.php @@ -147,8 +147,8 @@ class API_OAuth2_Form_DevAppInternet */ public static function loadValidatorMetadata(ClassMetadata $metadata) { - $blank = array('message' => _('Cette valeur ne peut être vide')); - $url = array('message' => _('Url non valide')); + $blank = ['message' => _('Cette valeur ne peut être vide')]; + $url = ['message' => _('Url non valide')]; $metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); diff --git a/lib/classes/API/OAuth2/RefreshToken.php b/lib/classes/API/OAuth2/RefreshToken.php index c1b66d4c6e..446ff34d4f 100644 --- a/lib/classes/API/OAuth2/RefreshToken.php +++ b/lib/classes/API/OAuth2/RefreshToken.php @@ -39,7 +39,7 @@ class API_OAuth2_RefreshToken FROM api_oauth_refresh_tokens WHERE refresh_token = :token'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':token' => $this->token)); + $stmt->execute([':token' => $this->token]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -88,7 +88,7 @@ class API_OAuth2_RefreshToken WHERE refresh_token = :refresh_token'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(":refresh_token" => $this->token)); + $stmt->execute([":refresh_token" => $this->token]); $stmt->closeCursor(); return; @@ -106,11 +106,11 @@ class API_OAuth2_RefreshToken WHERE api_account_id = :account_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $account->get_id())); + $stmt->execute([':account_id' => $account->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $tokens = array(); + $tokens = []; foreach ($rs as $row) { $tokens[] = new API_OAuth2_RefreshToken($app, $row['refresh_token']); @@ -135,12 +135,12 @@ class API_OAuth2_RefreshToken VALUES (:refresh_token, :account_id, :expires, :scope)'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array( + $params = [ ":refresh_token" => $refresh_token, ":account_id" => $account->get_id(), ":expires" => $expires, ":scope" => $scope - ); + ]; $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/classes/API/OAuth2/Token.php b/lib/classes/API/OAuth2/Token.php index d2f6072b8d..e96763472d 100644 --- a/lib/classes/API/OAuth2/Token.php +++ b/lib/classes/API/OAuth2/Token.php @@ -75,7 +75,7 @@ class API_OAuth2_Token FROM api_oauth_tokens WHERE api_account_id = :account_id'; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $this->account->get_id())); + $stmt->execute([':account_id' => $this->account->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ( ! $row) @@ -110,10 +110,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET oauth_token = :oauth_token WHERE oauth_token = :current_token'; - $params = array( + $params = [ ':oauth_token' => $oauth_token , ':current_token' => $this->token - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -143,10 +143,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET session_id = :session_id WHERE oauth_token = :current_token'; - $params = array( + $params = [ ':session_id' => $session_id , ':current_token' => $this->token - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -176,10 +176,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET expires = FROM_UNIXTIME(:expires) WHERE oauth_token = :oauth_token'; - $params = array( + $params = [ ':expires' => $expires , ':oauth_token' => $this->get_value() - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -204,10 +204,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET scope = :scope WHERE oauth_token = :oauth_token'; - $params = array( + $params = [ ':scope' => $scope , ':oauth_token' => $this->get_value() - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -238,10 +238,10 @@ class API_OAuth2_Token $new_token = self::generate_token(); - $params = array( + $params = [ ':new_token' => $new_token , ':old_token' => $this->get_value() - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -261,7 +261,7 @@ class API_OAuth2_Token $sql = 'DELETE FROM api_oauth_tokens WHERE oauth_token = :oauth_token'; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':oauth_token' => $this->get_value())); + $stmt->execute([':oauth_token' => $this->get_value()]); $stmt->closeCursor(); return; @@ -281,7 +281,7 @@ class API_OAuth2_Token AND a.api_account_id = b.api_account_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array(":oauth_token" => $oauth_token); + $params = [":oauth_token" => $oauth_token]; $stmt->execute($params); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -309,12 +309,12 @@ class API_OAuth2_Token $expires = new \DateTime('+1 hour'); - $params = array( + $params = [ ':token' => self::generate_token() , ':account_id' => $account->get_id() , ':expire' => $expires->format(DATE_ISO8601) , ':scope' => $scope - ); + ]; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/API/V1/Log.php b/lib/classes/API/V1/Log.php index 82d3741474..080b9af696 100644 --- a/lib/classes/API/V1/Log.php +++ b/lib/classes/API/V1/Log.php @@ -108,7 +108,7 @@ class API_V1_Log api_log_id = :log_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':log_id' => $this->id)); + $stmt->execute([':log_id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -137,10 +137,10 @@ class API_V1_Log SET api_account_id = :account_id WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':api_account_id' => $this->account_id , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -162,10 +162,10 @@ class API_V1_Log SET api_log_date = :date WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':date' => $this->date->format("Y-m-d H:i:s") , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -187,10 +187,10 @@ class API_V1_Log SET api_log_status_code = :code WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':code' => $this->status_code , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -207,7 +207,7 @@ class API_V1_Log public function set_format($format) { - if ( ! in_array($format, array('json', 'jsonp', 'yaml', 'unknow'))) + if ( ! in_array($format, ['json', 'jsonp', 'yaml', 'unknow'])) throw new Exception_InvalidArgument(); $this->format = $format; @@ -216,10 +216,10 @@ class API_V1_Log SET api_log_format = :format WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':format' => $this->format , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -235,7 +235,7 @@ class API_V1_Log public function set_ressource($ressource) { - if ( ! in_array($format, array(self::DATABOXES_RESSOURCE, self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE))) + if ( ! in_array($format, [self::DATABOXES_RESSOURCE, self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE])) throw new Exception_InvalidArgument(); $this->ressource = $ressource; @@ -244,10 +244,10 @@ class API_V1_Log SET api_log_ressource = :ressource WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':ressource' => $this->ressource , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -269,10 +269,10 @@ class API_V1_Log SET api_log_general = :general WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':general' => $this->general , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -294,10 +294,10 @@ class API_V1_Log SET api_log_aspect = :aspect WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':aspect' => $this->aspect , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -319,10 +319,10 @@ class API_V1_Log SET api_log_action = :action WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':action' => $this->action , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -365,7 +365,7 @@ class API_V1_Log :action )'; - $params = array( + $params = [ ':account_id' => $account->get_id(), ':route' => $route, ':status_code' => $status_code, @@ -374,7 +374,7 @@ class API_V1_Log ':general' => $general, ':aspect' => $aspect, ':action' => $action - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/API/V1/Timer.php b/lib/classes/API/V1/Timer.php index 5b5f233b05..f495865762 100644 --- a/lib/classes/API/V1/Timer.php +++ b/lib/classes/API/V1/Timer.php @@ -28,11 +28,11 @@ class API_V1_Timer implements ServiceProviderInterface $n++; $name = $event->getName() . '#' . $n; } - $app['api.timers']->add(array( + $app['api.timers']->add([ 'name' => $name, 'memory' => memory_get_usage(), 'time' => microtime(true) - $app['api.timers.start'], - )); + ]); }; $app['dispatcher']->addListener(KernelEvents::CONTROLLER, $callback, -999999); diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index bf46002883..5f4ed76e37 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -119,14 +119,14 @@ class API_V1_adapter extends API_V1_Abstract $date = new \DateTime(); $data = $app['task-manager.live-information']->getManager(); - $result->set_datas(array('scheduler' => array( + $result->set_datas(['scheduler' => [ 'configuration' => $data['configuration'], 'state' => $data['actual'], 'status' => $data['actual'], 'pid' => $data['process-id'], 'process-id' => $data['process-id'], 'updated_on' => $date->format(DATE_ATOM), - ))); + ]]); return $result; } @@ -142,12 +142,12 @@ class API_V1_adapter extends API_V1_Abstract { $result = new \API_V1_result($app, $app['request'], $this); - $ret = array(); + $ret = []; foreach ($app['manipulator.task']->getRepository()->findAll() as $task) { $ret[] = $this->list_task($app, $task); } - $result->set_datas(array('tasks' => $ret)); + $result->set_datas(['tasks' => $ret]); return $result; } @@ -156,7 +156,7 @@ class API_V1_adapter extends API_V1_Abstract { $data = $app['task-manager.live-information']->getTask($task); - return array( + return [ 'id' => $task->getId(), 'title' => $task->getName(), 'name' => $task->getName(), @@ -174,7 +174,7 @@ class API_V1_adapter extends API_V1_Abstract 'auto_start' => $task->getStatus() === Task::STATUS_STARTED, 'crashed' => $task->getCrashed(), 'status' => $task->getStatus(), - ); + ]; } /** @@ -187,7 +187,7 @@ class API_V1_adapter extends API_V1_Abstract public function get_task(Application $app, Task $task) { $result = new \API_V1_result($app, $app['request'], $this); - $ret = array('task' => $this->list_task($app, $task)); + $ret = ['task' => $this->list_task($app, $task)]; $result->set_datas($ret); return $result; @@ -205,7 +205,7 @@ class API_V1_adapter extends API_V1_Abstract $result = new \API_V1_result($app, $app['request'], $this); $app['manipulator.task']->start($task); - $result->set_datas(array('task' => $this->list_task($app, $task))); + $result->set_datas(['task' => $this->list_task($app, $task)]); return $result; } @@ -222,7 +222,7 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($app, $app['request'], $this); $app['manipulator.task']->stop($task); - $result->set_datas(array('task' => $this->list_task($app, $task))); + $result->set_datas(['task' => $this->list_task($app, $task)]); return $result; } @@ -255,7 +255,7 @@ class API_V1_adapter extends API_V1_Abstract $task->setStatus(Task::STATUS_STARTED); } - $result->set_datas(array('task' => $this->list_task($app, $task))); + $result->set_datas(['task' => $this->list_task($app, $task)]); return $result; } @@ -268,23 +268,23 @@ class API_V1_adapter extends API_V1_Abstract */ protected function get_cache_info(Application $app) { - $caches = array( + $caches = [ 'main' => $app['cache'], 'op_code' => $app['opcode-cache'], 'doctrine_metadatas' => $this->app['EM']->getConfiguration()->getMetadataCacheImpl(), 'doctrine_query' => $this->app['EM']->getConfiguration()->getQueryCacheImpl(), 'doctrine_result' => $this->app['EM']->getConfiguration()->getResultCacheImpl(), - ); + ]; - $ret = array(); + $ret = []; foreach ($caches as $name => $service) { if ($service instanceof \Alchemy\Phrasea\Cache\Cache) { - $ret['cache'][$name] = array( + $ret['cache'][$name] = [ 'type' => $service->getName(), 'online' => $service->isOnline(), 'stats' => $service->getStats(), - ); + ]; } else { $ret['cache'][$name] = null; } @@ -301,12 +301,12 @@ class API_V1_adapter extends API_V1_Abstract */ protected function get_config_info(Application $app) { - $ret = array(); + $ret = []; - $ret['phraseanet']['version'] = array( + $ret['phraseanet']['version'] = [ 'name' => $app['phraseanet.version']::getName(), 'number' => $app['phraseanet.version']::getNumber(), - ); + ]; $ret['phraseanet']['environment'] = $app->getEnvironment(); $ret['phraseanet']['debug'] = $app['debug']; @@ -327,99 +327,99 @@ class API_V1_adapter extends API_V1_Abstract try { $SEStatus = $app['phraseanet.SE']->getStatus(); } catch (\RuntimeException $e) { - $SEStatus = array('error' => $e->getMessage()); + $SEStatus = ['error' => $e->getMessage()]; } $binaries = $app['configuration']['binaries']; - return array( - 'global_values' => array( + return [ + 'global_values' => [ 'serverName' => $app['phraseanet.registry']->get('GV_ServerName'), 'title' => $app['phraseanet.registry']->get('GV_homeTitle'), 'keywords' => $app['phraseanet.registry']->get('GV_metaKeywords'), 'description' => $app['phraseanet.registry']->get('GV_metaDescription'), - 'httpServer' => array( + 'httpServer' => [ 'logErrors' => $app['phraseanet.registry']->get('GV_log_errors'), 'phpTimezone' => ini_get('date.timezone'), 'siteId' => $app['configuration']['main']['key'], 'staticUrl' => $app['phraseanet.registry']->get('GV_STATIC_URL'), 'defaultLanguage' => $app['phraseanet.registry']->get('id_GV_default_lng'), 'allowIndexing' => $app['phraseanet.registry']->get('GV_allow_search_engine'), - 'modes' => array( + 'modes' => [ 'XsendFile' => $app['configuration']['xsendfile']['enabled'], 'XsendFileMapping' => $app['configuration']['xsendfile']['mapping'], 'h264Streaming' => $app['phraseanet.registry']->get('GV_h264_streaming'), 'authTokenDirectory' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory'), 'authTokenDirectoryPath' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory_path'), 'authTokenPassphrase' => $app['phraseanet.registry']->get('GV_mod_auth_token_passphrase'), - ) - ), - 'maintenance' => array( + ] + ], + 'maintenance' => [ 'alertMessage' => $app['phraseanet.registry']->get('GV_message'), 'displayMessage' => $app['phraseanet.registry']->get('GV_message_on'), - ), - 'webServices' => array( + ], + 'webServices' => [ 'googleApi' => $app['phraseanet.registry']->get('GV_google_api'), 'googleAnalyticsId' => $app['phraseanet.registry']->get('GV_googleAnalytics'), 'i18nWebService' => $app['phraseanet.registry']->get('GV_i18n_service'), - 'recaptacha' => array( + 'recaptacha' => [ 'active' => $app['phraseanet.registry']->get('GV_captchas'), 'publicKey' => $app['phraseanet.registry']->get('GV_captcha_public_key'), 'privateKey' => $app['phraseanet.registry']->get('GV_captcha_private_key'), - ), - 'youtube' => array( + ], + 'youtube' => [ 'active' => $app['phraseanet.registry']->get('GV_youtube_api'), 'clientId' => $app['phraseanet.registry']->get('GV_youtube_client_id'), 'clientSecret' => $app['phraseanet.registry']->get('GV_youtube_client_secret'), 'devKey' => $app['phraseanet.registry']->get('GV_youtube_dev_key'), - ), - 'flickr' => array( + ], + 'flickr' => [ 'active' => $app['phraseanet.registry']->get('GV_flickr_api'), 'clientId' => $app['phraseanet.registry']->get('GV_flickr_client_id'), 'clientSecret' => $app['phraseanet.registry']->get('GV_flickr_client_secret'), - ), - 'dailymtotion' => array( + ], + 'dailymtotion' => [ 'active' => $app['phraseanet.registry']->get('GV_dailymotion_api'), 'clientId' => $app['phraseanet.registry']->get('GV_dailymotion_client_id'), 'clientSecret' => $app['phraseanet.registry']->get('GV_dailymotion_client_secret'), - ) - ), - 'navigator' => array( + ] + ], + 'navigator' => [ 'active' => $app['phraseanet.registry']->get('GV_client_navigator'), - ), - 'office-plugin' => array( + ], + 'office-plugin' => [ 'active' => $app['phraseanet.registry']->get('GV_client_navigator'), - ), - 'homepage' => array( + ], + 'homepage' => [ 'viewType' => $app['phraseanet.registry']->get('GV_home_publi'), - ), - 'report' => array( + ], + 'report' => [ 'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'), - ), - 'events' => array( + ], + 'events' => [ 'events' => $app['phraseanet.registry']->get('GV_events'), 'notifications' => $app['phraseanet.registry']->get('GV_notifications'), - ), - 'upload' => array( + ], + 'upload' => [ 'allowedFileExtension' => $app['phraseanet.registry']->get('GV_appletAllowedFileEx'), - ), - 'filesystem' => array( + ], + 'filesystem' => [ 'noWeb' => $app['phraseanet.registry']->get('GV_base_datapath_noweb'), - ), - 'searchEngine' => array( - 'configuration' => array( + ], + 'searchEngine' => [ + 'configuration' => [ 'defaultQuery' => $app['phraseanet.registry']->get('GV_defaultQuery'), 'defaultQueryType' => $app['phraseanet.registry']->get('GV_defaultQuery_type'), 'minChar' => $app['phraseanet.registry']->get('GV_min_letters_truncation'), 'sort' => $app['phraseanet.registry']->get('GV_phrasea_sort'), - ), - 'engine' => array( + ], + 'engine' => [ 'type' => $app['phraseanet.SE']->getName(), 'status' => $SEStatus, 'configuration' => $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(), - ), - ), - 'binary' => array( + ], + ], + 'binary' => [ 'phpCli' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null, 'phpIni' => $app['phraseanet.registry']->get('GV_PHP_INI'), 'swfExtract' => isset($binaries['swf_extract_binary']) ? $binaries['swf_extract_binary'] : null, @@ -431,21 +431,21 @@ class API_V1_adapter extends API_V1_Abstract 'mp4box' => isset($binaries['mp4box_binary']) ? $binaries['mp4box_binary'] : null, 'pdftotext' => isset($binaries['pdftotext_binary']) ? $binaries['pdftotext_binary'] : null, 'recess' => isset($binaries['recess_binary']) ? $binaries['recess_binary'] : null, - 'pdfmaxpages' => $app['phraseanet.registry']->get('GV_pdfmaxpages'),), - 'mainConfiguration' => array( + 'pdfmaxpages' => $app['phraseanet.registry']->get('GV_pdfmaxpages'),], + 'mainConfiguration' => [ 'adminMail' => $app['phraseanet.registry']->get('GV_adminMail'), 'viewBasAndCollName' => $app['phraseanet.registry']->get('GV_view_bas_and_coll'), 'chooseExportTitle' => $app['phraseanet.registry']->get('GV_choose_export_title'), 'defaultExportTitle' => $app['phraseanet.registry']->get('GV_default_export_title'), - 'socialTools' => $app['phraseanet.registry']->get('GV_social_tools'),), - 'modules' => array( + 'socialTools' => $app['phraseanet.registry']->get('GV_social_tools'),], + 'modules' => [ 'thesaurus' => $app['phraseanet.registry']->get('GV_thesaurus'), 'storyMode' => $app['phraseanet.registry']->get('GV_multiAndReport'), 'docSubsitution' => $app['phraseanet.registry']->get('GV_seeOngChgDoc'), - 'subdefSubstitution' => $app['phraseanet.registry']->get('GV_seeNewThumb'),), - 'email' => array( + 'subdefSubstitution' => $app['phraseanet.registry']->get('GV_seeNewThumb'),], + 'email' => [ 'defaultMailAddress' => $app['phraseanet.registry']->get('GV_defaulmailsenderaddr'), - 'smtp' => array( + 'smtp' => [ 'active' => $app['phraseanet.registry']->get('GV_smtp'), 'auth' => $app['phraseanet.registry']->get('GV_smtp_auth'), 'host' => $app['phraseanet.registry']->get('GV_smtp_host'), @@ -453,12 +453,12 @@ class API_V1_adapter extends API_V1_Abstract 'secure' => $app['phraseanet.registry']->get('GV_smtp_secure'), 'user' => $app['phraseanet.registry']->get('GV_smtp_user'), 'password' => $app['phraseanet.registry']->get('GV_smtp_password'), - ), - ), - 'ftp' => array( + ], + ], + 'ftp' => [ 'active' => $app['phraseanet.registry']->get('GV_activeFTP'), - 'activeForUser' => $app['phraseanet.registry']->get('GV_ftp_for_user'),), - 'client' => array( + 'activeForUser' => $app['phraseanet.registry']->get('GV_ftp_for_user'),], + 'client' => [ 'maxSizeDownload' => $app['phraseanet.registry']->get('GV_download_max'), 'tabSearchMode' => $app['phraseanet.registry']->get('GV_ong_search'), 'tabAdvSearchPosition' => $app['phraseanet.registry']->get('GV_ong_advsearch'), @@ -470,17 +470,17 @@ class API_V1_adapter extends API_V1_Abstract 'collRenderMode' => $app['phraseanet.registry']->get('GV_client_coll_ckbox'), 'viewSizeBaket' => $app['phraseanet.registry']->get('GV_viewSizeBaket'), 'clientAutoShowProposals' => $app['phraseanet.registry']->get('GV_clientAutoShowProposals'), - 'needAuth2DL' => $app['phraseanet.registry']->get('GV_needAuth2DL'),), - 'inscription' => array( + 'needAuth2DL' => $app['phraseanet.registry']->get('GV_needAuth2DL'),], + 'inscription' => [ 'autoSelectDB' => $app['phraseanet.registry']->get('GV_autoselectDB'), 'autoRegister' => $app['phraseanet.registry']->get('GV_autoregister'), - ), - 'push' => array( + ], + 'push' => [ 'validationReminder' => $app['phraseanet.registry']->get('GV_validation_reminder'), 'expirationValue' => $app['phraseanet.registry']->get('GV_val_expiration'), - ), - ) - ); + ], + ] + ]; } /** @@ -516,7 +516,7 @@ class API_V1_adapter extends API_V1_Abstract { $result = new API_V1_result($this->app, $request, $this); - $result->set_datas(array("databoxes" => $this->list_databoxes())); + $result->set_datas(["databoxes" => $this->list_databoxes()]); return $result; } @@ -534,11 +534,11 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "collections" => $this->list_databox_collections( $this->app['phraseanet.appbox']->get_databox($databox_id) ) - ) + ] ); return $result; @@ -557,12 +557,12 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "status" => $this->list_databox_status( $this->app['phraseanet.appbox']->get_databox($databox_id)->get_statusbits() ) - ) + ] ); return $result; @@ -581,13 +581,13 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "document_metadatas" => $this->list_databox_metadatas_fields( $this->app['phraseanet.appbox']->get_databox($databox_id) ->get_meta_structure() ) - ) + ] ); return $result; @@ -606,10 +606,10 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "termsOfUse" => $this->list_databox_terms($this->app['phraseanet.appbox']->get_databox($databox_id)) - ) + ] ); return $result; @@ -622,14 +622,14 @@ class API_V1_adapter extends API_V1_Abstract $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); $fields = $record->get_caption()->get_fields(); - $ret = array('caption_metadatas' => array()); + $ret = ['caption_metadatas' => []]; foreach ($fields as $field) { - $ret['caption_metadatas'][] = array( + $ret['caption_metadatas'][] = [ 'meta_structure_id' => $field->get_meta_struct_id(), 'name' => $field->get_name(), 'value' => $field->get_serialized_values(";"), - ); + ]; } $result->set_datas($ret); @@ -682,7 +682,7 @@ class API_V1_adapter extends API_V1_Abstract $callback = function ($element, $visa, $code) use (&$reasons, &$output) { if (!$visa->isValid()) { - $reasons = array(); + $reasons = []; foreach ($visa->getResponses() as $response) { $reasons[] = $response->getMessage(); @@ -709,9 +709,9 @@ class API_V1_adapter extends API_V1_Abstract $app['border-manager']->process($session, $Package, $callback, $behavior); - $ret = array( + $ret = [ 'entity' => null, - ); + ]; if ($output instanceof \record_adapter) { $ret['entity'] = '0'; @@ -735,9 +735,9 @@ class API_V1_adapter extends API_V1_Abstract $offset_start = max($request->get('offset_start', 0), 0); $per_page = min(max($request->get('per_page', 10), 1), 20); - $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canaddrecord'])); - $lazaretFiles = array(); + $lazaretFiles = []; if (count($baseIds) > 0) { $lazaretRepository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\LazaretFile'); @@ -747,7 +747,7 @@ class API_V1_adapter extends API_V1_Abstract ); } - $ret = array(); + $ret = []; foreach ($lazaretFiles as $lazaretFile) { $ret[] = $this->list_lazaret_file($lazaretFile); @@ -755,11 +755,11 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); - $result->set_datas(array( + $result->set_datas([ 'offset_start' => $offset_start, 'per_page' => $per_page, 'quarantine_items' => $ret, - )); + ]); return $result; } @@ -777,7 +777,7 @@ class API_V1_adapter extends API_V1_Abstract throw new \API_V1_exception_forbidden('You do not have access to this quarantine item'); } - $ret = array('quarantine_item' => $this->list_lazaret_file($lazaretFile)); + $ret = ['quarantine_item' => $this->list_lazaret_file($lazaretFile)]; $result = new API_V1_result($this->app, $request, $this); @@ -788,7 +788,7 @@ class API_V1_adapter extends API_V1_Abstract protected function list_lazaret_file(LazaretFile $file) { - $checks = array(); + $checks = []; if ($file->getChecks()) { foreach ($file->getChecks() as $checker) { @@ -802,12 +802,12 @@ class API_V1_adapter extends API_V1_Abstract $usr_id = $file->getSession()->getUser($this->app)->get_id(); } - $session = array( + $session = [ 'id' => $file->getSession()->getId(), 'usr_id' => $usr_id, - ); + ]; - return array( + return [ 'id' => $file->getId(), 'quarantine_session' => $session, 'base_id' => $file->getBaseId(), @@ -815,10 +815,10 @@ class API_V1_adapter extends API_V1_Abstract 'sha256' => $file->getSha256(), 'uuid' => $file->getUuid(), 'forced' => $file->getForced(), - 'checks' => $file->getForced() ? array() : $checks, + 'checks' => $file->getForced() ? [] : $checks, 'created_on' => $file->getCreated()->format(DATE_ATOM), 'updated_on' => $file->getUpdated()->format(DATE_ATOM), - ); + ]; } /** @@ -833,7 +833,7 @@ class API_V1_adapter extends API_V1_Abstract list($ret, $search_result) = $this->prepare_search_request($request); - $ret['results'] = array('records' => array(), 'stories' => array()); + $ret['results'] = ['records' => [], 'stories' => []]; foreach ($search_result->getResults() as $record) { if ($record->is_grouping()) { @@ -909,7 +909,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['phraseanet.SE.logger']->log($databox, $search_result->getQuery(), $search_result->getTotal(), $colls); } - $ret = array( + $ret = [ 'offset_start' => $offsetStart, 'per_page' => $perPage, 'available_results' => $search_result->getAvailable(), @@ -921,11 +921,11 @@ class API_V1_adapter extends API_V1_Abstract 'suggestions' => array_map(function (SearchEngineSuggestion $suggestion) { return $suggestion->toArray(); }, $search_result->getSuggestions()->toArray()), - 'results' => array(), + 'results' => [], 'query' => $search_result->getQuery(), - ); + ]; - return array($ret, $search_result); + return [$ret, $search_result]; } /** @@ -956,10 +956,10 @@ class API_V1_adapter extends API_V1_Abstract return $that->list_story($story); }, array_values($record->get_grouping_parents()->get_elements())); - $result->set_datas(array( + $result->set_datas([ "baskets" => $baskets, "stories" => $stories, - )); + ]); return $result; } @@ -980,9 +980,9 @@ class API_V1_adapter extends API_V1_Abstract $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); $result->set_datas( - array( + [ "record_metadatas" => $this->list_record_caption($record->get_caption()) - ) + ] ); return $result; @@ -1006,13 +1006,13 @@ class API_V1_adapter extends API_V1_Abstract ->get_record($record_id); $result->set_datas( - array( + [ "status" => $this->list_record_status( $this->app['phraseanet.appbox']->get_databox($databox_id) , $record->get_status() ) - ) + ] ); return $result; @@ -1034,16 +1034,16 @@ class API_V1_adapter extends API_V1_Abstract $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); - $ret = array(); + $ret = []; - $devices = $request->get('devices', array()); - $mimes = $request->get('mimes', array()); + $devices = $request->get('devices', []); + $mimes = $request->get('mimes', []); foreach ($record->get_embedable_medias($devices, $mimes) as $name => $media) { $ret[] = $this->list_embedable_media($media, $this->app['phraseanet.registry']); } - $result->set_datas(array("embed" => $ret)); + $result->set_datas(["embed" => $ret]); return $result; } @@ -1066,16 +1066,16 @@ class API_V1_adapter extends API_V1_Abstract ->get_databox($databox_id) ->get_record($record_id); - $ret = array(); + $ret = []; - $devices = $request->get('devices', array()); - $mimes = $request->get('mimes', array()); + $devices = $request->get('devices', []); + $mimes = $request->get('mimes', []); foreach ($record->get_embedable_medias($devices, $mimes) as $name => $media) { $ret[] = $this->list_embedable_media($media, $this->app['phraseanet.registry']); } - $result->set_datas(array("embed" => $ret)); + $result->set_datas(["embed" => $ret]); return $result; } @@ -1099,7 +1099,7 @@ class API_V1_adapter extends API_V1_Abstract } $record->set_metadatas($metadatas); - $result->set_datas(array("record_metadatas" => $this->list_record_caption($record->get_caption()))); + $result->set_datas(["record_metadatas" => $this->list_record_caption($record->get_caption())]); } catch (Exception $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); } @@ -1126,7 +1126,7 @@ class API_V1_adapter extends API_V1_Abstract if ($n > 31 || $n < 4) { throw new API_V1_exception_badrequest(); } - if (!in_array($value, array('0', '1'))) { + if (!in_array($value, ['0', '1'])) { throw new API_V1_exception_badrequest(); } if (!isset($status_bits[$n])) { @@ -1141,10 +1141,10 @@ class API_V1_adapter extends API_V1_Abstract $this->app['phraseanet.SE']->updateRecord($record); - $result->set_datas(array( + $result->set_datas([ "status" => $this->list_record_status($databox, $record->get_status()) - ) + ] ); } catch (Exception $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); @@ -1171,7 +1171,7 @@ class API_V1_adapter extends API_V1_Abstract $collection = collection::get_from_base_id($this->app, $request->get('base_id')); $record->move_to_collection($collection, $this->app['phraseanet.appbox']); - $result->set_datas(array("record" => $this->list_record($record))); + $result->set_datas(["record" => $this->list_record($record)]); } catch (Exception $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $e->getMessage()); } @@ -1193,7 +1193,7 @@ class API_V1_adapter extends API_V1_Abstract $databox = $this->app['phraseanet.appbox']->get_databox($databox_id); try { $record = $databox->get_record($record_id); - $result->set_datas(array('record' => $this->list_record($record))); + $result->set_datas(['record' => $this->list_record($record)]); } catch (NotFoundHttpException $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Record Not Found')); } catch (Exception $e) { @@ -1217,7 +1217,7 @@ class API_V1_adapter extends API_V1_Abstract $databox = $this->app['phraseanet.appbox']->get_databox($databox_id); try { $story = $databox->get_record($story_id); - $result->set_datas(array('story' => $this->list_story($story))); + $result->set_datas(['story' => $this->list_story($story)]); } catch (NotFoundHttpException $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Story Not Found')); } catch (Exception $e) { @@ -1239,7 +1239,7 @@ class API_V1_adapter extends API_V1_Abstract $usr_id = $this->app['authentication']->getUser()->get_id(); - $result->set_datas(array('baskets' => $this->list_baskets($usr_id))); + $result->set_datas(['baskets' => $this->list_baskets($usr_id)]); return $result; } @@ -1257,7 +1257,7 @@ class API_V1_adapter extends API_V1_Abstract $baskets = $repo->findActiveByUser($this->app['authentication']->getUser()); - $ret = array(); + $ret = []; foreach ($baskets as $basket) { $ret[] = $this->list_basket($basket); } @@ -1288,7 +1288,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['EM']->persist($Basket); $this->app['EM']->flush(); - $result->set_datas(array("basket" => $this->list_basket($Basket))); + $result->set_datas(["basket" => $this->list_basket($Basket)]); return $result; } @@ -1320,10 +1320,10 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "basket" => $this->list_basket($basket), "basket_elements" => $this->list_basket_content($basket) - ) + ] ); return $result; @@ -1337,7 +1337,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_basket_content(Basket $Basket) { - $ret = array(); + $ret = []; foreach ($Basket->getElements() as $basket_element) { $ret[] = $this->list_basket_element($basket_element); @@ -1354,15 +1354,15 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_basket_element(BasketElement $basket_element) { - $ret = array( + $ret = [ 'basket_element_id' => $basket_element->getId(), 'order' => $basket_element->getOrd(), 'record' => $this->list_record($basket_element->getRecord($this->app)), 'validation_item' => null != $basket_element->getBasket()->getValidation(), - ); + ]; if ($basket_element->getBasket()->getValidation()) { - $choices = array(); + $choices = []; $agreement = null; $note = ''; @@ -1370,19 +1370,19 @@ class API_V1_adapter extends API_V1_Abstract $participant = $validation_datas->getParticipant(); $user = $participant->getUser($this->app); /* @var $validation_datas Alchemy\Phrasea\Model\Entities\ValidationData */ - $choices[] = array( - 'validation_user' => array( + $choices[] = [ + 'validation_user' => [ 'usr_id' => $user->get_id(), 'usr_name' => $user->get_display_name(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(), - ), + ], 'agreement' => $validation_datas->getAgreement(), 'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM), 'note' => null === $validation_datas->getNote() ? '' : $validation_datas->getNote(), - ); + ]; if ($user->get_id() == $this->app['authentication']->getUser()->get_id()) { $agreement = $validation_datas->getAgreement(); @@ -1415,7 +1415,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['EM']->persist($basket); $this->app['EM']->flush(); - $result->set_datas(array("basket" => $this->list_basket($basket))); + $result->set_datas(["basket" => $this->list_basket($basket)]); return $result; } @@ -1436,7 +1436,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['EM']->persist($basket); $this->app['EM']->flush(); - $result->set_datas(array("basket" => $this->list_basket($basket))); + $result->set_datas(["basket" => $this->list_basket($basket)]); return $result; } @@ -1454,12 +1454,12 @@ class API_V1_adapter extends API_V1_Abstract $coll = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($this->app['acl']->get($user)); - $datas = array(); + $datas = []; foreach ($coll as $feed) { $datas[] = $this->list_publication($feed, $user); } - $result->set_datas(array("feeds" => $datas)); + $result->set_datas(["feeds" => $datas]); return $result; } @@ -1487,19 +1487,19 @@ class API_V1_adapter extends API_V1_Abstract $feed = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->find($publication_id); if (!$feed->isAccessible($user, $this->app)) { - return $result->set_datas(array()); + return $result->set_datas([]); } $offset_start = (int) ($request->get('offset_start') ? : 0); $per_page = (int) ($request->get('per_page') ? : 5); $per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5; - $datas = array( + $datas = [ 'feed' => $this->list_publication($feed, $user), 'offset_start' => $offset_start, 'per_page' => $per_page, 'entries' => $this->list_publications_entries($feed, $offset_start, $per_page), - ); + ]; $result->set_datas($datas); @@ -1517,12 +1517,12 @@ class API_V1_adapter extends API_V1_Abstract $per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5; - $datas = array( + $datas = [ 'total_entries' => $feed->getCountTotalEntries(), 'offset_start' => $offset_start, 'per_page' => $per_page, 'entries' => $this->list_publications_entries($feed, $offset_start, $per_page), - ); + ]; $result->set_datas($datas); @@ -1541,9 +1541,9 @@ class API_V1_adapter extends API_V1_Abstract throw new \API_V1_exception_forbidden('You have not access to the parent feed'); } - $datas = array( + $datas = [ 'entry' => $this->list_publication_entry($entry), - ); + ]; $result->set_datas($datas); @@ -1559,7 +1559,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_publication(Feed $feed, $user) { - return array( + return [ 'id' => $feed->getId(), 'title' => $feed->getTitle(), 'subtitle' => $feed->getSubtitle(), @@ -1570,7 +1570,7 @@ class API_V1_adapter extends API_V1_Abstract 'deletable' => $feed->isOwner($user), 'created_on' => $feed->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM), - ); + ]; } /** @@ -1586,7 +1586,7 @@ class API_V1_adapter extends API_V1_Abstract $entries = $feed->getEntries($offset_start, $how_many); - $out = array(); + $out = []; foreach ($entries as $entry) { $out[] = $this->list_publication_entry($entry); } @@ -1602,12 +1602,12 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_publication_entry(FeedEntry $entry) { - $items = array(); + $items = []; foreach ($entry->getItems() as $item) { $items[] = $this->list_publication_entry_item($item); } - return array( + return [ 'id' => $entry->getId(), 'author_email' => $entry->getAuthorEmail(), 'author_name' => $entry->getAuthorName(), @@ -1619,7 +1619,7 @@ class API_V1_adapter extends API_V1_Abstract 'feed_id' => $entry->getFeed()->getId(), 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/', 'url' => '/feeds/entry/' . $entry->getId() . '/', - ); + ]; } /** @@ -1630,10 +1630,10 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_publication_entry_item(FeedItem $item) { - $datas = array( + $datas = [ 'item_id' => $item->getId() , 'record' => $this->list_record($item->getRecord($this->app)) - ); + ]; return $datas; } @@ -1683,7 +1683,7 @@ class API_V1_adapter extends API_V1_Abstract $permalink = null; } - return array( + return [ 'name' => $media->get_name(), 'permalink' => $permalink, 'height' => $media->get_height(), @@ -1692,7 +1692,7 @@ class API_V1_adapter extends API_V1_Abstract 'devices' => $media->getDevices(), 'player_type' => $media->get_type(), 'mime_type' => $media->get_mime(), - ); + ]; } /** @@ -1704,7 +1704,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_permalink(media_Permalink_Adapter $permalink, registryInterface $registry) { - return array( + return [ 'created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), @@ -1713,7 +1713,7 @@ class API_V1_adapter extends API_V1_Abstract 'page_url' => $permalink->get_page(), 'download_url' => $permalink->get_url() . '&download', 'url' => $permalink->get_url() - ); + ]; } /** @@ -1726,9 +1726,9 @@ class API_V1_adapter extends API_V1_Abstract protected function list_record_status(databox $databox, $status) { $status = strrev($status); - $ret = array(); + $ret = []; foreach ($databox->get_statusbits() as $bit => $status_datas) { - $ret[] = array('bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1)); + $ret[] = ['bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1)]; } return $ret; @@ -1742,7 +1742,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_record_caption(caption_record $caption) { - $ret = array(); + $ret = []; foreach ($caption->get_fields() as $field) { foreach ($field->get_values() as $value) { $ret[] = $this->list_record_caption_field($value, $field); @@ -1760,18 +1760,18 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_record_caption_field(caption_Field_Value $value, caption_field $field) { - return array( + return [ 'meta_id' => $value->getId(), 'meta_structure_id' => $field->get_meta_struct_id(), 'name' => $field->get_name(), - 'labels' => array( + 'labels' => [ 'fr' => $field->get_databox_field()->get_label('fr'), 'en' => $field->get_databox_field()->get_label('en'), 'de' => $field->get_databox_field()->get_label('de'), 'nl' => $field->get_databox_field()->get_label('nl'), - ), + ], 'value' => $value->getValue(), - ); + ]; } /** @@ -1782,7 +1782,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function list_basket(Basket $basket) { - $ret = array( + $ret = [ 'basket_id' => $basket->getId(), 'created_on' => $basket->getCreated()->format(DATE_ATOM), 'description' => (string) $basket->getDescription(), @@ -1791,23 +1791,23 @@ class API_V1_adapter extends API_V1_Abstract 'updated_on' => $basket->getUpdated()->format(DATE_ATOM), 'unread' => !$basket->getIsRead(), 'validation_basket' => !!$basket->getValidation() - ); + ]; if ($basket->getValidation()) { - $users = array(); + $users = []; foreach ($basket->getValidation()->getParticipants() as $participant) { /* @var $participant ValidationParticipant */ $user = $participant->getUser($this->app); - $users[] = array( + $users[] = [ 'usr_id' => $user->get_id(), 'usr_name' => $user->get_display_name(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(), - ); + ]; } $expires_on_atom = $basket->getValidation()->getExpires(); @@ -1817,13 +1817,13 @@ class API_V1_adapter extends API_V1_Abstract } $ret = array_merge( - array( + [ 'validation_users' => $users, 'expires_on' => $expires_on_atom, 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()), 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(), 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()), - ), $ret + ], $ret ); } @@ -1838,15 +1838,15 @@ class API_V1_adapter extends API_V1_Abstract */ public function list_record(record_adapter $record) { - $technicalInformation = array(); + $technicalInformation = []; foreach ($record->get_technical_infos() as $name => $value) { - $technicalInformation[] = array( + $technicalInformation[] = [ 'name' => $name, 'value' => $value - ); + ]; } - return array( + return [ 'databox_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'mime_type' => $record->get_mime(), @@ -1860,7 +1860,7 @@ class API_V1_adapter extends API_V1_Abstract 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->get_type(), 'uuid' => $record->get_uuid(), - ); + ]; } /** @@ -1894,7 +1894,7 @@ class API_V1_adapter extends API_V1_Abstract return $field->get_serialized_values(); }; - return array( + return [ '@entity@' => self::OBJECT_TYPE_STORY, 'databox_id' => $story->get_sbas_id(), 'story_id' => $story->get_record_id(), @@ -1903,7 +1903,7 @@ class API_V1_adapter extends API_V1_Abstract 'collection_id' => phrasea::collFromBas($this->app, $story->get_base_id()), 'thumbnail' => $this->list_embedable_media($story->get_thumbnail(), $this->app['phraseanet.registry']), 'uuid' => $story->get_uuid(), - 'metadatas' => array( + 'metadatas' => [ '@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG, 'dc:contributor' => $format($caption, databox_Field_DCESAbstract::Contributor), 'dc:coverage' => $format($caption, databox_Field_DCESAbstract::Coverage), @@ -1920,9 +1920,9 @@ class API_V1_adapter extends API_V1_Abstract 'dc:subject' => $format($caption, databox_Field_DCESAbstract::Subject), 'dc:title' => $format($caption, databox_Field_DCESAbstract::Title), 'dc:type' => $format($caption, databox_Field_DCESAbstract::Type), - ), + ], 'records' => $records, - ); + ]; } /** @@ -1932,7 +1932,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databoxes() { - $ret = array(); + $ret = []; foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { $ret[] = $this->list_databox($databox); } @@ -1948,9 +1948,9 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_terms(databox $databox) { - $ret = array(); + $ret = []; foreach ($databox->get_cgus() as $locale => $array_terms) { - $ret[] = array('locale' => $locale, 'terms' => $array_terms['value']); + $ret[] = ['locale' => $locale, 'terms' => $array_terms['value']]; } return $ret; @@ -1963,17 +1963,17 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox(databox $databox) { - $ret = array(); + $ret = []; $ret['databox_id'] = $databox->get_sbas_id(); $ret['name'] = $databox->get_dbname(); $ret['viewname'] = $databox->get_viewname(); - $ret['labels'] = array( + $ret['labels'] = [ 'en' => $databox->get_label('en'), 'de' => $databox->get_label('de'), 'fr' => $databox->get_label('fr'), 'nl' => $databox->get_label('nl'), - ); + ]; $ret['version'] = $databox->get_version(); return $ret; @@ -1987,7 +1987,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_collections(databox $databox) { - $ret = array(); + $ret = []; foreach ($databox->get_collections() as $collection) { $ret[] = $this->list_collection($collection); @@ -2004,18 +2004,18 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_collection(collection $collection) { - $ret = array( + $ret = [ 'base_id' => $collection->get_base_id(), 'collection_id' => $collection->get_coll_id(), 'name' => $collection->get_name(), - 'labels' => array( + 'labels' => [ 'fr' => $collection->get_label('fr'), 'en' => $collection->get_label('en'), 'de' => $collection->get_label('de'), 'nl' => $collection->get_label('nl'), - ), + ], 'record_amount' => $collection->get_record_amount(), - ); + ]; return $ret; } @@ -2028,23 +2028,23 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_status(array $status) { - $ret = array(); + $ret = []; foreach ($status as $n => $datas) { - $ret[] = array( + $ret[] = [ 'bit' => $n, 'label_on' => $datas['labelon'], 'label_off' => $datas['labeloff'], - 'labels' => array( + 'labels' => [ 'en' => $datas['labels_on_i18n']['en'], 'fr' => $datas['labels_on_i18n']['fr'], 'de' => $datas['labels_on_i18n']['de'], 'nl' => $datas['labels_on_i18n']['nl'], - ), + ], 'img_on' => $datas['img_on'], 'img_off' => $datas['img_off'], 'searchable' => !!$datas['searchable'], 'printable' => !!$datas['printable'], - ); + ]; } return $ret; @@ -2058,7 +2058,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_metadatas_fields(databox_descriptionStructure $meta_struct) { - $ret = array(); + $ret = []; foreach ($meta_struct as $meta) { $ret[] = $this->list_databox_metadata_field_properties($meta); } @@ -2074,18 +2074,18 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_metadata_field_properties(databox_field $databox_field) { - $ret = array( + $ret = [ 'id' => $databox_field->get_id(), 'namespace' => $databox_field->get_tag()->getGroupName(), 'source' => $databox_field->get_tag()->getTagname(), 'tagname' => $databox_field->get_tag()->getName(), 'name' => $databox_field->get_name(), - 'labels' => array( + 'labels' => [ 'fr' => $databox_field->get_label('fr'), 'en' => $databox_field->get_label('en'), 'de' => $databox_field->get_label('de'), 'nl' => $databox_field->get_label('nl'), - ), + ], 'separator' => $databox_field->get_separator(), 'thesaurus_branch' => $databox_field->get_tbranch(), 'type' => $databox_field->get_type(), @@ -2093,7 +2093,7 @@ class API_V1_adapter extends API_V1_Abstract 'multivalue' => $databox_field->is_multi(), 'readonly' => $databox_field->is_readonly(), 'required' => $databox_field->is_required(), - ); + ]; return $ret; } diff --git a/lib/classes/API/V1/result.php b/lib/classes/API/V1/result.php index 8307bad6af..17725ed1a9 100644 --- a/lib/classes/API/V1/result.php +++ b/lib/classes/API/V1/result.php @@ -124,7 +124,7 @@ class API_V1_result } $accept = $this->request->getAcceptableContentTypes(); - $response_types = array(); + $response_types = []; foreach ($accept as $key => $app_type) { $response_types[strtolower($app_type)] = true; @@ -183,8 +183,8 @@ class API_V1_result . $this->request->getPathInfo() ); - $ret = array( - 'meta' => array( + $ret = [ + 'meta' => [ 'api_version' => $this->api_version , 'request' => $request_uri , 'response_time' => $this->response_time @@ -193,9 +193,9 @@ class API_V1_result , 'error_message' => $this->error_message , 'error_details' => $this->error_details , 'charset' => 'UTF-8' - ) + ] , 'response' => $this->response - ); + ]; $this->app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent()); @@ -214,7 +214,7 @@ class API_V1_result break; case self::FORMAT_YAML: if ($ret['response'] instanceof stdClass) - $ret['response'] = array(); + $ret['response'] = []; $dumper = new Symfony\Component\Yaml\Dumper(); $return_value = $dumper->dump($ret, 8); @@ -388,7 +388,7 @@ class API_V1_result $response = new Response( $this->format(), $this->get_http_code(), - array('Content-Type' => $this->get_content_type()) + ['Content-Type' => $this->get_content_type()] ); $response->setCharset('UTF-8'); diff --git a/lib/classes/Bridge/Account.php b/lib/classes/Bridge/Account.php index ac97c72cd6..d1ac26d6ce 100644 --- a/lib/classes/Bridge/Account.php +++ b/lib/classes/Bridge/Account.php @@ -92,7 +92,7 @@ class Bridge_Account FROM bridge_accounts WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -196,11 +196,11 @@ class Bridge_Account $sql = 'UPDATE bridge_accounts SET name = :name, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':name' => $this->name , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -225,7 +225,7 @@ class Bridge_Account $sql = 'DELETE FROM bridge_accounts WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -242,7 +242,7 @@ class Bridge_Account $sql = 'SELECT id, api_id FROM bridge_accounts WHERE id = :account_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $account_id)); + $stmt->execute([':account_id' => $account_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -268,11 +268,11 @@ class Bridge_Account $sql = 'SELECT id FROM bridge_accounts WHERE api_id = :api_id AND usr_id = :usr_id AND dist_id = :dist_id'; - $params = array( + $params = [ ':api_id' => $api->get_id() , ':usr_id' => $user->get_id() , ':dist_id' => $distant_id - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -298,11 +298,11 @@ class Bridge_Account LIMIT 0,' . (int) $quantity; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':api_id' => $api->get_id())); + $stmt->execute([':api_id' => $api->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); + $results = []; foreach ($rs as $row) { $results[] = new Bridge_Account($app, $api, $row['id']); @@ -322,12 +322,12 @@ class Bridge_Account $sql = 'SELECT id, api_id FROM bridge_accounts WHERE usr_id = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); - $apis = array(); + $results = []; + $apis = []; foreach ($rs as $row) { $api_id = $row['api_id']; @@ -360,12 +360,12 @@ class Bridge_Account (id, api_id, dist_id, usr_id, name, created_on, updated_on) VALUES (null, :api_id, :dist_id, :usr_id, :name, NOW(), NOW())'; - $params = array( + $params = [ ':api_id' => $api->get_id() , ':dist_id' => $dist_id , ':usr_id' => $user->get_id() , ':name' => $name - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Bridge/AccountSettings.php b/lib/classes/Bridge/AccountSettings.php index 3faa0e6fe0..1f29a9e488 100644 --- a/lib/classes/Bridge/AccountSettings.php +++ b/lib/classes/Bridge/AccountSettings.php @@ -54,7 +54,7 @@ class Bridge_AccountSettings $sql = 'SELECT value FROM bridge_account_settings WHERE account_id = :account_id AND `key` = :key'; - $params = array(':account_id' => $this->account->get_id(), ':key' => $key); + $params = [':account_id' => $this->account->get_id(), ':key' => $key]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -75,11 +75,11 @@ class Bridge_AccountSettings $sql = 'REPLACE INTO bridge_account_settings (account_id, `key`, value) VALUES (:account_id, :key, :value)'; - $params = array( + $params = [ ':value' => $value , ':account_id' => $this->account->get_id() , ':key' => $key - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -100,7 +100,7 @@ class Bridge_AccountSettings $sql = 'DELETE FROM bridge_account_settings WHERE account_id = :account_id AND `key` = :key'; - $params = array(':account_id' => $this->account->get_id(), ':key' => $key); + $params = [':account_id' => $this->account->get_id(), ':key' => $key]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Bridge/Api.php b/lib/classes/Bridge/Api.php index 69ce9f96a0..cb6cf68d42 100644 --- a/lib/classes/Bridge/Api.php +++ b/lib/classes/Bridge/Api.php @@ -71,7 +71,7 @@ class Bridge_Api $sql = 'SELECT id, name, disable_time, created_on, updated_on FROM bridge_apis WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -364,7 +364,7 @@ class Bridge_Api * @param array $options specific option, regarding the connector * @return string The distant_id of the created element */ - public function upload(record_adapter $record, array $options = array()) + public function upload(record_adapter $record, array $options = []) { $action = function (Bridge_Api $obj) use ($record, $options) { return $obj->get_connector()->upload($record, $options); @@ -389,7 +389,7 @@ class Bridge_Api $sql = 'DELETE FROM bridge_apis WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -406,11 +406,11 @@ class Bridge_Api $sql = 'UPDATE bridge_apis SET disable_time = :time, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':time' => $value , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -463,7 +463,7 @@ class Bridge_Api */ public static function generate_callback_url(UrlGenerator $generator, $api_name) { - return $generator->generate('prod_bridge_callback', array('api_name' => strtolower($api_name)), UrlGenerator::ABSOLUTE_URL); + return $generator->generate('prod_bridge_callback', ['api_name' => strtolower($api_name)], UrlGenerator::ABSOLUTE_URL); } /** @@ -474,7 +474,7 @@ class Bridge_Api */ public static function generate_login_url(UrlGenerator $generator, $api_name) { - return $generator->generate('prod_bridge_login', array('api_name' => strtolower($api_name)), UrlGenerator::ABSOLUTE_URL); + return $generator->generate('prod_bridge_login', ['api_name' => strtolower($api_name)], UrlGenerator::ABSOLUTE_URL); } /** @@ -504,7 +504,7 @@ class Bridge_Api $sql = 'SELECT id FROM bridge_apis WHERE name = :name'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':name' => $name)); + $stmt->execute([':name' => $name]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -527,7 +527,7 @@ class Bridge_Api $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); + $results = []; foreach ($rs as $row) { try { @@ -547,7 +547,7 @@ class Bridge_Api VALUES (null, :name, 0, null, NOW(), NOW())'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':name' => strtolower($name))); + $stmt->execute([':name' => strtolower($name)]); $stmt->closeCursor(); $api_id = $app['phraseanet.appbox']->get_connection()->lastInsertId(); diff --git a/lib/classes/Bridge/Api/Abstract.php b/lib/classes/Bridge/Api/Abstract.php index 123901dcc9..194e6538ab 100644 --- a/lib/classes/Bridge/Api/Abstract.php +++ b/lib/classes/Bridge/Api/Abstract.php @@ -114,7 +114,7 @@ abstract class Bridge_Api_Abstract * * @return string */ - public function get_auth_url($supp_params = array()) + public function get_auth_url($supp_params = []) { return $this->_auth->get_auth_url($supp_params); } diff --git a/lib/classes/Bridge/Api/AbstractCollection.php b/lib/classes/Bridge/Api/AbstractCollection.php index 2e36321154..18e3dac611 100644 --- a/lib/classes/Bridge/Api/AbstractCollection.php +++ b/lib/classes/Bridge/Api/AbstractCollection.php @@ -45,7 +45,7 @@ abstract class Bridge_Api_AbstractCollection * * @var Array */ - protected $elements = array(); + protected $elements = []; /** * diff --git a/lib/classes/Bridge/Api/Auth/Flickr.php b/lib/classes/Bridge/Api/Auth/Flickr.php index 1e579fb38e..40c73e4b27 100644 --- a/lib/classes/Bridge/Api/Auth/Flickr.php +++ b/lib/classes/Bridge/Api/Auth/Flickr.php @@ -79,7 +79,7 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ $this->get_api()->setAuthToken($auth_token); - return array('auth_token' => $auth_token); + return ['auth_token' => $auth_token]; } /** @@ -117,9 +117,9 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function get_auth_signatures() { - return array( + return [ 'auth_token' => $this->settings->get('auth_token') - ); + ]; } /** @@ -129,7 +129,7 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function set_parameters(Array $parameters) { - $avail_parameters = array('flickr_client_id', 'flickr_client_secret', 'permissions'); + $avail_parameters = ['flickr_client_id', 'flickr_client_secret', 'permissions']; foreach ($parameters as $parameter => $value) { if ( ! in_array($parameter, $avail_parameters)) continue; @@ -144,7 +144,7 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ * * @return string */ - public function get_auth_url(Array $supp_params = array()) + public function get_auth_url(Array $supp_params = []) { $request_token = $this->get_api()->requestFrob(); diff --git a/lib/classes/Bridge/Api/Auth/Interface.php b/lib/classes/Bridge/Api/Auth/Interface.php index 921cd3a3d1..202eabce8f 100644 --- a/lib/classes/Bridge/Api/Auth/Interface.php +++ b/lib/classes/Bridge/Api/Auth/Interface.php @@ -31,7 +31,7 @@ interface Bridge_Api_Auth_Interface public function parse_request_token(); - public function get_auth_url(Array $supp_parameters = array()); + public function get_auth_url(Array $supp_parameters = []); public function get_auth_signatures(); diff --git a/lib/classes/Bridge/Api/Auth/OAuth2.php b/lib/classes/Bridge/Api/Auth/OAuth2.php index 68bafbd304..349868483e 100644 --- a/lib/classes/Bridge/Api/Auth/OAuth2.php +++ b/lib/classes/Bridge/Api/Auth/OAuth2.php @@ -75,13 +75,13 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function connect($request_token) { - $post_params = array( + $post_params = [ 'code' => $request_token, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => $this->redirect_uri, 'grant_type' => 'authorization_code' - ); + ]; $response_json = http_query::getUrl($this->token_endpoint, $post_params); $response = json_decode($response_json, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS); @@ -89,7 +89,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ if ( ! is_array($response) || ! isset($response['refresh_token']) || ! isset($response['access_token'])) throw new Bridge_Exception_ApiConnectorAccessTokenFailed('Unable to retrieve tokens'); - return array('refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']); + return ['refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']]; } /** @@ -98,12 +98,12 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function reconnect() { - $post_params = array( + $post_params = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'refresh_token' => $this->settings->get('refresh_token'), 'grant_type' => 'refresh_token' - ); + ]; $response = http_query::getUrl($this->token_endpoint, $post_params); $response = json_decode($response, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS); @@ -141,9 +141,9 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function get_auth_signatures() { - return array( + return [ 'auth_token' => $this->settings->get('auth_token') - ); + ]; } /** @@ -153,7 +153,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function set_parameters(Array $parameters) { - $avail_parameters = array( + $avail_parameters = [ 'client_id' , 'client_secret' , 'redirect_uri' @@ -161,7 +161,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ , 'response_type' , 'token_endpoint' , 'auth_endpoint' - ); + ]; foreach ($parameters as $parameter => $value) { if ( ! in_array($parameter, $avail_parameters)) @@ -177,14 +177,14 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ * * @return string */ - public function get_auth_url(Array $supp_parameters = array()) + public function get_auth_url(Array $supp_parameters = []) { - $params = array_merge(array( + $params = array_merge([ 'response_type' => 'code', 'client_id' => $this->client_id, 'redirect_uri' => $this->redirect_uri, 'scope' => $this->scope - ), $supp_parameters); + ], $supp_parameters); return sprintf('%s?%s', $this->auth_endpoint, http_build_query($params, null, '&')); } diff --git a/lib/classes/Bridge/Api/Auth/Youtube.php b/lib/classes/Bridge/Api/Auth/Youtube.php index 4105b4da22..02f54d34f8 100644 --- a/lib/classes/Bridge/Api/Auth/Youtube.php +++ b/lib/classes/Bridge/Api/Auth/Youtube.php @@ -22,12 +22,12 @@ class Bridge_Api_Auth_Youtube extends Bridge_Api_Auth_OAuth2 * @param array $supp_parameters * @return string */ - public function get_auth_url(array $supp_parameters = array()) + public function get_auth_url(array $supp_parameters = []) { $supp_parameters = array_merge( - $supp_parameters, array( + $supp_parameters, [ 'access_type' => 'offline', - 'approval_prompt' => 'force') + 'approval_prompt' => 'force'] ); return parent::get_auth_url($supp_parameters); diff --git a/lib/classes/Bridge/Api/Dailymotion.php b/lib/classes/Bridge/Api/Dailymotion.php index 1ceea2f94b..8590fafdf6 100644 --- a/lib/classes/Bridge/Api/Dailymotion.php +++ b/lib/classes/Bridge/Api/Dailymotion.php @@ -89,7 +89,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_user_id() { - $result = $this->_api->call("/me", array('fields' => array('id')), $this->oauth_token); + $result = $this->_api->call("/me", ['fields' => ['id']], $this->oauth_token); return $result["id"]; } @@ -100,7 +100,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_user_name() { - $result = $this->_api->call("/me", array('fields' => array('username')), $this->oauth_token); + $result = $this->_api->call("/me", ['fields' => ['username']], $this->oauth_token); return $result["username"]; } @@ -183,7 +183,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_element_types() { - return array(self::ELEMENT_TYPE_VIDEO => _('Videos')); + return [self::ELEMENT_TYPE_VIDEO => _('Videos')]; } /** @@ -192,7 +192,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_container_types() { - return array(self::CONTAINER_TYPE_PLAYLIST => _('Playlists')); + return [self::CONTAINER_TYPE_PLAYLIST => _('Playlists')]; } public function get_oauth_token() @@ -241,7 +241,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($object) { case self::ELEMENT_TYPE_VIDEO: - $result = $this->_api->call('/me/videos', array('fields' => array( + $result = $this->_api->call('/me/videos', ['fields' => [ 'created_time' , 'description' , 'duration' @@ -256,9 +256,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I , 'views_total' , 'id' , 'channel' - ), + ], 'page' => ! $offset_start ? 1 : $offset_start, - 'limit' => $quantity), $this->oauth_token); + 'limit' => $quantity], $this->oauth_token); $element_collection = new Bridge_Api_ElementCollection(); $element_collection->set_items_per_page($result["limit"]); @@ -298,12 +298,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $username = $this->get_user_name(); - $params = array('fields' => array( + $params = ['fields' => [ 'description' , 'id' , 'name' - ), - 'page' => ! $offset_start ? 1 : $offset_start); + ], + 'page' => ! $offset_start ? 1 : $offset_start]; //add quantity if (! ! $quantity) { $params["limit"] = $quantity; @@ -325,7 +325,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I foreach ($result['list'] as $entry) { //get 1st image - $list_element = $this->list_containers_content($object, $entry['id'], array('thumbnail_medium_url'), 1); + $list_element = $this->list_containers_content($object, $entry['id'], ['thumbnail_medium_url'], 1); $elements = $list_element->get_elements(); $first_element = array_shift($elements); $thumbnail = $first_element instanceof Bridge_Api_Dailymotion_Element ? $first_element->get_thumbnail() : ''; @@ -356,18 +356,18 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function update_element($object, $object_id, Array $datas) { - $required_fields = array("title", "description", "category", "privacy"); + $required_fields = ["title", "description", "category", "privacy"]; foreach ($required_fields as $field) { if ( ! array_key_exists($field, $datas)) throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant"); } - $params = array( + $params = [ 'title' => $datas["title"] , 'description' => $datas["description"] , 'channel' => $datas["category"] , 'private' => ! $datas["private"] - ); + ]; if ( ! $this->is_valid_object_id($object_id)) throw new Bridge_Exception_ActionInvalidObjectId($object_id); @@ -397,7 +397,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($container_type) { case self::CONTAINER_TYPE_PLAYLIST: $url = sprintf("POST /me/%ss", $container_type); - $playlist = $this->_api->call($url, array('name' => $request->get("name")), $this->oauth_token); + $playlist = $this->_api->call($url, ['name' => $request->get("name")], $this->oauth_token); return $playlist["id"]; break; @@ -422,9 +422,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($destination) { case self::CONTAINER_TYPE_PLAYLIST: - $array = array($element_id); + $array = [$element_id]; //get containers content - foreach ($this->list_containers_content($destination, $container_id, array('id'))->get_elements() as $element) { + foreach ($this->list_containers_content($destination, $container_id, ['id'])->get_elements() as $element) { $array[] = $element->get_id(); } @@ -432,7 +432,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $url = sprintf('POST /%s/%s/%ss', $destination, $container_id, $element_type); - $this->_api->call($url, array('ids' => implode(",", $array)), $this->oauth_token); + $this->_api->call($url, ['ids' => implode(",", $array)], $this->oauth_token); return $this->get_container_from_id(self::CONTAINER_TYPE_PLAYLIST, $container_id); break; @@ -458,10 +458,10 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $url = sprintf("DELETE /%s/%s", $object, $object_id); switch ($object) { case self::ELEMENT_TYPE_VIDEO: - $this->_api->call($url, array(), $this->oauth_token); + $this->_api->call($url, [], $this->oauth_token); break; case self::CONTAINER_TYPE_PLAYLIST: - $this->_api->call($url, array(), $this->oauth_token); + $this->_api->call($url, [], $this->oauth_token); break; default: throw new Bridge_Exception_ObjectUnknown('Unknown object ' . $object); @@ -492,9 +492,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I { $url = sprintf("/%s/%s", $element->get_type(), $element->get_dist_id()); - $result = $this->_api->call($url, array('fields' => array( + $result = $this->_api->call($url, ['fields' => [ 'status' - )), $this->oauth_token); + ]], $this->oauth_token); return $result["status"]; } @@ -578,12 +578,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I * @param array $options * @return string */ - public function upload(record_adapter $record, array $options = array()) + public function upload(record_adapter $record, array $options = []) { switch ($record->get_type()) { case self::ELEMENT_TYPE_VIDEO : $url_file = $this->_api->uploadFileWithToken($record->get_hd_file()->getRealPath(), $this->oauth_token); - $options = array_merge(array('url' => $url_file), $options); + $options = array_merge(['url' => $url_file], $options); $video = $this->_api->call('POST /me/videos', $options, $this->oauth_token); return $video["id"]; @@ -607,7 +607,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($object) { case self::ELEMENT_TYPE_VIDEO: - $entry = $this->_api->call($url, array('fields' => array( + $entry = $this->_api->call($url, ['fields' => [ 'created_time' , 'description' , 'duration' @@ -623,7 +623,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I , 'id' , 'channel' , 'tags' - )), $this->oauth_token); + ]], $this->oauth_token); return new Bridge_Api_Dailymotion_Element($entry, $object); break; @@ -645,11 +645,11 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($object) { case self::CONTAINER_TYPE_PLAYLIST: - $entry = $this->_api->call($url, array('fields' => array( + $entry = $this->_api->call($url, ['fields' => [ 'description' , 'id' , 'name' - )), $this->oauth_token); + ]], $this->oauth_token); /** * @todo Retieve thumb */ @@ -686,7 +686,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I protected function set_auth_params() { $this->_auth->set_parameters( - array( + [ 'client_id' => $this->registry->get('GV_dailymotion_client_id') , 'client_secret' => $this->registry->get('GV_dailymotion_client_secret') , 'redirect_uri' => Bridge_Api::generate_callback_url($this->generator, $this->get_name()) @@ -694,7 +694,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I , 'response_type' => 'code' , 'token_endpoint' => self::OAUTH2_TOKEN_ENDPOINT , 'auth_endpoint' => self::OAUTH2_AUTHORIZE_ENDPOINT - ) + ] ); return $this; @@ -732,7 +732,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I public function get_category_list() { $locale = explode("_", $this->locale); - $result = $this->_api->call("/channels", array("language" => $locale[0])); + $result = $this->_api->call("/channels", ["language" => $locale[0]]); return $result["list"]; } @@ -742,9 +742,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I * @param type $supp_params * @return type */ - public function get_auth_url($supp_params = array()) + public function get_auth_url($supp_params = []) { - $params = array_merge(array('display' => 'popup', 'scope' => 'read write delete manage_playlists'), $supp_params); + $params = array_merge(['display' => 'popup', 'scope' => 'read write delete manage_playlists'], $supp_params); return parent::get_auth_url($params); } @@ -754,10 +754,10 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I * @param string $id * @return Bridge_Api_ElementCollection */ - protected function list_containers_content($object, $id, Array $fields = array(), $iteration = 0) + protected function list_containers_content($object, $id, Array $fields = [], $iteration = 0) { $url = sprintf("/%s/%s/videos", $object, $id); - $result = $this->_api->call($url, array('fields' => $fields), $this->oauth_token); + $result = $this->_api->call($url, ['fields' => $fields], $this->oauth_token); $element_collection = new Bridge_Api_ElementCollection(); $element_collection->set_items_per_page($result["limit"]); @@ -829,7 +829,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I public function check_update_constraints(Array $datas) { - $errors = array(); + $errors = []; $check = function ($field) use (&$errors, $datas) { $required = ! ! $field["required"]; $name = $field["name"]; @@ -863,12 +863,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->get_serialize_key(); - $datas = array( + $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'tag' => $request->get('tags_' . $key), 'private' => $request->get('privacy_' . $key) === 'private' ? true : false, - ); + ]; return $datas; } @@ -880,12 +880,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_update_datas(Request $request) { - $datas = array( + $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'tags' => $request->get('modif_tags'), 'private' => $request->get('modif_privacy') === 'private' ? true : false, - ); + ]; return $datas; } @@ -908,7 +908,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ private function check_record_constraints(record_adapter $record) { - $errors = array(); + $errors = []; if ( ! $record->get_hd_file() instanceof \SplFileInfo) $errors["file_size"] = _("Le record n'a pas de fichier physique"); //Record must rely on real file @@ -927,31 +927,31 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_fields() { - return array( - array( + return [ + [ 'name' => 'title', 'length' => '255', 'length_min' => '5', 'required' => true - ) - , array( + ] + , [ 'name' => 'description', 'length' => '2000', 'length_min' => '0', 'required' => false - ) - , array( + ] + , [ 'name' => 'tags', 'length' => '150', 'length_min' => '0', 'required' => false - ) - , array( + ] + , [ 'name' => 'private', 'length' => '0', 'length_min' => '0', 'required' => true - ) - ); + ] + ]; } } diff --git a/lib/classes/Bridge/Api/Dailymotion/Element.php b/lib/classes/Bridge/Api/Dailymotion/Element.php index 6664542d71..f2f222cf6a 100644 --- a/lib/classes/Bridge/Api/Dailymotion/Element.php +++ b/lib/classes/Bridge/Api/Dailymotion/Element.php @@ -170,6 +170,6 @@ class Bridge_Api_Dailymotion_Element implements Bridge_Api_ElementInterface */ public function get_tags() { - return implode(",", $this->get('tags', array())); + return implode(",", $this->get('tags', [])); } } diff --git a/lib/classes/Bridge/Api/Flickr.php b/lib/classes/Bridge/Api/Flickr.php index 91c7ccd3bf..81b9d4d678 100644 --- a/lib/classes/Bridge/Api/Flickr.php +++ b/lib/classes/Bridge/Api/Flickr.php @@ -169,7 +169,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($object) { case self::ELEMENT_TYPE_PHOTO: - $params = array('photo_id' => $element_id); + $params = ['photo_id' => $element_id]; $th_response = $this->_api->executeMethod('flickr.photos.getInfo', $params); if ( ! $th_response->isOk()) @@ -198,7 +198,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf switch ($object) { case self::CONTAINER_TYPE_PHOTOSET: - $params = array('photoset_id' => $element_id); + $params = ['photoset_id' => $element_id]; $response = $this->_api->executeMethod('flickr.photoset.getInfo', $params); if ( ! $response->isOk()) @@ -227,7 +227,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($object) { case self::CONTAINER_TYPE_PHOTOSET: - $params = array(); + $params = []; if ($quantity) $params['per_page'] = $quantity; $params['page'] = $quantity != 0 ? floor($offset_start / $quantity) + 1 : 1; @@ -267,17 +267,17 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function update_element($object, $object_id, Array $datas) { - $required_fields = array("title"); + $required_fields = ["title"]; foreach ($required_fields as $field) { if ( ! array_key_exists($field, $datas) || trim($datas[$field]) === '') throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant"); } - $params = array( + $params = [ 'title' => $datas["title"] , 'photo_id' => $object_id , 'description' => $datas["description"] - ); + ]; switch ($object) { case self::ELEMENT_TYPE_PHOTO : @@ -309,11 +309,11 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf if (is_null($pid)) throw new Bridge_Exception_ActionMandatoryField('You must define a default photo for the photoset'); - $params = array( + $params = [ 'title' => $request->get('title') , 'primary_photo_id' => $pid , 'description' => $request->get('description') - ); + ]; $response = $this->_api->executeMethod('flickr.photosets.create', $params); @@ -348,7 +348,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf case self::ELEMENT_TYPE_PHOTO: switch ($destination) { case self::CONTAINER_TYPE_PHOTOSET: - $params = array('photo_id' => $element_id, 'photoset_id' => $container_id); + $params = ['photo_id' => $element_id, 'photoset_id' => $container_id]; $response = $this->_api->executeMethod('flickr.photosets.addPhoto', $params); if ( ! $response->isOk()) { @@ -385,7 +385,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf case self::ELEMENT_TYPE_PHOTO: $response = $this->_api->executeMethod( 'flickr.photos.delete' - , array('photo_id' => $object_id) + , ['photo_id' => $object_id] ); if ( ! $response->isOk()) throw new Bridge_Exception_ApiConnectorRequestFailed(); @@ -393,7 +393,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf case self::CONTAINER_TYPE_PHOTOSET: $response = $this->_api->executeMethod( 'flickr.photosets.delete' - , array('photoset_id' => $object_id) + , ['photoset_id' => $object_id] ); if ( ! $response->isOk()) throw new Bridge_Exception_ApiConnectorRequestFailed(); @@ -417,9 +417,9 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($type) { case self::ELEMENT_TYPE_PHOTO: - $params = array(); + $params = []; //info to display during search - $extras = array( + $extras = [ 'description' , 'license' , 'date_upload' @@ -430,7 +430,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf , 'views' , 'url_sq' , 'url_t' - ); + ]; $params['user_id'] = $this->get_user_id(); $params['extras'] = implode(",", $extras); @@ -510,7 +510,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf * @param array $options * @return string The new distant Id */ - public function upload(record_adapter $record, Array $options = array()) + public function upload(record_adapter $record, Array $options = []) { $uploader = new Phlickr_Uploader($this->_api); @@ -534,7 +534,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf public function acceptable_records() { return function (record_adapter $record) { - return in_array($record->get_type(), array('image')); + return in_array($record->get_type(), ['image']); }; } @@ -568,7 +568,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf $family = $friends = $public = false; break; } - $ret = array('friends' => $friends, 'family' => $family, 'public' => $public); + $ret = ['friends' => $friends, 'family' => $family, 'public' => $public]; return $ret; } @@ -601,7 +601,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_element_types() { - return array(self::ELEMENT_TYPE_PHOTO => _('Photos')); + return [self::ELEMENT_TYPE_PHOTO => _('Photos')]; } /** @@ -610,7 +610,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_container_types() { - return array(self::CONTAINER_TYPE_PHOTOSET => _('Photosets')); + return [self::CONTAINER_TYPE_PHOTOSET => _('Photosets')]; } /** @@ -622,7 +622,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_category_list() { - return array(); + return []; } public function is_configured() @@ -678,11 +678,11 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf protected function set_auth_params() { $this->_auth->set_parameters( - array( + [ 'flickr_client_id' => $this->registry->get('GV_flickr_client_id') , 'flickr_client_secret' => $this->registry->get('GV_flickr_client_secret') , 'permissions' => 'delete' - ) + ] ); return $this; @@ -719,7 +719,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf public function check_update_constraints(Array $datas) { - $errors = array(); + $errors = []; $check = function ($field) use (&$errors, $datas) { $name = $field['name']; $length = (int) $field['length']; @@ -748,10 +748,10 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_update_datas(Request $request) { - $datas = array( + $datas = [ 'title' => $request->get('modif_title', ''), 'description' => $request->get('modif_description', '') - ); + ]; return $datas; } @@ -767,13 +767,13 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->get_serialize_key(); - $datas = array( + $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'category' => $request->get('category_' . $key), 'tags' => $request->get('tags_' . $key), 'privacy' => $request->get('privacy_' . $key), - ); + ]; return $datas; } @@ -793,23 +793,23 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ private function get_fields() { - return array( - array( + return [ + [ 'name' => 'title', 'length' => '100', 'required' => true - ) - , array( + ] + , [ 'name' => 'description', 'length' => '500', 'required' => false - ) - , array( + ] + , [ 'name' => 'tags', 'length' => '200', 'required' => false - ) - ); + ] + ]; } /** @@ -819,7 +819,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ private function check_record_constraints(record_adapter $record) { - $errors = array(); + $errors = []; if ( ! $record->get_hd_file() instanceof \SplFileInfo) $errors["file_size"] = _("Le record n'a pas de fichier physique"); //Record must rely on real file if ($record->get_technical_infos('size') > self::AUTH_PHOTO_SIZE) @@ -830,8 +830,8 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf private function checkTicket($ticketsId, $type) { - $return = array("status" => self::UPLOAD_STATE_FAILED, "dist_id" => null); - $response = $this->_api->executeMethod("flickr.photos.upload.checkTickets", array("tickets" => $ticketsId)); + $return = ["status" => self::UPLOAD_STATE_FAILED, "dist_id" => null]; + $response = $this->_api->executeMethod("flickr.photos.upload.checkTickets", ["tickets" => $ticketsId]); if ( ! $response->isOk()) throw new Bridge_Exception_ApiConnectorRequestFailed('Unable to retrieve element list ' . $type); diff --git a/lib/classes/Bridge/Api/Flickr/Element.php b/lib/classes/Bridge/Api/Flickr/Element.php index 87c58c53df..2a4cfb6481 100644 --- a/lib/classes/Bridge/Api/Flickr/Element.php +++ b/lib/classes/Bridge/Api/Flickr/Element.php @@ -42,7 +42,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface */ public function __construct(SimpleXMLElement $entry, $user_id, $type, $entry_from_list = true) { - $this->entry = array(); + $this->entry = []; $this->type = $type; if ($entry_from_list) @@ -80,7 +80,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface } $dates = $photo->dates; $visibility = $photo->visibility; - $tags = array(); + $tags = []; foreach ($photo->tags->tag as $one_tag) { $tags[] = $one_tag; } diff --git a/lib/classes/Bridge/Api/Interface.php b/lib/classes/Bridge/Api/Interface.php index 95ae4bfd85..78bf47efc4 100644 --- a/lib/classes/Bridge/Api/Interface.php +++ b/lib/classes/Bridge/Api/Interface.php @@ -152,7 +152,7 @@ interface Bridge_Api_Interface public function get_error_message_from_status($connector_status); - public function upload(record_adapter $record, array $options = array()); + public function upload(record_adapter $record, array $options = []); public function is_valid_object_id($object_id); diff --git a/lib/classes/Bridge/Api/Youtube.php b/lib/classes/Bridge/Api/Youtube.php index 32bd8bcfe5..bbd31f698d 100644 --- a/lib/classes/Bridge/Api/Youtube.php +++ b/lib/classes/Bridge/Api/Youtube.php @@ -167,7 +167,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_element_types() { - return array(self::ELEMENT_TYPE_VIDEO => _('Videos')); + return [self::ELEMENT_TYPE_VIDEO => _('Videos')]; } /** @@ -176,7 +176,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_container_types() { - return array(self::CONTAINER_TYPE_PLAYLIST => _('Playlists')); + return [self::CONTAINER_TYPE_PLAYLIST => _('Playlists')]; } /** @@ -297,7 +297,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function update_element($object, $object_id, Array $datas) { - $required_fields = array("description", "category", "tags", "title", "privacy"); + $required_fields = ["description", "category", "tags", "title", "privacy"]; foreach ($required_fields as $field) { if ( ! array_key_exists($field, $datas)) throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant"); @@ -626,7 +626,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ protected function parse_xml_error($string) { - $rs = array(); + $rs = []; libxml_use_internal_errors(true); $xml = simplexml_load_string($string); libxml_clear_errors(); @@ -636,7 +636,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter } if (isset($xml->HEAD) || isset($xml->head)) { - return array(); + return []; } else { $domaine = explode(":", (string) $xml->error[0]->domain); $rs['type'] = count($domaine) > 1 ? $domaine[1] : $domaine[0]; @@ -655,7 +655,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter * @param array $options * @return string The new distant Id */ - public function upload(record_adapter $record, array $options = array()) + public function upload(record_adapter $record, array $options = []) { switch ($record->get_type()) { case 'video': @@ -671,7 +671,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $video_entry->setVideoDescription($options['description']); $video_entry->setVideoCategory($options['category']); $video_entry->SetVideoTags(explode(' ', $options['tags'])); - $video_entry->setVideoDeveloperTags(array('phraseanet')); + $video_entry->setVideoDeveloperTags(['phraseanet']); if ($options['privacy'] == "public") $video_entry->setVideoPublic(); @@ -721,7 +721,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_category_list() { - $cat = array(); + $cat = []; $url_cat = sprintf('%s?hl=%s', self::CATEGORY_URL, $this->get_locale()); if (false === $cxml = simplexml_load_file($url_cat)) { @@ -815,7 +815,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter protected function set_auth_params() { $this->_auth->set_parameters( - array( + [ 'client_id' => $this->registry->get('GV_youtube_client_id') , 'client_secret' => $this->registry->get('GV_youtube_client_secret') , 'redirect_uri' => Bridge_Api::generate_callback_url($this->generator, $this->get_name()) @@ -823,7 +823,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter , 'response_type' => 'code' , 'token_endpoint' => self::OAUTH2_TOKEN_ENDPOINT , 'auth_endpoint' => self::OAUTH2_AUTHORIZE_ENDPOINT - ) + ] ); return $this; @@ -884,11 +884,11 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_locale() { - $youtube_available_locale = array( + $youtube_available_locale = [ 'zh-CN', 'zh-TW', 'cs-CZ', 'nl-NL', 'en-GB', 'en-US', 'fr-FR', 'de-DE', 'it-IT', 'ja-JP', 'ko-KR', 'pl-PL', 'pt-PT', 'ru-RU', 'es-ES', 'es-MX', 'sv-SE' - ); + ]; if ( ! is_null($this->locale)) { $youtube_format_locale = str_replace('_', '-', $this->locale); if (in_array(trim($youtube_format_locale), $youtube_available_locale)) { @@ -937,7 +937,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter public function check_update_constraints(Array $datas) { - $errors = array(); + $errors = []; $check = function ($field) use (&$errors, $datas) { $name = $field['name']; $length = (int) $field['length']; @@ -970,13 +970,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_update_datas(Request $request) { - $datas = array( + $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'category' => $request->get('modif_category'), 'tags' => $request->get('modif_tags'), 'privacy' => $request->get('modif_privacy'), - ); + ]; return $datas; } @@ -992,13 +992,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->get_serialize_key(); - $datas = array( + $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'category' => $request->get('category_' . $key), 'tags' => $request->get('tags_' . $key), 'privacy' => $request->get('privacy_' . $key), - ); + ]; return $datas; } @@ -1021,7 +1021,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ private function check_record_constraints(record_adapter $record) { - $errors = array(); + $errors = []; $key = $record->get_serialize_key(); if ( ! $record->get_hd_file() instanceof SplFileInfo) $errors["file_size_" . $key] = _("Le record n'a pas de fichier physique"); //Record must rely on real file @@ -1041,38 +1041,38 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ private function get_fields() { - return array( - array( + return [ + [ 'name' => 'title', 'length' => '100', 'required' => true, 'empty' => false - ) - , array( + ] + , [ 'name' => 'description', 'length' => '2000', 'required' => true, 'empty' => true - ) - , array( + ] + , [ 'name' => 'tags', 'length' => '500', 'tag_length' => '30', 'required' => true, 'empty' => true - ) - , array( + ] + , [ 'name' => 'privacy', 'length' => '0', 'required' => true, 'empty' => false - ) - , array( + ] + , [ 'name' => 'category', 'length' => '0', 'required' => true, 'empty' => false - ) - ); + ] + ]; } } diff --git a/lib/classes/Bridge/Element.php b/lib/classes/Bridge/Element.php index dc629427c3..969c61dd28 100644 --- a/lib/classes/Bridge/Element.php +++ b/lib/classes/Bridge/Element.php @@ -119,7 +119,7 @@ class Bridge_Element , title, serialized_datas, created_on, updated_on, uploaded_on FROM bridge_elements WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -190,11 +190,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET dist_id = :dist_id, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':dist_id' => $this->dist_id , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -225,11 +225,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET status = :status, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':status' => $this->status , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -261,11 +261,11 @@ class Bridge_Element SET connector_status = :connector_status, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':connector_status' => $this->connector_status , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -322,11 +322,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET title = :title, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':title' => $this->title , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -357,11 +357,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET serialized_datas = :datas, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':datas' => serialize($this->datas) , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -402,11 +402,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET uploaded_on = :uploaded_on, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':uploaded_on' => $this->uploaded_on ? $this->uploaded_on->format(DATE_ISO8601) : null , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -433,7 +433,7 @@ class Bridge_Element $sql = 'DELETE FROM bridge_elements WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -446,11 +446,11 @@ class Bridge_Element LIMIT ' . (int) $offset_start . ',' . (int) $quantity; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $account->get_id())); + $stmt->execute([':account_id' => $account->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); + $results = []; foreach ($rs as $row) { $results[] = new Bridge_Element($app, $account, $row['id']); @@ -459,7 +459,7 @@ class Bridge_Element return $results; } - public static function create(Application $app, Bridge_Account $account, record_adapter $record, $title, $status, $type, Array $datas = array()) + public static function create(Application $app, Bridge_Account $account, record_adapter $record, $title, $status, $type, Array $datas = []) { $sql = 'INSERT INTO bridge_elements (id, account_id, sbas_id, record_id, dist_id, title, `type` @@ -468,7 +468,7 @@ class Bridge_Element (null, :account_id, :sbas_id, :record_id, null, :title, :type ,:datas , :status, NOW(), NOW())'; - $params = array( + $params = [ ':account_id' => $account->get_id() , ':sbas_id' => $record->get_sbas_id() , ':record_id' => $record->get_record_id() @@ -476,7 +476,7 @@ class Bridge_Element , ':title' => $title , ':type' => $type , ':datas' => serialize($datas) - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Browser.php b/lib/classes/Browser.php index 6609f0b48e..c3a205dbae 100644 --- a/lib/classes/Browser.php +++ b/lib/classes/Browser.php @@ -712,13 +712,13 @@ class Browser if (stripos($this->_agent, 'msnb') !== false) { $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'MSN')); $this->setBrowser(self::BROWSER_MSN); - $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); + $this->setVersion(str_replace(['(', ')', ';'], '', $aresult[1])); return true; } $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); $this->setBrowser(self::BROWSER_IE); - $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); + $this->setVersion(str_replace(['(', ')', ';'], '', $aresult[1])); return true; } @@ -746,7 +746,7 @@ class Browser $this->setVersion(preg_replace("/[^0-9.]+/", "", $result[1])); // remove Gecko out of the user-agent, otherwise the mozilla check will success - $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); + $this->_agent = str_replace(["Mozilla", "Gecko"], "MSIE", $this->_agent); } return false; @@ -840,7 +840,7 @@ class Browser if (stripos($this->_agent, 'NetPositive') !== false) { $aresult = explode('/', stristr($this->_agent, 'NetPositive')); $aversion = explode(' ', $aresult[1]); - $this->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); + $this->setVersion(str_replace(['(', ')', ';'], '', $aversion[0])); $this->setBrowser(self::BROWSER_NETPOSITIVE); return true; @@ -1299,7 +1299,7 @@ class Browser { $this->_is_new_generation = false; - if (in_array($this->_browser_name, array('Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'))) { + if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) @@ -1337,7 +1337,7 @@ class Browser */ protected function checkHTML5() { - if (in_array($this->_browser_name, array('Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'))) { + if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) diff --git a/lib/classes/DailymotionWithoutOauth2.php b/lib/classes/DailymotionWithoutOauth2.php index 102fc5d5b5..0527a365ce 100644 --- a/lib/classes/DailymotionWithoutOauth2.php +++ b/lib/classes/DailymotionWithoutOauth2.php @@ -27,14 +27,13 @@ class DailymotionWithoutOauth2 extends Dailymotion * @throws DailymotionAuthRequiredException if not authentication info is available * @throws DailymotionTransportException if an error occurs during request. */ - public function call($method, $args = array(), $access_token = null) + public function call($method, $args = [], $access_token = null) { - $headers = array('Content-Type: application/json'); - $payload = json_encode(array - ( + $headers = ['Content-Type: application/json']; + $payload = json_encode([ 'call' => $method, 'args' => $args, - )); + ]); $status_code = null; try { @@ -77,10 +76,10 @@ class DailymotionWithoutOauth2 extends Dailymotion */ public function uploadFileWithToken($filePath, $oauth_token) { - $result = $this->call('file.upload', array(), $oauth_token); + $result = $this->call('file.upload', [], $oauth_token); $timeout = $this->timeout; $this->timeout = null; - $result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true); + $result = json_decode($this->httpRequest($result['upload_url'], ['file' => '@' . $filePath]), true); $this->timeout = $timeout; return $result['url']; diff --git a/lib/classes/Session/Logger.php b/lib/classes/Session/Logger.php index 7f1f2ed2b4..b1a46c5f25 100644 --- a/lib/classes/Session/Logger.php +++ b/lib/classes/Session/Logger.php @@ -74,13 +74,13 @@ class Session_Logger $stmt = $this->databox->get_connection()->prepare($sql); - $params = array( + $params = [ ':log_id' => $this->get_id() , ':record_id' => $record->get_record_id() , ':action' => $action , ':final' => $final , ':comm' => $comment - ); + ]; $stmt->execute($params); $stmt->closeCursor(); @@ -98,10 +98,10 @@ class Session_Logger */ public static function create(Application $app, databox $databox, Browser $browser) { - $colls = array(); + $colls = []; if ($app['authentication']->getUser()) { - $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id())); + $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]); foreach ($bases as $collection) { $colls[] = $collection->get_coll_id(); } @@ -118,7 +118,7 @@ class Session_Logger , :browser, :browser_version, :platform, :screen, :ip , :user_agent, :appli, :fonction, :company, :activity, :country)"; - $params = array( + $params = [ ':ses_id' => $app['session']->get('session_id'), ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_login() : null, ':site_id' => $app['configuration']['main']['key'], @@ -129,12 +129,12 @@ class Session_Logger ':screen' => $browser->getScreenSize(), ':ip' => $browser->getIP(), ':user_agent' => $browser->getUserAgent(), - ':appli' => serialize(array()), + ':appli' => serialize([]), ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_job() : null, ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_company() : null, ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_position() : null, ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_country() : null - ); + ]; $stmt = $conn->prepare($sql); $stmt->execute($params); @@ -145,10 +145,10 @@ class Session_Logger $stmt = $conn->prepare($sql); foreach ($colls as $collId) { - $stmt->execute(array( + $stmt->execute([ ':log_id' => $log_id, ':coll_id' => $collId - )); + ]); } $stmt->closeCursor(); @@ -166,10 +166,10 @@ class Session_Logger $sql = 'SELECT id FROM log WHERE site = :site AND sit_session = :ses_id'; - $params = array( + $params = [ ':site' => $app['configuration']['main']['key'] , ':ses_id' => $app['session']->get('session_id') - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); @@ -211,7 +211,7 @@ class Session_Logger $user = User_Adapter::getInstance($usrId, $app); - $appName = array( + $appName = [ '1' => 'Prod', '2' => 'Client', '3' => 'Admin', @@ -221,7 +221,7 @@ class Session_Logger '7' => 'Validate', '8' => 'Upload', '9' => 'API' - ); + ]; if (isset($appName[$appId])) { $sbas_ids = array_keys($app['acl']->get($user)->get_granted_sbas()); @@ -233,7 +233,7 @@ class Session_Logger $connbas = connection::getPDOConnection($app, $sbas_id); $sql = 'SELECT appli FROM log WHERE id = :log_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':log_id' => $logger->get_id())); + $stmt->execute([':log_id' => $logger->get_id()]); $row3 = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -247,10 +247,10 @@ class Session_Logger $sql = 'UPDATE log SET appli = :applis WHERE id = :log_id'; - $params = array( + $params = [ ':applis' => serialize($applis) , ':log_id' => $logger->get_id() - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Setup/Upgrade.php b/lib/classes/Setup/Upgrade.php index e45d85202f..0eec13f186 100644 --- a/lib/classes/Setup/Upgrade.php +++ b/lib/classes/Setup/Upgrade.php @@ -39,7 +39,7 @@ class Setup_Upgrade * * @var array */ - protected $recommendations = array(); + protected $recommendations = []; /** * @@ -135,7 +135,7 @@ class Setup_Upgrade */ public function addRecommendation($recommendation, $command = null) { - $this->recommendations[] = array($recommendation, $command); + $this->recommendations[] = [$recommendation, $command]; } /** @@ -171,13 +171,13 @@ class Setup_Upgrade $date_obj = new DateTime(); $dumper = new Symfony\Component\Yaml\Dumper(); $datas = $dumper->dump( - array( + [ 'percentage' => $this->get_percentage() , 'total_steps' => $this->total_steps , 'completed_steps' => $this->completed_steps , 'message' => $this->message , 'last_update' => $date_obj->format(DATE_ATOM) - ), 1 + ], 1 ); if (!file_put_contents(self::get_lock_file(), $datas)) @@ -241,14 +241,14 @@ class Setup_Upgrade { $active = self::lock_exists(); - $datas = array( + $datas = [ 'active' => $active , 'percentage' => 1 , 'total_steps' => 0 , 'completed_steps' => 0 , 'message' => null , 'last_update' => null - ); + ]; if ($active) { $parser = new Symfony\Component\Yaml\Parser(); diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php index 623c1cef43..8ee7e9e78f 100644 --- a/lib/classes/User/Adapter.php +++ b/lib/classes/User/Adapter.php @@ -32,44 +32,44 @@ class User_Adapter implements User_Interface, cache_cacheableInterface * * @var Array */ - public static $locales = array( + public static $locales = [ 'ar_SA' => 'العربية' , 'de_DE' => 'Deutsch' , 'nl_NL' => 'Dutch' , 'en_GB' => 'English' , 'es_ES' => 'Español' , 'fr_FR' => 'Français' - ); + ]; /** * * @var array */ - protected static $_instance = array(); + protected static $_instance = []; /** * * @var array */ - protected $_prefs = array(); + protected $_prefs = []; /** * * @var array */ - protected static $_users = array(); + protected static $_users = []; /** * * @var array */ - protected $_updated_prefs = array(); + protected $_updated_prefs = []; /** * * @var array */ - public static $def_values = array( + public static $def_values = [ 'view' => 'thumbs', 'images_per_page' => 20, 'images_size' => 120, @@ -91,21 +91,21 @@ class User_Adapter implements User_Interface, cache_cacheableInterface 'basket_caption_display' => '0', 'basket_status_display' => '0', 'basket_title_display' => '0' - ); + ]; /** * * @var array */ - protected static $available_values = array( - 'view' => array('thumbs', 'list'), - 'basket_sort_field' => array('name', 'date'), - 'basket_sort_order' => array('ASC', 'DESC'), - 'start_page' => array('PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'), - 'technical_display' => array('0', '1', 'group'), - 'rollover_thumbnail' => array('caption', 'preview'), - 'bask_val_order' => array('nat', 'asc', 'desc') - ); + protected static $available_values = [ + 'view' => ['thumbs', 'list'], + 'basket_sort_field' => ['name', 'date'], + 'basket_sort_order' => ['ASC', 'DESC'], + 'start_page' => ['PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'], + 'technical_display' => ['0', '1', 'group'], + 'rollover_thumbnail' => ['caption', 'preview'], + 'bask_val_order' => ['nat', 'asc', 'desc'] + ]; /** * @@ -362,7 +362,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $password = $this->app['auth.password-encoder']->encodePassword($pasword, $this->get_nonce()); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':password' => $password, ':usr_id' => $this->get_id())); + $stmt->execute([':password' => $password, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->password = $password; @@ -389,7 +389,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':new_email' => $email, ':usr_id' => $this->get_id())); + $stmt->execute([':new_email' => $email, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->email = $email; $this->delete_data_from_cache(); @@ -432,7 +432,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $conn = connection::getPDOConnection($app); $sql = 'SELECT usr_id FROM usr WHERE usr_login = :login'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':login' => trim($login))); + $stmt->execute([':login' => trim($login)]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -451,7 +451,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $value = $boolean ? '1' : '0'; $sql = 'UPDATE usr SET mail_notifications = :mail_notifications WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':mail_notifications' => $value, ':usr_id' => $this->get_id())); + $stmt->execute([':mail_notifications' => $value, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->mail_notifications = !!$boolean; $this->delete_data_from_cache(); @@ -469,7 +469,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $value = $boolean ? '1' : '0'; $sql = 'UPDATE usr SET ldap_created = :ldap_created WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':ldap_created' => $value, ':usr_id' => $this->get_id())); + $stmt->execute([':ldap_created' => $value, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->ldap_created = $boolean; @@ -480,7 +480,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET usr_prenom = :usr_prenom WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_prenom' => $firstname, ':usr_id' => $this->get_id())); + $stmt->execute([':usr_prenom' => $firstname, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->firstname = $firstname; $this->delete_data_from_cache(); @@ -492,7 +492,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET usr_nom = :usr_nom WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_nom' => $lastname, ':usr_id' => $this->get_id())); + $stmt->execute([':usr_nom' => $lastname, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->lastname = $lastname; $this->delete_data_from_cache(); @@ -504,7 +504,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET adresse = :adresse WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':adresse' => $address, ':usr_id' => $this->get_id())); + $stmt->execute([':adresse' => $address, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->address = $address; $this->delete_data_from_cache(); @@ -516,7 +516,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET ville = :city WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':city' => $city, ':usr_id' => $this->get_id())); + $stmt->execute([':city' => $city, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->city = $city; $this->delete_data_from_cache(); @@ -542,11 +542,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET geonameid = :geonameid, pays=:country_code WHERE usr_id = :usr_id'; - $datas = array( + $datas = [ ':geonameid' => $geonameid, ':usr_id' => $this->get_id(), ':country_code' => $country_code - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($datas); @@ -562,7 +562,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET cpostal = :cpostal WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':cpostal' => $zip, ':usr_id' => $this->get_id())); + $stmt->execute([':cpostal' => $zip, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->zip = $zip; $this->delete_data_from_cache(); @@ -574,7 +574,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET usr_sexe = :usr_sexe WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_sexe' => $gender, ':usr_id' => $this->get_id())); + $stmt->execute([':usr_sexe' => $gender, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->gender = $gender; $this->delete_data_from_cache(); @@ -586,7 +586,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET tel = :tel WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':tel' => $tel, ':usr_id' => $this->get_id())); + $stmt->execute([':tel' => $tel, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->tel = $tel; $this->delete_data_from_cache(); @@ -598,7 +598,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET fax = :fax WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':fax' => $fax, ':usr_id' => $this->get_id())); + $stmt->execute([':fax' => $fax, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->fax = $fax; $this->delete_data_from_cache(); @@ -610,7 +610,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET fonction = :fonction WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':fonction' => $job, ':usr_id' => $this->get_id())); + $stmt->execute([':fonction' => $job, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->job = $job; $this->delete_data_from_cache(); @@ -622,7 +622,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET activite = :activite WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':activite' => $position, ':usr_id' => $this->get_id())); + $stmt->execute([':activite' => $position, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->position = $position; $this->delete_data_from_cache(); @@ -634,7 +634,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET societe = :company WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':company' => $company, ':usr_id' => $this->get_id())); + $stmt->execute([':company' => $company, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->company = $company; $this->delete_data_from_cache(); @@ -652,7 +652,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET model_of = :owner_id WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id())); + $stmt->execute([':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this @@ -687,9 +687,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function getFtpCredential() { if (null === $this->ftpCredential) { - $this->ftpCredential = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FtpCredential')->findOneBy(array( + $this->ftpCredential = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FtpCredential')->findOneBy([ 'usrId' => $this->get_id() - )); + ]); if (null === $this->ftpCredential) { $this->ftpCredential = new FtpCredential(); @@ -707,7 +707,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function is_special() { - return in_array($this->login, array('invite', 'autoregister')); + return in_array($this->login, ['invite', 'autoregister']); } public function get_template_owner() @@ -727,7 +727,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface AND usr_login NOT LIKE "(#deleted_%" AND invite="0" AND usr_login != "autoregister"'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':email' => trim($email))); + $stmt->execute([':email' => trim($email)]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -762,42 +762,42 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_login = :usr_login , usr_mail = null WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id())); + $stmt->execute([':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM basusr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM sbasusr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM dsel WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM edit_presets WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM sselnew WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM tokens WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM usr_settings WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); unset(self::$_instance[$this->get_id()]); @@ -823,7 +823,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface FROM usr WHERE usr_id= :id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $id)); + $stmt->execute([':id' => $id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -876,10 +876,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET lastModel = :template_id WHERE usr_id = :usr_id'; - $params = array( + $params = [ ':usr_id' => $this->get_id() , ':template_id' => $template->get_login() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -893,7 +893,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET mail_locked = :mail_locked WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0'))); + $stmt->execute([':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0')]); $stmt->closeCursor(); $this->mail_locked = !!$boolean; @@ -1005,7 +1005,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); @@ -1039,7 +1039,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -1136,11 +1136,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface VALUES (:usr_id, :prop, :value)'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':usr_id' => $this->id, ':prop' => $prop, ':value' => $value - )); + ]); $this->delete_data_from_cache(); } catch (Exception $e) { @@ -1217,7 +1217,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $users = array(); + $users = []; foreach ($rs as $row) $users[$row['usr_id']] = $row['usr_login']; @@ -1230,7 +1230,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface try { $sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $stmt->closeCursor(); $sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")"; @@ -1259,7 +1259,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET locale = :locale WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':locale' => $locale, ':usr_id' => $this->get_id())); + $stmt->execute([':locale' => $locale, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -1293,14 +1293,14 @@ class User_Adapter implements User_Interface, cache_cacheableInterface VALUES (null, :login, :password, NOW(), :email, :admin, :nonce, 1, :invite)'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':login' => $login, ':nonce' => $nonce, ':password' => $app['auth.password-encoder']->encodePassword($password, $nonce), ':email' => ($email ? $email : null), ':admin' => ($admin ? '1' : '0'), ':invite' => ($invite ? '1' : '0') - )); + ]); $stmt->closeCursor(); $usr_id = $conn->lastInsertId(); @@ -1314,7 +1314,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_login = :login WHERE usr_id = :usr_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':login' => 'invite'.$usr_id, ':usr_id' => $usr_id)); + $stmt->execute([':login' => 'invite'.$usr_id, ':usr_id' => $usr_id]); $stmt->closeCursor(); } @@ -1333,7 +1333,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'SELECT nonce FROM usr WHERE usr_id = :usr_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); @@ -1347,9 +1347,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function __sleep() { - $vars = array(); + $vars = []; foreach ($this as $key => $value) { - if (in_array($key, array('ACL', 'app'))) + if (in_array($key, ['ACL', 'app'])) continue; $vars[] = $key; } diff --git a/lib/classes/User/Query.php b/lib/classes/User/Query.php index f196a1b7c1..b33d7d4671 100644 --- a/lib/classes/User/Query.php +++ b/lib/classes/User/Query.php @@ -30,19 +30,19 @@ class User_Query implements User_QueryInterface * * @var Array */ - protected $results = array(); + protected $results = []; /** * * @var Array */ - protected $sort = array(); + protected $sort = []; /** * * @var Array */ - protected $like_field = array(); + protected $like_field = []; /** * @@ -78,13 +78,13 @@ class User_Query implements User_QueryInterface * * @var Array */ - protected $active_bases = array(); + protected $active_bases = []; /** * * @var Array */ - protected $active_sbas = array(); + protected $active_sbas = []; /** * @@ -120,13 +120,13 @@ class User_Query implements User_QueryInterface * * @var Array */ - protected $base_ids = array(); + protected $base_ids = []; /** * * @var Array */ - protected $sbas_ids = array(); + protected $sbas_ids = []; /** * @@ -211,7 +211,7 @@ class User_Query implements User_QueryInterface */ protected function generate_sql_constraints() { - $this->sql_params = array(); + $this->sql_params = []; $sql = ' FROM usr LEFT JOIN basusr ON (usr.usr_id = basusr.usr_id) @@ -324,12 +324,12 @@ class User_Query implements User_QueryInterface $sql .= ' AND usr.lastModel = "' . mysql_real_escape_string($this->last_model) . '" '; } - $sql_like = array(); + $sql_like = []; foreach ($this->like_field as $like_field => $like_value) { switch ($like_field) { case self::LIKE_NAME: - $qrys = array(); + $qrys = []; foreach (explode(' ', $like_value) as $like_val) { if (trim($like_val) === '') continue; @@ -338,9 +338,9 @@ class User_Query implements User_QueryInterface ' (usr.`%s` LIKE "%s%%" COLLATE utf8_unicode_ci OR usr.`%s` LIKE "%s%%" COLLATE utf8_unicode_ci) ' , self::LIKE_FIRSTNAME - , str_replace(array('"', '%'), array('\"', '\%'), $like_val) + , str_replace(['"', '%'], ['\"', '\%'], $like_val) , self::LIKE_LASTNAME - , str_replace(array('"', '%'), array('\"', '\%'), $like_val) + , str_replace(['"', '%'], ['\"', '\%'], $like_val) ); } @@ -357,7 +357,7 @@ class User_Query implements User_QueryInterface $sql_like[] = sprintf( ' usr.`%s` LIKE "%s%%" COLLATE utf8_unicode_ci ' , $like_field - , str_replace(array('"', '%'), array('\"', '\%'), $like_value) + , str_replace(['"', '%'], ['\"', '\%'], $like_value) ); break; default; @@ -374,7 +374,7 @@ class User_Query implements User_QueryInterface protected function generate_field_constraints($fieldName, ArrayCollection $fields) { $n = 0; - $constraints = array(); + $constraints = []; foreach ($fields as $field) { $constraints[':' . $fieldName . $n ++] = $field; @@ -389,7 +389,7 @@ class User_Query implements User_QueryInterface public function in(array $usr_ids) { - $tmp_usr_ids = array(); + $tmp_usr_ids = []; foreach ($usr_ids as $usr_id) { $tmp_usr_ids[] = (int) $usr_id; @@ -889,7 +889,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $activities = array(); + $activities = []; foreach ($rs as $row) { if (trim($row['activite']) === '') @@ -914,7 +914,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $fonction = array(); + $fonction = []; foreach ($rs as $row) { if (trim($row['fonction']) === '') @@ -941,7 +941,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $pays = array(); + $pays = []; $ctry = \getCountries($this->app['locale']); @@ -969,7 +969,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $societe = array(); + $societe = []; foreach ($rs as $row) { if (trim($row['societe']) === '') @@ -994,7 +994,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $lastModel = array(); + $lastModel = []; foreach ($rs as $row) { if (trim($row['lastModel']) === '') @@ -1008,7 +1008,7 @@ class User_Query implements User_QueryInterface private function generate_sort_constraint() { - $sorter = array(); + $sorter = []; foreach ($this->sort as $sort => $ord) { diff --git a/lib/classes/appbox.php b/lib/classes/appbox.php index a473fce36e..9120f2252c 100644 --- a/lib/classes/appbox.php +++ b/lib/classes/appbox.php @@ -82,7 +82,7 @@ class appbox extends base if (!is_null($pathfile)) { - if (!in_array(mb_strtolower($pathfile->getMimeType()), array('image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'))) { + if (!in_array(mb_strtolower($pathfile->getMimeType()), ['image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'])) { throw new \InvalidArgumentException('Invalid file format'); } @@ -146,7 +146,7 @@ class appbox extends base $file = $this->app['root.path'] . '/config/' . $pic_type . '/' . $collection->get_base_id(); $custom_path = $this->app['root.path'] . '/www/custom/' . $pic_type . '/' . $collection->get_base_id(); - foreach (array($file, $custom_path) as $target) { + foreach ([$file, $custom_path] as $target) { if (is_file($target)) { @@ -171,12 +171,12 @@ class appbox extends base if (!is_null($pathfile)) { - if (!in_array(mb_strtolower($pathfile->getMimeType()), array('image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/gif'))) { + if (!in_array(mb_strtolower($pathfile->getMimeType()), ['image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/gif'])) { throw new \InvalidArgumentException('Invalid file format'); } } - if (!in_array($pic_type, array(databox::PIC_PDF))) { + if (!in_array($pic_type, [databox::PIC_PDF])) { throw new \InvalidArgumentException('unknown pic_type'); } @@ -201,7 +201,7 @@ class appbox extends base $file = $this->app['root.path'] . '/config/minilogos/' . $pic_type . '_' . $databox->get_sbas_id() . '.jpg'; $custom_path = $this->app['root.path'] . '/www/custom/minilogos/' . $pic_type . '_' . $databox->get_sbas_id() . '.jpg'; - foreach (array($file, $custom_path) as $target) { + foreach ([$file, $custom_path] as $target) { if (is_file($target)) { $filesystem->remove($target); @@ -231,7 +231,7 @@ class appbox extends base { $sqlupd = "UPDATE bas SET ord = :ordre WHERE base_id = :base_id"; $stmt = $this->get_connection()->prepare($sqlupd); - $stmt->execute(array(':ordre' => $ordre, ':base_id' => $collection->get_base_id())); + $stmt->execute([':ordre' => $ordre, ':base_id' => $collection->get_base_id()]); $stmt->closeCursor(); $collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS); @@ -251,10 +251,10 @@ class appbox extends base $sql = 'UPDATE sbas SET indexable = :indexable WHERE sbas_id = :sbas_id'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':indexable' => ($boolean ? '1' : '0'), ':sbas_id' => $databox->get_sbas_id() - )); + ]); $stmt->closeCursor(); return $this; @@ -270,7 +270,7 @@ class appbox extends base $sql = 'SELECT indexable FROM sbas WHERE sbas_id = :sbas_id'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':sbas_id' => $databox->get_sbas_id())); + $stmt->execute([':sbas_id' => $databox->get_sbas_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -322,13 +322,13 @@ class appbox extends base $upgrader->set_current_message(_('Purging directories')); $finder = new Finder(); - $finder->in(array( + $finder->in([ $this->app['root.path'] . '/tmp/cache_minify/', $this->app['root.path'] . '/tmp/cache_twig/', $this->app['root.path'] . '/tmp/cache/profiler/', $this->app['root.path'] . '/tmp/doctrine/', $this->app['root.path'] . '/tmp/serializer/', - )) + ]) ->depth(0) ->ignoreVCS(true) ->ignoreDotFiles(true); @@ -344,19 +344,19 @@ class appbox extends base */ $upgrader->set_current_message(_('Copying files')); - foreach (array( + foreach ([ 'config/custom_files/' => 'www/custom/', 'config/minilogos/' => 'www/custom/minilogos/', 'config/stamp/' => 'www/custom/stamp/', 'config/status/' => 'www/custom/status/', 'config/wm/' => 'www/custom/wm/', - ) as $source => $target) { + ] as $source => $target) { $app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target); } $upgrader->add_steps_complete(1); - $advices = array(); + $advices = []; /** * Step 6 @@ -430,7 +430,7 @@ class appbox extends base return $this->databoxes; } - $ret = array(); + $ret = []; foreach ($this->retrieve_sbas_ids() as $sbas_id) { try { $ret[$sbas_id] = new \databox($this->app, $sbas_id); @@ -453,7 +453,7 @@ class appbox extends base } $sql = 'SELECT sbas_id FROM sbas'; - $ret = array(); + $ret = []; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); diff --git a/lib/classes/appbox/register.php b/lib/classes/appbox/register.php index 444cb0f0c0..ed43889d33 100644 --- a/lib/classes/appbox/register.php +++ b/lib/classes/appbox/register.php @@ -51,7 +51,7 @@ class appbox_register $sql = "INSERT INTO demand (date_modif, usr_id, base_id, en_cours, refuser) VALUES (now(), :usr_id , :base_id, 1, 0)"; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id(), ':base_id' => $collection->get_base_id())); + $stmt->execute([':usr_id' => $user->get_id(), ':base_id' => $collection->get_base_id()]); $stmt->closeCursor(); return $this; @@ -70,10 +70,10 @@ class appbox_register { $sql = 'SELECT base_id FROM demand WHERE usr_id = :usr_id AND en_cours="1" '; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $ret[] = collection::get_from_base_id($app, $row['base_id']); } @@ -92,7 +92,7 @@ class appbox_register $lastMonth = new DateTime('-1 month'); $sql = "delete from demand where date_modif < :lastMonth"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':lastMonth' => $lastMonth->format(DATE_ISO8601))); + $stmt->execute([':lastMonth' => $lastMonth->format(DATE_ISO8601)]); $stmt->closeCursor(); return; diff --git a/lib/classes/base.php b/lib/classes/base.php index a6d06cd5d1..e68298a654 100644 --- a/lib/classes/base.php +++ b/lib/classes/base.php @@ -190,7 +190,7 @@ abstract class base implements cache_cacheableInterface { $appbox = $this->get_base_type() == self::APPLICATION_BOX ? $this : $this->get_appbox(); if ($option === appbox::CACHE_LIST_BASES) { - $keys = array($this->get_cache_key(appbox::CACHE_LIST_BASES)); + $keys = [$this->get_cache_key(appbox::CACHE_LIST_BASES)]; phrasea::reset_sbasDatas($appbox); phrasea::reset_baseDatas($appbox); phrasea::clear_sbas_params($this->app); @@ -244,9 +244,9 @@ abstract class base implements cache_cacheableInterface protected function upgradeDb($apply_patches, Setup_Upgrade $upgrader, Application $app) { - $recommends = array(); + $recommends = []; - $allTables = array(); + $allTables = []; $schema = $this->get_schema(); @@ -262,7 +262,7 @@ abstract class base implements cache_cacheableInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ORMTables = array( + $ORMTables = [ 'AuthFailures', 'AggregateTokens', 'BasketElements', @@ -296,7 +296,7 @@ abstract class base implements cache_cacheableInterface 'UserSettings', 'Users', 'UserNotificationSettings', - ); + ]; foreach ($rs as $row) { $tname = $row["Name"]; @@ -306,17 +306,17 @@ abstract class base implements cache_cacheableInterface $engine = strtolower(trim($allTables[$tname]->engine)); $ref_engine = strtolower($row['Engine']); - if ($engine != $ref_engine && in_array($engine, array('innodb', 'myisam'))) { + if ($engine != $ref_engine && in_array($engine, ['innodb', 'myisam'])) { $sql = 'ALTER TABLE `' . $tname . '` ENGINE = ' . $engine; try { $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (Exception $e) { - $recommends[] = array( + $recommends[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $sql - ); + ]; } } @@ -325,10 +325,10 @@ abstract class base implements cache_cacheableInterface unset($allTables[$tname]); $upgrader->add_steps_complete(1); } elseif ( ! in_array($tname, $ORMTables)) { - $recommends[] = array( + $recommends[] = [ 'message' => 'Une table pourrait etre supprime', 'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;' - ); + ]; } } @@ -361,7 +361,7 @@ abstract class base implements cache_cacheableInterface } if ($sql !== '') { $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':version' => $version->getNumber())); + $stmt->execute([':version' => $version->getNumber()]); $stmt->closeCursor(); $this->version = $version->getNumber(); @@ -423,7 +423,7 @@ abstract class base implements cache_cacheableInterface */ protected function createTable(SimpleXMLElement $table) { - $field_stmt = $defaults_stmt = array(); + $field_stmt = $defaults_stmt = []; $create_stmt = "CREATE TABLE `" . $table['name'] . "` ("; @@ -438,9 +438,9 @@ abstract class base implements cache_cacheableInterface $is_default = ''; $character_set = ''; - if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext')) + if (in_array(strtolower((string) $field->type), ['text', 'longtext', 'mediumtext', 'tinytext']) || substr(strtolower((string) $field->type), 0, 7) == 'varchar' - || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) { + || in_array(substr(strtolower((string) $field->type), 0, 4), ['char', 'enum'])) { $collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci'; @@ -459,7 +459,7 @@ abstract class base implements cache_cacheableInterface foreach ($table->indexes->index as $index) { switch ($index->type) { case "PRIMARY": - $primary_fields = array(); + $primary_fields = []; foreach ($index->fields->field as $field) { $primary_fields[] = "`" . $field . "`"; @@ -468,7 +468,7 @@ abstract class base implements cache_cacheableInterface $field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')'; break; case "UNIQUE": - $unique_fields = array(); + $unique_fields = []; foreach ($index->fields->field as $field) { $unique_fields[] = "`" . $field . "`"; @@ -477,7 +477,7 @@ abstract class base implements cache_cacheableInterface $field_stmt[] = 'UNIQUE KEY `' . $index->name . '` (' . implode(',', $unique_fields) . ')'; break; case "INDEX": - $index_fields = array(); + $index_fields = []; foreach ($index->fields->field as $field) { $index_fields[] = "`" . $field . "`"; @@ -490,7 +490,7 @@ abstract class base implements cache_cacheableInterface } if ($table->defaults) { foreach ($table->defaults->default as $default) { - $k = $v = $params = $dates_values = array(); + $k = $v = $params = $dates_values = []; $nonce = random::generatePassword(16); foreach ($default->data as $data) { $k = trim($data['key']); @@ -498,7 +498,7 @@ abstract class base implements cache_cacheableInterface $data = $this->app['auth.password-encoder']->encodePassword($data, $nonce); if ($k === 'nonce') $data = $nonce; - $v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data)); + $v = trim(str_replace(["\r\n", "\r", "\n", "\t"], '', $data)); if (trim(mb_strtolower($v)) == 'now()') $dates_values [$k] = 'NOW()'; @@ -508,19 +508,19 @@ abstract class base implements cache_cacheableInterface $separator = ((count($params) > 0 && count($dates_values) > 0) ? ', ' : ''); - $defaults_stmt[] = array( + $defaults_stmt[] = [ 'sql' => 'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params)) . $separator . implode(', ', array_keys($dates_values)) . ') VALUES (:' . implode(', :', array_keys($params)) . $separator . implode(', ', array_values($dates_values)) . ') ' , 'params' => $params - ); + ]; } } $engine = mb_strtolower(trim($table->engine)); - $engine = in_array($engine, array('innodb', 'myisam')) ? $engine : 'innodb'; + $engine = in_array($engine, ['innodb', 'myisam']) ? $engine : 'innodb'; $create_stmt .= implode(',', $field_stmt); $create_stmt .= ") ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_unicode_ci;"; @@ -535,10 +535,10 @@ abstract class base implements cache_cacheableInterface $stmt->execute($def['params']); $stmt->closeCursor(); } catch (Exception $e) { - $recommends[] = array( + $recommends[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $def['sql'] - ); + ]; } } @@ -547,8 +547,8 @@ abstract class base implements cache_cacheableInterface protected function upgradeTable(SimpleXMLElement $table) { - $correct_table = array('fields' => array(), 'indexes' => array(), 'collation' => array()); - $alter = $alter_pre = $return = array(); + $correct_table = ['fields' => [], 'indexes' => [], 'collation' => []]; + $alter = $alter_pre = $return = []; foreach ($table->fields->field as $field) { $expr = trim((string) $field->type); @@ -559,9 +559,9 @@ abstract class base implements cache_cacheableInterface $collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci'; - if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext')) + if (in_array(strtolower((string) $field->type), ['text', 'longtext', 'mediumtext', 'tinytext']) || substr(strtolower((string) $field->type), 0, 7) == 'varchar' - || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) { + || in_array(substr(strtolower((string) $field->type), 0, 4), ['char', 'enum'])) { $collations = array_reverse(explode('_', $collation)); $code = array_pop($collations); @@ -587,7 +587,7 @@ abstract class base implements cache_cacheableInterface if ($table->indexes) { foreach ($table->indexes->index as $index) { $i_name = (string) $index->name; - $expr = array(); + $expr = []; foreach ($index->fields->field as $field) $expr[] = '`' . trim((string) $field) . '`'; @@ -682,10 +682,10 @@ abstract class base implements cache_cacheableInterface } unset($correct_table['fields'][$f_name]); } else { - $return[] = array( + $return[] = [ 'message' => 'Un champ pourrait etre supprime', 'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;" - ); + ]; } } @@ -693,7 +693,7 @@ abstract class base implements cache_cacheableInterface $alter[] = "ALTER TABLE `" . $table['name'] . "` ADD `$f_name` " . $correct_table['fields'][$f_name]; } - $tIndex = array(); + $tIndex = []; $sql = "SHOW INDEXES FROM `" . $table['name'] . "`"; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); @@ -702,12 +702,12 @@ abstract class base implements cache_cacheableInterface foreach ($rs2 as $row2) { if ( ! isset($tIndex[$row2['Key_name']])) - $tIndex[$row2['Key_name']] = array('unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => array()); + $tIndex[$row2['Key_name']] = ['unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => []]; $tIndex[$row2['Key_name']]['columns'][(int) ($row2['Seq_in_index'])] = $row2['Column_name']; } foreach ($tIndex as $kIndex => $vIndex) { - $strColumns = array(); + $strColumns = []; foreach ($vIndex['columns'] as $column) $strColumns[] = '`' . $column . '`'; @@ -733,10 +733,10 @@ abstract class base implements cache_cacheableInterface unset($correct_table['indexes'][$kIndex]); } else { - $return[] = array( + $return[] = [ 'message' => 'Un index pourrait etre supprime', 'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';' - ); + ]; } } @@ -749,10 +749,10 @@ abstract class base implements cache_cacheableInterface $stmt->execute(); $stmt->closeCursor(); } catch (Exception $e) { - $return[] = array( + $return[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $a - ); + ]; } } @@ -762,10 +762,10 @@ abstract class base implements cache_cacheableInterface $stmt->execute(); $stmt->closeCursor(); } catch (Exception $e) { - $return[] = array( + $return[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $a - ); + ]; } } @@ -778,7 +778,7 @@ abstract class base implements cache_cacheableInterface return true; } - $list_patches = array(); + $list_patches = []; $upgrader->add_steps(1)->set_current_message(_('Looking for patches')); diff --git a/lib/classes/cache/databox.php b/lib/classes/cache/databox.php index 8275df3f97..7ec25c2461 100644 --- a/lib/classes/cache/databox.php +++ b/lib/classes/cache/databox.php @@ -62,7 +62,7 @@ class cache_databox $sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id'; $stmt = $connsbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -89,10 +89,10 @@ class cache_databox $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="record" AND value = :value'; - $params = array( + $params = [ ':site_id' => $app['phraseanet.registry']->get('GV_ServerName') , ':value' => $row['value'] - ); + ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); @@ -113,10 +113,10 @@ class cache_databox $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="structure" AND value = :value'; - $params = array( + $params = [ ':site_id' => $app['phraseanet.registry']->get('GV_ServerName') , ':value' => $row['value'] - ); + ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); @@ -134,7 +134,7 @@ class cache_databox $sql = 'UPDATE sitepreff SET memcached_update = :date'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':date' => $now)); + $stmt->execute([':date' => $now]); $stmt->closeCursor(); self::$refreshing = false; @@ -158,7 +158,7 @@ class cache_databox WHERE site_id != :site_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -168,7 +168,7 @@ class cache_databox $stmt = $connbas->prepare($sql); foreach ($rs as $row) { - $stmt->execute(array(':site_id' => $row['site_id'], ':type' => $type, ':value' => $value)); + $stmt->execute([':site_id' => $row['site_id'], ':type' => $type, ':value' => $value]); } $stmt->closeCursor(); @@ -182,7 +182,7 @@ class cache_databox $sql = 'SELECT site_id FROM clients WHERE site_id = :site_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $rowCount = $stmt->rowCount(); $stmt->closeCursor(); @@ -192,7 +192,7 @@ class cache_databox $sql = 'INSERT INTO clients (site_id) VALUES (:site_id)'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $stmt->closeCursor(); return; diff --git a/lib/classes/caption/Field/Value.php b/lib/classes/caption/Field/Value.php index b1722c1632..af9190449d 100644 --- a/lib/classes/caption/Field/Value.php +++ b/lib/classes/caption/Field/Value.php @@ -56,7 +56,7 @@ class caption_Field_Value implements cache_cacheableInterface protected $record; protected $app; - protected static $localCache = array(); + protected static $localCache = []; /** * @@ -96,7 +96,7 @@ class caption_Field_Value implements cache_cacheableInterface FROM metadatas WHERE id = :id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -133,11 +133,11 @@ class caption_Field_Value implements cache_cacheableInterface } } - $datas = array( + $datas = [ 'value' => $this->value, 'vocabularyId' => $this->VocabularyId, 'vocabularyType' => $this->VocabularyType ? $this->VocabularyType->getType() : null, - ); + ]; $this->set_data_to_cache($datas); @@ -185,7 +185,7 @@ class caption_Field_Value implements cache_cacheableInterface $sql = 'DELETE FROM metadatas WHERE id = :id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -200,11 +200,11 @@ class caption_Field_Value implements cache_cacheableInterface { $connbas = $this->databox_field->get_connection(); - $params = array( + $params = [ ':VocabType' => null , ':VocabularyId' => null , ':meta_id' => $this->getId() - ); + ]; $sql_up = 'UPDATE metadatas SET VocabularyType = :VocabType, VocabularyId = :VocabularyId @@ -224,11 +224,11 @@ class caption_Field_Value implements cache_cacheableInterface { $connbas = $this->databox_field->get_connection(); - $params = array( + $params = [ ':VocabType' => $vocabulary->getType() , ':VocabularyId' => $vocab_id , ':meta_id' => $this->getId() - ); + ]; $sql_up = 'UPDATE metadatas SET VocabularyType = :VocabType, VocabularyId = :VocabularyId @@ -248,10 +248,10 @@ class caption_Field_Value implements cache_cacheableInterface $connbas = $this->databox_field->get_connection(); - $params = array( + $params = [ ':meta_id' => $this->id , ':value' => $value - ); + ]; $sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id'; $stmt_up = $connbas->prepare($sql_up); @@ -309,13 +309,13 @@ class caption_Field_Value implements cache_cacheableInterface VALUES (null, :record_id, :field, :value, :VocabType, :VocabId)'; - $params = array( + $params = [ ':record_id' => $record->get_record_id(), ':field' => $databox_field->get_id(), ':value' => $value, ':VocabType' => $vocabulary ? $vocabulary->getType() : null, ':VocabId' => $vocabulary ? $vocabularyId : null, - ); + ]; $stmt_ins = $connbas->prepare($sql_ins); $stmt_ins->execute($params); @@ -355,7 +355,7 @@ class caption_Field_Value implements cache_cacheableInterface $fvalue = $value; - $cleanvalue = str_replace(array("", "", "'"), array("", "", "'"), $fvalue); + $cleanvalue = str_replace(["", "", "'"], ["", "", "'"], $fvalue); list($term_noacc, $context_noacc) = $this->splitTermAndContext($cleanvalue); $term_noacc = $this->app['unicode']->remove_indexer_chars($term_noacc); @@ -375,8 +375,8 @@ class caption_Field_Value implements cache_cacheableInterface if ($node->getAttribute("lng") == $this->app['locale.I18n']) { // le terme est dans la bonne langue, on le rend cliquable list($term, $context) = $this->splitTermAndContext($fvalue); - $term = str_replace(array("", ""), array("", ""), $term); - $context = str_replace(array("", ""), array("", ""), $context); + $term = str_replace(["", ""], ["", ""], $term); + $context = str_replace(["", ""], ["", ""], $context); $qjs = $term; if ($context) { $qjs .= " [" . $context . "]"; @@ -400,8 +400,8 @@ class caption_Field_Value implements cache_cacheableInterface } if (! $lngfound) { list($term, $context) = $this->splitTermAndContext($fvalue); - $term = str_replace(array("", ""), array("", ""), $term); - $context = str_replace(array("", ""), array("", ""), $context); + $term = str_replace(["", ""], ["", ""], $term); + $context = str_replace(["", ""], ["", ""], $context); $qjs = $term; if ($context) { $qjs .= " [" . $context . "]"; @@ -439,7 +439,7 @@ class caption_Field_Value implements cache_cacheableInterface } } - return array($term, $context); + return [$term, $context]; } /** diff --git a/lib/classes/caption/field.php b/lib/classes/caption/field.php index b3cd6299a2..7bacd1d696 100644 --- a/lib/classes/caption/field.php +++ b/lib/classes/caption/field.php @@ -38,7 +38,7 @@ class caption_field implements cache_cacheableInterface protected $record; protected $app; - protected static $localCache = array(); + protected static $localCache = []; /** * @@ -53,7 +53,7 @@ class caption_field implements cache_cacheableInterface $this->app = $app; $this->record = $record; $this->databox_field = $databox_field; - $this->values = array(); + $this->values = []; $rs = $this->get_metadatas_ids(); @@ -85,10 +85,10 @@ class caption_field implements cache_cacheableInterface WHERE record_id = :record_id AND meta_struct_id = :meta_struct_id'; - $params = array( + $params = [ ':record_id' => $this->record->get_record_id() , ':meta_struct_id' => $this->databox_field->get_id() - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -166,7 +166,7 @@ class caption_field implements cache_cacheableInterface else $separator = ' ' . $separator . ' '; - $array_values = array(); + $array_values = []; foreach ($values as $value) { if ($highlight) @@ -281,7 +281,7 @@ class caption_field implements cache_cacheableInterface */ public static function get_multi_values($serialized_value, $separator) { - $values = array(); + $values = []; if (strlen($separator) == 1) { $values = explode($separator, $serialized_value); } else { @@ -304,9 +304,9 @@ class caption_field implements cache_cacheableInterface $sql = 'SELECT count(id) as count_id FROM metadatas WHERE meta_struct_id = :meta_struct_id'; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt->execute($params); $rowcount = $stmt->rowCount(); @@ -319,9 +319,9 @@ class caption_field implements cache_cacheableInterface $sql = 'SELECT record_id, id FROM metadatas WHERE meta_struct_id = :meta_struct_id LIMIT ' . $n . ', ' . $increment; - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -333,7 +333,7 @@ class caption_field implements cache_cacheableInterface foreach ($rs as $row) { try { $record = $databox_field->get_databox()->get_record($row['record_id']); - $record->set_metadatas(array()); + $record->set_metadatas([]); /** * TODO NEUTRON add App @@ -357,9 +357,9 @@ class caption_field implements cache_cacheableInterface WHERE meta_struct_id = :meta_struct_id'; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt->execute($params); $rowcount = $stmt->rowCount(); @@ -373,9 +373,9 @@ class caption_field implements cache_cacheableInterface WHERE meta_struct_id = :meta_struct_id LIMIT ' . $n . ', ' . $increment; - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -389,7 +389,7 @@ class caption_field implements cache_cacheableInterface $record = $databox_field->get_databox()->get_record($row['record_id']); $caption_field = new caption_field($app, $databox_field, $record); $caption_field->delete(); - $record->set_metadatas(array()); + $record->set_metadatas([]); $app['phraseanet.SE']->updateRecord($record); unset($caption_field); diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index 2cd0253a34..b025f0937e 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -95,13 +95,13 @@ class caption_record implements caption_interface, cache_cacheableInterface protected function toArray($includeBusinessFields) { - $buffer = array(); + $buffer = []; - foreach ($this->get_fields(array(), $includeBusinessFields) as $field) { + foreach ($this->get_fields([], $includeBusinessFields) as $field) { $vi = $field->get_values(); if ($field->is_multi()) { - $buffer[$field->get_name()] = array(); + $buffer[$field->get_name()] = []; foreach ($vi as $value) { $val = $value->getValue(); $buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $this->sanitizeSerializedValue($val); @@ -113,7 +113,7 @@ class caption_record implements caption_interface, cache_cacheableInterface } } - return array('record' => array('description' => $buffer)); + return ['record' => ['description' => $buffer]]; } protected function serializeXML($includeBusinessFields) @@ -128,7 +128,7 @@ class caption_record implements caption_interface, cache_cacheableInterface $description = $dom_doc->createElement('description'); $record->appendChild($description); - foreach ($this->get_fields(array(), $includeBusinessFields) as $field) { + foreach ($this->get_fields([], $includeBusinessFields) as $field) { $values = $field->get_values(); foreach ($values as $value) { @@ -155,7 +155,7 @@ class caption_record implements caption_interface, cache_cacheableInterface private function sanitizeSerializedValue($value) { - return str_replace(array( + return str_replace([ "\x00", //null "\x01", //start heading "\x02", //start text @@ -184,7 +184,7 @@ class caption_record implements caption_interface, cache_cacheableInterface "\x1D", //group sep "\x1E", //record sep "\x1F", //unit sep - ), '', $value); + ], '', $value); } protected function retrieve_fields() @@ -193,7 +193,7 @@ class caption_record implements caption_interface, cache_cacheableInterface return $this->fields; } - $fields = array(); + $fields = []; try { $fields = $this->get_data_from_cache(); } catch (Exception $e) { @@ -202,13 +202,13 @@ class caption_record implements caption_interface, cache_cacheableInterface WHERE m.record_id = :record_id AND s.id = m.meta_struct_id ORDER BY s.sorter ASC"; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':record_id' => $this->record->get_record_id())); + $stmt->execute([':record_id' => $this->record->get_record_id()]); $fields = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->set_data_to_cache($fields); } - $rec_fields = array(); + $rec_fields = []; foreach ($fields as $row) { $databox_meta_struct = databox_field::get_instance($this->app, $this->databox, $row['structure_id']); $metadata = new caption_field($this->app, $databox_meta_struct, $this->record); @@ -229,7 +229,7 @@ class caption_record implements caption_interface, cache_cacheableInterface */ public function get_fields(Array $grep_fields = null, $IncludeBusiness = false) { - $fields = array(); + $fields = []; foreach ($this->retrieve_fields() as $meta_struct_id => $field) { if ($grep_fields && ! in_array($field->get_name(), $grep_fields)) { @@ -304,7 +304,7 @@ class caption_record implements caption_interface, cache_cacheableInterface */ protected function highlight_fields($highlight, Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false) { - $fields = array(); + $fields = []; foreach ($this->get_fields($grep_fields, $includeBusiness) as $meta_struct_id => $field) { @@ -314,11 +314,11 @@ class caption_record implements caption_interface, cache_cacheableInterface , $highlight ? $field->highlight_thesaurus() : $field->get_serialized_values(false, false) ); - $fields[$field->get_name()] = array( + $fields[$field->get_name()] = [ 'value' => $value, 'label' => $field->get_databox_field()->get_label($this->app['locale.I18n']), 'separator' => $field->get_databox_field()->get_separator(), - ); + ]; } if ($searchEngine instanceof SearchEngineInterface) { diff --git a/lib/classes/collection.php b/lib/classes/collection.php index 7818a6a854..4044effa98 100644 --- a/lib/classes/collection.php +++ b/lib/classes/collection.php @@ -27,12 +27,12 @@ class collection implements cache_cacheableInterface protected $name; protected $prefs; protected $pub_wm; - protected $labels = array(); - private static $_logos = array(); - private static $_stamps = array(); - private static $_watermarks = array(); - private static $_presentations = array(); - private static $_collections = array(); + protected $labels = []; + private static $_logos = []; + private static $_stamps = []; + private static $_watermarks = []; + private static $_presentations = []; + private static $_collections = []; protected $databox; protected $is_active; protected $binary_logo; @@ -79,7 +79,7 @@ class collection implements cache_cacheableInterface label_en, label_fr, label_de, label_nl FROM coll WHERE coll_id = :coll_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':coll_id' => $this->coll_id)); + $stmt->execute([':coll_id' => $this->coll_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ( ! $row) @@ -89,12 +89,12 @@ class collection implements cache_cacheableInterface $this->pub_wm = $row['pub_wm']; $this->name = $row['asciiname']; $this->prefs = $row['prefs']; - $this->labels = array( + $this->labels = [ 'fr' => $row['label_fr'], 'en' => $row['label_en'], 'de' => $row['label_de'], 'nl' => $row['label_nl'], - ); + ]; $conn = connection::getPDOConnection($this->app); @@ -102,7 +102,7 @@ class collection implements cache_cacheableInterface WHERE server_coll_id = :coll_id AND sbas_id = :sbas_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':coll_id' => $this->coll_id, ':sbas_id' => $this->databox->get_sbas_id())); + $stmt->execute([':coll_id' => $this->coll_id, ':sbas_id' => $this->databox->get_sbas_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -116,7 +116,7 @@ class collection implements cache_cacheableInterface $stmt->closeCursor(); - $datas = array( + $datas = [ 'is_active' => $this->is_active , 'base_id' => $this->base_id , 'available' => $this->available @@ -125,7 +125,7 @@ class collection implements cache_cacheableInterface , 'ord' => $this->ord , 'prefs' => $this->prefs , 'labels' => $this->labels - ); + ]; $this->set_data_to_cache($datas); @@ -136,7 +136,7 @@ class collection implements cache_cacheableInterface { $sql = 'UPDATE bas SET active = "1" WHERE base_id = :base_id'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $this->is_active = true; @@ -166,7 +166,7 @@ class collection implements cache_cacheableInterface { $sql = 'UPDATE bas SET active=0 WHERE base_id = :base_id'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $this->is_active = false; $this->delete_data_from_cache(); @@ -186,7 +186,7 @@ class collection implements cache_cacheableInterface ORDER BY record_id DESC LIMIT 0, " . $pass_quantity; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -220,10 +220,10 @@ class collection implements cache_cacheableInterface public function set_public_presentation($publi) { - if (in_array($publi, array('none', 'wm', 'stamp'))) { + if (in_array($publi, ['none', 'wm', 'stamp'])) { $sql = 'UPDATE coll SET pub_wm = :pub_wm WHERE coll_id = :coll_id'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':pub_wm' => $publi, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->pub_wm = $publi; @@ -244,7 +244,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET asciiname = :asciiname WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':asciiname' => $name, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':asciiname' => $name, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->name = $name; @@ -265,7 +265,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET label_$code = :label WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':label' => $label, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':label' => $label, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->labels[$code] = $label; @@ -294,7 +294,7 @@ class collection implements cache_cacheableInterface { $sql = "SELECT COUNT(record_id) AS n FROM record WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $rowbas = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -313,17 +313,17 @@ class collection implements cache_cacheableInterface GROUP BY record.coll_id, subdef.name"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { - $ret[] = array( + $ret[] = [ "coll_id" => (int) $row["coll_id"], "name" => $row["name"], "amount" => (int) $row["n"], - "size" => (int) $row["size"]); + "size" => (int) $row["size"]]; } return $ret; @@ -339,7 +339,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET logo = :logo, majLogo=NOW() WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':logo' => $this->binary_logo, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':logo' => $this->binary_logo, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); return $this; @@ -352,7 +352,7 @@ class collection implements cache_cacheableInterface WHERE r.coll_id = :coll_id AND r.type="image" AND s.name="preview"'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); while ($row2 = $stmt->fetch(PDO::FETCH_ASSOC)) { @unlink(p4string::addEndSlash($row2['path']) . 'watermark_' . $row2['file']); @@ -369,7 +369,7 @@ class collection implements cache_cacheableInterface WHERE r.coll_id = :coll_id AND r.type="image" AND s.name IN ("preview", "document")'; - $params = array(':coll_id' => $this->get_coll_id()); + $params = [':coll_id' => $this->get_coll_id()]; if ($record_id) { $sql .= ' AND record_id = :record_id'; @@ -395,24 +395,24 @@ class collection implements cache_cacheableInterface $sql = "DELETE FROM coll WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $appbox = $this->databox->get_appbox(); $sql = "DELETE FROM bas WHERE base_id = :base_id"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $sql = "DELETE FROM basusr WHERE base_id = :base_id"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $sql = "DELETE FROM demand WHERE base_id = :base_id"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $this->get_databox()->delete_data_from_cache(databox::CACHE_COLLECTIONS); @@ -488,7 +488,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET prefs = :prefs WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -513,10 +513,10 @@ class collection implements cache_cacheableInterface public function unmount_collection(Application $app) { - $params = array(':base_id' => $this->get_base_id()); + $params = [':base_id' => $this->get_base_id()]; $query = new User_Query($app); - $total = $query->on_base_ids(array($this->get_base_id())) + $total = $query->on_base_ids([$this->get_base_id()]) ->include_phantoms(false) ->include_special_users(true) ->include_invite(true) @@ -568,10 +568,10 @@ class collection implements cache_cacheableInterface $sql = "INSERT INTO coll (coll_id, asciiname, prefs, logo) VALUES (null, :name, :prefs, '')"; - $params = array( + $params = [ ':name' => $name, 'prefs' => $prefs, - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -583,7 +583,7 @@ class collection implements cache_cacheableInterface VALUES (null, 1, :server_coll_id, :sbas_id, '')"; $stmt = $conn->prepare($sql); - $stmt->execute(array(':server_coll_id' => $new_id, ':sbas_id' => $sbas_id)); + $stmt->execute([':server_coll_id' => $new_id, ':sbas_id' => $sbas_id]); $stmt->closeCursor(); $new_bas = $conn->lastInsertId(); @@ -606,7 +606,7 @@ class collection implements cache_cacheableInterface public function set_admin($base_id, user_adapter $user) { - $rights = array( + $rights = [ "canputinalbum" => "1", "candwnldhd" => "1", "nowatermark" => "1", @@ -624,7 +624,7 @@ class collection implements cache_cacheableInterface "imgtools" => "1", "manage" => "1", "modify_struct" => "1" - ); + ]; $this->app['acl']->get($user)->update_rights_to_base($base_id, $rights); @@ -638,7 +638,7 @@ class collection implements cache_cacheableInterface VALUES (null, 1, :server_coll_id, :sbas_id, '')"; $stmt = $databox->get_appbox()->get_connection()->prepare($sql); - $stmt->execute(array(':server_coll_id' => $coll_id, ':sbas_id' => $sbas_id)); + $stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $sbas_id]); $stmt->closeCursor(); $new_bas = $databox->get_appbox()->get_connection()->lastInsertId(); diff --git a/lib/classes/connection.php b/lib/classes/connection.php index 28427d8a9d..26c36a7133 100644 --- a/lib/classes/connection.php +++ b/lib/classes/connection.php @@ -22,7 +22,7 @@ class connection * * @var Array */ - private static $_PDO_instance = array(); + private static $_PDO_instance = []; /** * @@ -34,7 +34,7 @@ class connection * * @var Array */ - public static $log = array(); + public static $log = []; protected $app; public function __construct(Application $app) @@ -67,8 +67,8 @@ class connection foreach (self::$log as $entry) { $query = $entry['query']; do { - $query = str_replace(array("\n", " "), " ", $query); - } while ($query != str_replace(array("\n", " "), " ", $query)); + $query = str_replace(["\n", " "], " ", $query); + } while ($query != str_replace(["\n", " "], " ", $query)); $totalTime += $entry['time']; $string = $entry['time'] . "\t" . ' - ' . $query . ' - ' . "\n"; @@ -124,7 +124,7 @@ class connection if (!isset(self::$_PDO_instance[$name])) { $hostname = $port = $user = $password = $dbname = false; - $connection_params = array(); + $connection_params = []; if (trim($name) !== 'appbox') { $connection_params = phrasea::sbas_params($app); @@ -147,7 +147,7 @@ class connection } try { - self::$_PDO_instance[$name] = new connection_pdo($name, $hostname, $port, $user, $password, $dbname, array(), $app['debug']); + self::$_PDO_instance[$name] = new connection_pdo($name, $hostname, $port, $user, $password, $dbname, [], $app['debug']); } catch (Exception $e) { throw new Exception('Connection not available'); } diff --git a/lib/classes/connection/abstract.php b/lib/classes/connection/abstract.php index c125577ef4..183a00776c 100644 --- a/lib/classes/connection/abstract.php +++ b/lib/classes/connection/abstract.php @@ -18,7 +18,7 @@ abstract class connection_abstract extends PDO { protected $name; - protected $credentials = array(); + protected $credentials = []; protected $multi_db = true; public function get_credentials() @@ -57,7 +57,7 @@ abstract class connection_abstract extends PDO * @param array $driver_options * @return PDOStatement */ - public function prepare($statement, $driver_options = array()) + public function prepare($statement, $driver_options = []) { return parent::prepare($statement, $driver_options); } diff --git a/lib/classes/connection/interface.php b/lib/classes/connection/interface.php index 18dff96b86..a7474118b2 100644 --- a/lib/classes/connection/interface.php +++ b/lib/classes/connection/interface.php @@ -28,7 +28,7 @@ interface connection_interface public function close(); - public function prepare($statement, $driver_options = array()); + public function prepare($statement, $driver_options = []); public function beginTransaction(); diff --git a/lib/classes/connection/pdo.php b/lib/classes/connection/pdo.php index 603e1ab2b5..423f4ed2c2 100644 --- a/lib/classes/connection/pdo.php +++ b/lib/classes/connection/pdo.php @@ -32,7 +32,7 @@ class connection_pdo extends connection_abstract implements connection_interface * * @return connection_pdo */ - public function __construct($name, $hostname, $port, $user, $passwd, $dbname = false, $options = array(), $debug = false) + public function __construct($name, $hostname, $port, $user, $passwd, $dbname = false, $options = [], $debug = false) { $this->debug = $debug; $this->name = $name; @@ -65,7 +65,7 @@ class connection_pdo extends connection_abstract implements connection_interface * @param type $driver_options * @return PDOStatement */ - public function prepare($statement, $driver_options = array()) + public function prepare($statement, $driver_options = []) { if ($this->debug) { return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options)); diff --git a/lib/classes/connection/pdoStatementDebugger.php b/lib/classes/connection/pdoStatementDebugger.php index 75aefc94a1..18e75ec4dd 100644 --- a/lib/classes/connection/pdoStatementDebugger.php +++ b/lib/classes/connection/pdoStatementDebugger.php @@ -29,7 +29,7 @@ class connection_pdoStatementDebugger return $this; } - public function execute($params = array()) + public function execute($params = []) { $start = microtime(true); $exception = null; @@ -39,10 +39,10 @@ class connection_pdoStatementDebugger $exception = $e; } $time = microtime(true) - $start; - connection::$log[] = array( + connection::$log[] = [ 'query' => '' . str_replace(array_keys($params), array_values($params), $this->statement->queryString), 'time' => $time - ); + ]; if ($exception instanceof Exception) throw $exception; @@ -51,6 +51,6 @@ class connection_pdoStatementDebugger public function __call($function_name, $parameters) { - return call_user_func_array(array($this->statement, $function_name), $parameters); + return call_user_func_array([$this->statement, $function_name], $parameters); } } diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 2aa5790294..9622b5e6cc 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -32,19 +32,19 @@ class databox extends base * * @var Array */ - protected static $_xpath_thesaurus = array(); + protected static $_xpath_thesaurus = []; /** * * @var Array */ - protected static $_dom_thesaurus = array(); + protected static $_dom_thesaurus = []; /** * * @var Array */ - protected static $_thesaurus = array(); + protected static $_thesaurus = []; /** * @@ -86,7 +86,7 @@ class databox extends base * * @var SimpleXMLElement */ - protected static $_sxml_thesaurus = array(); + protected static $_sxml_thesaurus = []; const BASE_TYPE = self::DATA_BOX; const CACHE_BASE_DATABOX = 'base_infos'; @@ -99,7 +99,7 @@ class databox extends base protected $cache; protected $connection; protected $app; - private $labels = array(); + private $labels = []; private $ord; private $viewname; private $loaded = false; @@ -140,7 +140,7 @@ class databox extends base $sql = 'SELECT ord, viewname, label_en, label_fr, label_de, label_nl FROM sbas WHERE sbas_id = :sbas_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array('sbas_id' => $this->id)); + $stmt->execute(['sbas_id' => $this->id]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -175,7 +175,7 @@ class databox extends base $sql = 'UPDATE sbas SET viewname = :viewname WHERE sbas_id = :sbas_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':viewname' => $viewname, ':sbas_id' => $this->id)); + $stmt->execute([':viewname' => $viewname, ':sbas_id' => $this->id]); $stmt->closeCursor(); $this->delete_data_from_cache(static::CACHE_BASE_DATABOX); @@ -201,7 +201,7 @@ class databox extends base public function get_collections() { - $ret = array(); + $ret = []; foreach ($this->get_available_collections() as $coll_id) { try { @@ -229,11 +229,11 @@ class databox extends base AND b.active = '1' ORDER BY s.ord ASC, b.ord,b.base_id ASC"; $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $ret[] = (int) $row['server_coll_id']; @@ -280,7 +280,7 @@ class databox extends base $sql = "UPDATE sbas SET label_$code = :label WHERE sbas_id = :sbas_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':label' => $label, ':sbas_id' => $this->id)); + $stmt->execute([':label' => $label, ':sbas_id' => $this->id]); $stmt->closeCursor(); $this->labels[$code] = $label; @@ -376,15 +376,15 @@ class databox extends base foreach ($rs as $rowbas) { if ( ! isset($trows[$rowbas[$sortk1]])) - $trows[$rowbas[$sortk1]] = array(); - $trows[$rowbas[$sortk1]][$rowbas[$sortk2]] = array( + $trows[$rowbas[$sortk1]] = []; + $trows[$rowbas[$sortk1]][$rowbas[$sortk2]] = [ "coll_id" => $rowbas["coll_id"], "asciiname" => $rowbas["asciiname"], "lostcoll" => $rowbas["lostcoll"], "name" => $rowbas["name"], "n" => $rowbas["n"], "siz" => $rowbas["siz"] - ); + ]; } ksort($trows); @@ -416,7 +416,7 @@ class databox extends base $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array('xml_indexed' => 0, 'thesaurus_indexed' => 0); + $ret = ['xml_indexed' => 0, 'thesaurus_indexed' => 0]; foreach ($rs as $row) { $status = $row['status']; if ($status & 1) @@ -435,7 +435,7 @@ class databox extends base } $query = new User_Query($this->app); - $total = $query->on_sbas_ids(array($this->id)) + $total = $query->on_sbas_ids([$this->id]) ->include_phantoms(false) ->include_special_users(true) ->include_invite(true) @@ -462,7 +462,7 @@ class databox extends base $this->app['EM']->flush(); - $params = array(':site_id' => $this->app['configuration']['main']['key']); + $params = [':site_id' => $this->app['configuration']['main']['key']]; $sql = 'DELETE FROM clients WHERE site_id = :site_id'; $stmt = $this->get_connection()->prepare($sql); @@ -476,12 +476,12 @@ class databox extends base $sql = "DELETE FROM sbas WHERE sbas_id = :sbas_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $stmt->closeCursor(); $sql = "DELETE FROM sbasusr WHERE sbas_id = :sbas_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $stmt->closeCursor(); $this->app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_LIST_BASES); @@ -508,13 +508,13 @@ class databox extends base $user = $credentials['user']; $password = $credentials['password']; - $params = array( + $params = [ ':host' => $host , ':port' => $port , ':dbname' => $dbname , ':user' => $user , ':password' => $password - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -551,14 +551,14 @@ class databox extends base $sql = 'INSERT INTO sbas (sbas_id, ord, host, port, dbname, sqlengine, user, pwd) VALUES (null, :ord, :host, :port, :dbname, "MYSQL", :user, :password)'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':ord' => $ord , ':host' => $host , ':port' => $port , ':dbname' => $dbname , ':user' => $user , ':password' => $password - )); + ]); $stmt->closeCursor(); $sbas_id = (int) $app['phraseanet.appbox']->get_connection()->lastInsertId(); @@ -586,7 +586,7 @@ class databox extends base */ public static function mount(Application $app, $host, $port, $user, $password, $dbname, registry $registry) { - new connection_pdo('test', $host, $port, $user, $password, $dbname, array(), $app['debug']); + new connection_pdo('test', $host, $port, $user, $password, $dbname, [], $app['debug']); $conn = $app['phraseanet.appbox']->get_connection(); $sql = 'SELECT MAX(ord) as ord FROM sbas'; @@ -600,14 +600,14 @@ class databox extends base $sql = 'INSERT INTO sbas (sbas_id, ord, host, port, dbname, sqlengine, user, pwd) VALUES (null, :ord, :host, :port, :dbname, "MYSQL", :user, :password)'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':ord' => $ord , ':host' => $host , ':port' => $port , ':dbname' => $dbname , ':user' => $user , ':password' => $password - )); + ]); $stmt->closeCursor(); $sbas_id = (int) $conn->lastInsertId(); @@ -735,7 +735,7 @@ class databox extends base public static function get_available_dcfields() { - return array( + return [ databox_Field_DCESAbstract::Contributor => new databox_Field_DCES_Contributor() , databox_Field_DCESAbstract::Coverage => new databox_Field_DCES_Coverage() , databox_Field_DCESAbstract::Creator => new databox_Field_DCES_Creator() @@ -751,7 +751,7 @@ class databox extends base , databox_Field_DCESAbstract::Subject => new databox_Field_DCES_Subject() , databox_Field_DCESAbstract::Title => new databox_Field_DCES_Title() , databox_Field_DCESAbstract::Type => new databox_Field_DCES_Type() - ); + ]; } /** @@ -761,11 +761,11 @@ class databox extends base public function get_mountable_colls() { $conn = connection::getPDOConnection($this->app); - $colls = array(); + $colls = []; $sql = 'SELECT server_coll_id FROM bas WHERE sbas_id = :sbas_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -773,7 +773,7 @@ class databox extends base $colls[] = (int) $row['server_coll_id']; } - $mountable_colls = array(); + $mountable_colls = []; $sql = 'SELECT coll_id, asciiname FROM coll'; @@ -796,11 +796,11 @@ class databox extends base public function get_activable_colls() { $conn = connection::getPDOConnection($this->app); - $base_ids = array(); + $base_ids = []; $sql = 'SELECT base_id FROM bas WHERE sbas_id = :sbas_id AND active = "0"'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -829,10 +829,10 @@ class databox extends base $stmt = $this->get_connection()->prepare($sql); $stmt->execute( - array( + [ ':structure' => $this->structure, ':now' => $now - ) + ] ); $stmt->closeCursor(); @@ -858,10 +858,10 @@ class databox extends base WHERE prop='cterms'"; $this->cterms = $dom_cterms->saveXML(); - $params = array( + $params = [ ':xml' => $this->cterms , ':date' => $now - ); + ]; $stmt = $this->get_connection()->prepare($sql); $stmt->execute($params); @@ -879,7 +879,7 @@ class databox extends base $sql = "UPDATE pref SET value = :xml, updated_on = :date WHERE prop='thesaurus'"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':xml' => $this->thesaurus, ':date' => $now)); + $stmt->execute([':xml' => $this->thesaurus, ':date' => $now]); $stmt->closeCursor(); $this->delete_data_from_cache(databox::CACHE_THESAURUS); @@ -895,8 +895,8 @@ class databox extends base $contents = file_get_contents($data_template->getPathname()); $contents = str_replace( - array("{{basename}}", "{{datapathnoweb}}") - , array($this->dbname, $path_doc) + ["{{basename}}", "{{datapathnoweb}}"] + , [$this->dbname, $path_doc] , $contents ); @@ -931,12 +931,12 @@ class databox extends base $type = isset($field['type']) ? $field['type'] : 'string'; $type = in_array($type - , array( + , [ databox_field::TYPE_DATE , databox_field::TYPE_NUMBER , databox_field::TYPE_STRING , databox_field::TYPE_TEXT - ) + ] ) ? $type : databox_field::TYPE_STRING; $multi = isset($field['multi']) ? (Boolean) (string) $field['multi'] : false; @@ -973,12 +973,12 @@ class databox extends base $conn = connection::getPDOConnection($this->app); $this->app['acl']->get($user) - ->give_access_to_sbas(array($this->id)) + ->give_access_to_sbas([$this->id]) ->update_rights_to_sbas( - $this->id, array( + $this->id, [ 'bas_manage' => 1, 'bas_modify_struct' => 1, 'bas_modif_th' => 1, 'bas_chupub' => 1 - ) + ] ); $sql = "SELECT * FROM coll"; @@ -992,10 +992,10 @@ class databox extends base (null,'1', :coll_id, :sbas_id)"; $stmt = $conn->prepare($sql); - $base_ids = array(); + $base_ids = []; foreach ($rs as $row) { try { - $stmt->execute(array(':coll_id' => $row['coll_id'], ':sbas_id' => $this->id)); + $stmt->execute([':coll_id' => $row['coll_id'], ':sbas_id' => $this->id]); $base_ids[] = $base_id = $conn->lastInsertId(); if ( ! empty($row['logo'])) { @@ -1008,13 +1008,13 @@ class databox extends base $this->app['acl']->get($user)->give_access_to_base($base_ids); foreach ($base_ids as $base_id) { - $this->app['acl']->get($user)->update_rights_to_base($base_id, array( + $this->app['acl']->get($user)->update_rights_to_base($base_id, [ 'canpush' => 1, 'cancmd' => 1 , 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1 , 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1 , 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1 , 'modify_struct' => 1, 'nowatermark' => 1 - ) + ] ); } @@ -1039,7 +1039,7 @@ class databox extends base public function clear_logs() { - foreach (array('log', 'log_colls', 'log_docs', 'log_search', 'log_view', 'log_thumb') as $table) { + foreach (['log', 'log_colls', 'log_docs', 'log_search', 'log_view', 'log_thumb'] as $table) { $sql = 'TRUNCATE ' . $table; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); @@ -1309,9 +1309,9 @@ class databox extends base $sx_structure = simplexml_load_string($structure); $subdefgroup = $sx_structure->subdefs[0]; - $AvSubdefs = array(); + $AvSubdefs = []; - $errors = array(); + $errors = []; foreach ($subdefgroup as $k => $subdefs) { $subdefgroup_name = trim((string) $subdefs->attributes()->name); @@ -1322,7 +1322,7 @@ class databox extends base } if ( ! isset($AvSubdefs[$subdefgroup_name])) - $AvSubdefs[$subdefgroup_name] = array(); + $AvSubdefs[$subdefgroup_name] = []; foreach ($subdefs as $sd) { $sd_name = trim(mb_strtolower((string) $sd->attributes()->name)); @@ -1331,7 +1331,7 @@ class databox extends base $errors[] = _('ERREUR : Les name de subdef sont uniques par groupe de subdefs et necessaire'); continue; } - if ( ! in_array($sd_class, array('thumbnail', 'preview', 'document'))) { + if ( ! in_array($sd_class, ['thumbnail', 'preview', 'document'])) { $errors[] = _('ERREUR : La classe de subdef est necessaire et egal a "thumbnail","preview" ou "document"'); continue; } @@ -1371,10 +1371,10 @@ class databox extends base $stmt->closeCursor(); foreach ($rs as $row) { - $TOU[$row['locale']] = array('updated_on' => $row['updated_on'], 'value' => $row['value']); + $TOU[$row['locale']] = ['updated_on' => $row['updated_on'], 'value' => $row['value']]; } - $missing_locale = array(); + $missing_locale = []; $avLanguages = $this->app['locales.available']; foreach ($avLanguages as $code => $language) { @@ -1389,8 +1389,8 @@ class databox extends base VALUES (null, 'ToU', '', :locale, :date, NOW())"; $stmt = $this->get_connection()->prepare($sql); foreach ($missing_locale as $v) { - $stmt->execute(array(':locale' => $v, ':date' => $date)); - $TOU[$v] = array('updated_on' => $date, 'value' => ''); + $stmt->execute([':locale' => $v, ':date' => $date]); + $TOU[$v] = ['updated_on' => $date, 'value' => '']; } $stmt->closeCursor(); $this->cgus = $TOU; @@ -1403,7 +1403,7 @@ class databox extends base public function update_cgus($locale, $terms, $reset_date) { - $terms = str_replace(array("\r\n", "\n", "\r"), array('', '', ''), strip_tags($terms, '

    1. ')); + $terms = str_replace(["\r\n", "\n", "\r"], ['', '', ''], strip_tags($terms, '

        1. ')); $sql = 'UPDATE pref SET value = :terms '; if ($reset_date) @@ -1412,7 +1412,7 @@ class databox extends base $sql .= ' WHERE prop="ToU" AND locale = :locale'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':terms' => $terms, ':locale' => $locale)); + $stmt->execute([':terms' => $terms, ':locale' => $locale]); $stmt->closeCursor(); $this->cgus = null; $this->delete_data_from_cache(self::CACHE_CGUS); @@ -1424,10 +1424,10 @@ class databox extends base { $this->_sxml_structure = $this->_dom_structure = $this->_xpath_structure = null; - $vars = array(); + $vars = []; foreach ($this as $key => $value) { - if (in_array($key, array('app', 'meta_struct'))) { + if (in_array($key, ['app', 'meta_struct'])) { continue; } diff --git a/lib/classes/databox/cgu.php b/lib/classes/databox/cgu.php index d0fb21176e..da271f76f9 100644 --- a/lib/classes/databox/cgu.php +++ b/lib/classes/databox/cgu.php @@ -49,7 +49,7 @@ class databox_cgu private static function getUnvalidated(Application $app, $home = false) { - $terms = array(); + $terms = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { @@ -71,7 +71,7 @@ class databox_cgu } if ($userValidation) - $terms[$name] = array('sbas_id' => $databox->get_sbas_id(), 'terms' => $value, 'date' => $update); + $terms[$name] = ['sbas_id' => $databox->get_sbas_id(), 'terms' => $value, 'date' => $update]; } catch (Exception $e) { } diff --git a/lib/classes/databox/descriptionStructure.php b/lib/classes/databox/descriptionStructure.php index 2b7e4f41b6..e28f60ece3 100644 --- a/lib/classes/databox/descriptionStructure.php +++ b/lib/classes/databox/descriptionStructure.php @@ -20,14 +20,14 @@ class databox_descriptionStructure implements IteratorAggregate, Countable * * @var Array */ - protected $elements = array(); + protected $elements = []; /** * Cache array for the get element by name function * * @var Array */ - protected $cache_name_id = array(); + protected $cache_name_id = []; /** * diff --git a/lib/classes/databox/field.php b/lib/classes/databox/field.php index 6fe166d92b..55fd60fd26 100644 --- a/lib/classes/databox/field.php +++ b/lib/classes/databox/field.php @@ -116,7 +116,7 @@ class databox_field implements cache_cacheableInterface * * @var array */ - protected $labels = array(); + protected $labels = []; /** * @@ -138,7 +138,7 @@ class databox_field implements cache_cacheableInterface * @var int */ protected $sbas_id; - protected static $_instance = array(); + protected static $_instance = []; protected $dces_element; protected $Vocabulary; protected $VocabularyType; @@ -192,7 +192,7 @@ class databox_field implements cache_cacheableInterface FROM metadatas_structure WHERE id=:id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $id)); + $stmt->execute([':id' => $id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -209,7 +209,7 @@ class databox_field implements cache_cacheableInterface $this->on_error = true; } - foreach (array('en', 'fr', 'de', 'nl') as $code) { + foreach (['en', 'fr', 'de', 'nl'] as $code) { $this->labels[$code] = $row['label_' . $code]; } @@ -338,7 +338,7 @@ class databox_field implements cache_cacheableInterface $connbas = $this->get_connection(); $sql = 'DELETE FROM metadatas_structure WHERE id = :id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $this->get_id())); + $stmt->execute([':id' => $this->get_id()]); $stmt->closeCursor(); $dom_struct = $this->databox->get_dom_structure(); @@ -389,7 +389,7 @@ class databox_field implements cache_cacheableInterface `label_nl` = :label_nl WHERE id = :id'; - $params = array( + $params = [ ':name' => $this->name, ':source' => $this->tag->getTagname(), ':indexable' => $this->indexable ? '1' : '0', @@ -410,7 +410,7 @@ class databox_field implements cache_cacheableInterface ':label_fr' => isset($this->labels['fr']) ? $this->labels['fr'] : null, ':label_de' => isset($this->labels['de']) ? $this->labels['de'] : null, ':label_nl' => isset($this->labels['nl']) ? $this->labels['nl'] : null - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -611,9 +611,9 @@ class databox_field implements cache_cacheableInterface SET dces_element = null WHERE dces_element = :dces_element'; $stmt = $connbas->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':dces_element' => $DCES_element->get_label() - )); + ]); $stmt->closeCursor(); } @@ -621,10 +621,10 @@ class databox_field implements cache_cacheableInterface SET dces_element = :dces_element WHERE id = :id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':dces_element' => $DCES_element ? $DCES_element->get_label() : null , ':id' => $this->id - )); + ]); $stmt->closeCursor(); $this->dces_element = $DCES_element; @@ -925,7 +925,7 @@ class databox_field implements cache_cacheableInterface public function toArray() { - return array( + return [ 'id' => $this->id, 'sbas-id' => $this->sbas_id, 'labels' => $this->labels, @@ -945,7 +945,7 @@ class databox_field implements cache_cacheableInterface 'dces-element' => $this->dces_element ? $this->dces_element->get_label() : null, 'vocabulary-type' => $this->Vocabulary ? $this->Vocabulary->getType() : null, 'vocabulary-restricted' => $this->VocabularyRestriction, - ); + ]; } /** @@ -990,7 +990,7 @@ class databox_field implements cache_cacheableInterface $multi = $multi ? 1 : 0; $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array(':name' => $name, ':sorter' => $sorter, ':multi' => $multi)); + $stmt->execute([':name' => $name, ':sorter' => $sorter, ':multi' => $multi]); $id = $databox->get_connection()->lastInsertId(); $stmt->closeCursor(); @@ -1014,9 +1014,9 @@ class databox_field implements cache_cacheableInterface */ public function __sleep() { - $vars = array(); + $vars = []; foreach ($this as $key => $value) { - if (in_array($key, array('databox', 'app', 'Vocabulary'))) + if (in_array($key, ['databox', 'app', 'Vocabulary'])) continue; $vars[] = $key; } diff --git a/lib/classes/databox/status.php b/lib/classes/databox/status.php index 06656df722..eb037a7c2d 100644 --- a/lib/classes/databox/status.php +++ b/lib/classes/databox/status.php @@ -26,7 +26,7 @@ class databox_status * * @var Array */ - private static $_status = array(); + private static $_status = []; /** * @@ -38,7 +38,7 @@ class databox_status * * @var Array */ - private $status = array(); + private $status = []; /** * @@ -59,7 +59,7 @@ class databox_status */ private function __construct(Application $app, $sbas_id) { - $this->status = array(); + $this->status = []; $path = $url = false; @@ -138,7 +138,7 @@ class databox_status $sbas_ids = $app['acl']->get($app['authentication']->getUser())->get_granted_sbas(); - $statuses = array(); + $statuses = []; foreach ($sbas_ids as $databox) { try { @@ -155,11 +155,11 @@ class databox_status public static function getSearchStatus(Application $app) { - $statuses = array(); + $statuses = []; $sbas_ids = $app['acl']->get($app['authentication']->getUser())->get_granted_sbas(); - $see_all = array(); + $see_all = []; foreach ($sbas_ids as $databox) { $see_all[$databox->get_sbas_id()] = false; @@ -177,7 +177,7 @@ class databox_status } } - $stats = array(); + $stats = []; foreach ($statuses as $sbas_id => $status) { @@ -202,31 +202,31 @@ class databox_status } } if (! $set) { - $stats[$bit][] = array( - 'sbas' => array($sbas_id), + $stats[$bit][] = [ + 'sbas' => [$sbas_id], 'labeloff' => $props['labeloff'], 'labelon' => $props['labelon'], 'labels_on_i18n' => $props['labels_on_i18n'], 'labels_off_i18n' => $props['labels_off_i18n'], 'imgoff' => $props['img_off'], 'imgon' => $props['img_on'] - ); + ]; $set = true; } } if (! $set) { - $stats[$bit] = array( - array( - 'sbas' => array($sbas_id), + $stats[$bit] = [ + [ + 'sbas' => [$sbas_id], 'labeloff' => $props['labeloff'], 'labelon' => $props['labelon'], 'labels_on_i18n' => $props['labels_on_i18n'], 'labels_off_i18n' => $props['labels_off_i18n'], 'imgoff' => $props['img_off'], 'imgon' => $props['img_on'] - ) - ); + ] + ]; } } } @@ -387,7 +387,7 @@ class databox_status { $status = self::getStatus($app, $sbas_id); - $switch = in_array($switch, array('on', 'off')) ? $switch : false; + $switch = in_array($switch, ['on', 'off']) ? $switch : false; if (! $switch) { return false; @@ -407,7 +407,7 @@ class databox_status public static function updateIcon(Application $app, $sbas_id, $bit, $switch, UploadedFile $file) { - $switch = in_array($switch, array('on', 'off')) ? $switch : false; + $switch = in_array($switch, ['on', 'off']) ? $switch : false; if (! $switch) { throw new Exception_InvalidArgument(); diff --git a/lib/classes/databox/subdef.php b/lib/classes/databox/subdef.php index 218e104079..652e363f3e 100644 --- a/lib/classes/databox/subdef.php +++ b/lib/classes/databox/subdef.php @@ -31,20 +31,20 @@ class databox_subdef * @var string */ protected $class; - protected $devices = array(); + protected $devices = []; protected $name; protected $path; protected $subdef_group; - protected $labels = array(); + protected $labels = []; protected $write_meta; protected $downloadable; - protected static $mediaTypeToSubdefTypes = array( - SubdefType::TYPE_AUDIO => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO), - SubdefType::TYPE_DOCUMENT => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER), - SubdefType::TYPE_FLASH => array(SubdefSpecs::TYPE_IMAGE), - SubdefType::TYPE_IMAGE => array(SubdefSpecs::TYPE_IMAGE), - SubdefType::TYPE_VIDEO => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION), - ); + protected static $mediaTypeToSubdefTypes = [ + SubdefType::TYPE_AUDIO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO], + SubdefType::TYPE_DOCUMENT => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER], + SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE], + SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE], + SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION], + ]; const CLASS_THUMBNAIL = 'thumbnail'; const CLASS_PREVIEW = 'preview'; @@ -194,16 +194,16 @@ class databox_subdef */ public function getAvailableSubdefTypes() { - $subdefTypes = array(); + $subdefTypes = []; - $availableDevices = array( + $availableDevices = [ self::DEVICE_ALL, self::DEVICE_HANDHELD, self::DEVICE_PRINT, self::DEVICE_PROJECTION, self::DEVICE_SCREEN, self::DEVICE_TV, - ); + ]; if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) { diff --git a/lib/classes/databox/subdefsStructure.php b/lib/classes/databox/subdefsStructure.php index 6d838f8407..2703a3888e 100644 --- a/lib/classes/databox/subdefsStructure.php +++ b/lib/classes/databox/subdefsStructure.php @@ -20,7 +20,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable * * @var Array */ - protected $AvSubdefs = array(); + protected $AvSubdefs = []; /** * @@ -76,13 +76,13 @@ class databox_subdefsStructure implements IteratorAggregate, Countable { $sx_struct = $this->databox->get_sxml_structure(); - $this->AvSubdefs = array( - 'image' => array(), - 'video' => array(), - 'audio' => array(), - 'document' => array(), - 'flash' => array() - ); + $this->AvSubdefs = [ + 'image' => [], + 'video' => [], + 'audio' => [], + 'document' => [], + 'flash' => [] + ]; if (! $sx_struct) { return $this; @@ -94,7 +94,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable $subdefgroup_name = strtolower($subdefs->attributes()->name); if ( ! isset($AvSubdefs[$subdefgroup_name])) { - $AvSubdefs[$subdefgroup_name] = array(); + $AvSubdefs[$subdefgroup_name] = []; } foreach ($subdefs as $sd) { diff --git a/lib/classes/deprecated/countries.php b/lib/classes/deprecated/countries.php index cbe4e5bbb6..6db3d6bcf5 100644 --- a/lib/classes/deprecated/countries.php +++ b/lib/classes/deprecated/countries.php @@ -16,7 +16,7 @@ */ function getCountries($lng = 'fr') { - $countries['en'] = array( + $countries['en'] = [ 'AF' => 'AFGHANISTAN', 'AX' => 'ÅLAND ISLANDS', 'AL' => 'ALBANIA', @@ -263,11 +263,11 @@ function getCountries($lng = 'fr') 'YE' => 'YEMEN', 'ZM' => 'ZAMBIA', 'ZW' => 'ZIMBABWE', - ); + ]; $countries['us'] = $countries['en']; - $countries['fr'] = array( + $countries['fr'] = [ 'AF' => 'AFGHANISTAN', 'ZA' => 'AFRIQUE DU SUD', 'AX' => 'ÅLAND, ÎLES', @@ -514,7 +514,7 @@ function getCountries($lng = 'fr') 'YE' => 'YÉMEN', 'ZM' => 'ZAMBIE', 'ZW' => 'ZIMBABWE' - ); + ]; if ( ! isset($countries[$lng])) $lng = 'us'; foreach ($countries[$lng] as $k => $country) diff --git a/lib/classes/deprecated/inscript.api.php b/lib/classes/deprecated/inscript.api.php index 72906dc234..93a8e0e9af 100644 --- a/lib/classes/deprecated/inscript.api.php +++ b/lib/classes/deprecated/inscript.api.php @@ -40,7 +40,7 @@ function giveMeBases(Application $app, $usr = null) AND usr.usr_id = :usr_id AND model_of = 0'; $stmt = $conn->prepare($sqlU); - $stmt->execute(array(':usr_id' => $usr)); + $stmt->execute([':usr_id' => $usr]); $rsU = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -72,7 +72,7 @@ function giveMeBases(Application $app, $usr = null) foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { $collname = $basname = null; $sbas_id = $databox->get_sbas_id(); - $inscriptions[$sbas_id] = array(); + $inscriptions[$sbas_id] = []; $inscriptions[$sbas_id]['CGU'] = false; $inscriptions[$sbas_id]['CGUrelease'] = false; $inscriptions[$sbas_id]['inscript'] = false; @@ -293,7 +293,7 @@ function giveMeBaseUsr(Application $app, $usr) $out .= ''; - return array('tab' => $out, 'demandes' => $noDemand); + return ['tab' => $out, 'demandes' => $noDemand]; } function giveModInscript($usr, $lng) diff --git a/lib/classes/eventsmanager/broker.php b/lib/classes/eventsmanager/broker.php index 977eaa4db2..50d9ecc9b0 100644 --- a/lib/classes/eventsmanager/broker.php +++ b/lib/classes/eventsmanager/broker.php @@ -4,9 +4,9 @@ use Alchemy\Phrasea\Application; class eventsmanager_broker { - protected $events = array(); - protected $notifications = array(); - protected $pool_classes = array(); + protected $events = []; + protected $notifications = []; + protected $pool_classes = []; /** * @@ -23,11 +23,11 @@ class eventsmanager_broker public function start() { - $iterators_pool = array( - 'event' => array( + $iterators_pool = [ + 'event' => [ 'eventsmanager_event_test' - ), - 'notify' => array( + ], + 'notify' => [ 'eventsmanager_notify_autoregister', 'eventsmanager_notify_bridgeuploadfail', 'eventsmanager_notify_downloadmailfail', @@ -41,8 +41,8 @@ class eventsmanager_broker 'eventsmanager_notify_validate', 'eventsmanager_notify_validationdone', 'eventsmanager_notify_validationreminder', - ) - ); + ] + ]; foreach ($iterators_pool as $type => $iterators) { foreach ($iterators as $fileinfo) { @@ -64,7 +64,7 @@ class eventsmanager_broker return; } - public function trigger($event, $array_params = array(), &$object = false) + public function trigger($event, $array_params = [], &$object = false) { if (array_key_exists($event, $this->events)) { foreach ($this->events[$event] as $classname) { @@ -79,7 +79,7 @@ class eventsmanager_broker { if ( ! array_key_exists($event, $this->events)) - $this->events[$event] = array(); + $this->events[$event] = []; $this->events[$event][] = $object_name; } @@ -93,12 +93,12 @@ class eventsmanager_broker VALUES (null, :usr_id, :event_type, 1, :mailed, :datas, NOW())'; - $params = array( + $params = [ ':usr_id' => $usr_id , ':event_type' => $event_type , ':mailed' => ($mailed ? 1 : 0) , ':datas' => $datas - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -118,7 +118,7 @@ class eventsmanager_broker FROM notifications WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -133,10 +133,10 @@ class eventsmanager_broker ORDER BY created_on DESC LIMIT ' . ((int) $page * $n) . ', ' . $n; - $data = array('notifications' => array(), 'next' => ''); + $data = ['notifications' => [], 'next' => '']; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -147,7 +147,7 @@ class eventsmanager_broker if ( ! isset($this->pool_classes[$type]) || count($content) === 0) { $sql = 'DELETE FROM notifications WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $row['id'])); + $stmt->execute([':id' => $row['id']]); $stmt->closeCursor(); continue; } @@ -156,19 +156,19 @@ class eventsmanager_broker $display_date = $this->app['date-formatter']->getDate(new DateTime($row['created_on'])); if ( ! isset($data['notifications'][$date_key])) { - $data['notifications'][$date_key] = array( + $data['notifications'][$date_key] = [ 'display' => $display_date - , 'notifications' => array() - ); + , 'notifications' => [] + ]; } - $data['notifications'][$date_key]['notifications'][$row['id']] = array( + $data['notifications'][$date_key]['notifications'][$row['id']] = [ 'classname' => $content['class'] , 'time' => $this->app['date-formatter']->getTime(new DateTime($row['created_on'])) , 'icon' => '' , 'id' => $row['id'] , 'text' => $content['text'] - ); + ]; } if (((int) $page + 1) * $n < $total) { @@ -186,7 +186,7 @@ class eventsmanager_broker FROM notifications WHERE usr_id = :usr_id AND unread="1"'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -205,7 +205,7 @@ class eventsmanager_broker FROM notifications WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -221,9 +221,9 @@ class eventsmanager_broker WHERE usr_id = :usr_id AND unread="1" ORDER BY created_on DESC'; } - $ret = array(); + $ret = []; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -237,19 +237,19 @@ class eventsmanager_broker if ( ! isset($this->pool_classes[$type]) || count($datas) === 0) { $sql = 'DELETE FROM notifications WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $row['id'])); + $stmt->execute([':id' => $row['id']]); $stmt->closeCursor(); continue; } $ret[] = array_merge( $datas - , array( + , [ 'created_on' => $this->app['date-formatter']->getPrettyString(new DateTime($row['created_on'])) , 'icon' => $this->pool_classes[$type]->icon_url() , 'id' => $row['id'] , 'unread' => $row['unread'] - ) + ] ); } @@ -267,7 +267,7 @@ class eventsmanager_broker AND (id="' . implode('" OR id="', $notifications) . '")'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr_id)); + $stmt->execute([':usr_id' => $usr_id]); $stmt->closeCursor(); return $this; @@ -275,7 +275,7 @@ class eventsmanager_broker public function list_notifications_available($usr_id) { - $personnal_notifications = array(); + $personnal_notifications = []; foreach ($this->notifications as $notification) { if (!$this->pool_classes[$notification]->is_available($usr_id)) { @@ -284,12 +284,12 @@ class eventsmanager_broker $group = $this->pool_classes[$notification]->get_group(); $group = $group === null ? _('Notifications globales') : $group; - $personnal_notifications[$group][] = array( + $personnal_notifications[$group][] = [ 'name' => $this->pool_classes[$notification]->get_name() , 'id' => $notification , 'description' => $this->pool_classes[$notification]->get_description() , 'subscribe_emails' => true - ); + ]; } return $personnal_notifications; diff --git a/lib/classes/eventsmanager/event/test.php b/lib/classes/eventsmanager/event/test.php index 0c44941856..60d8d94956 100644 --- a/lib/classes/eventsmanager/event/test.php +++ b/lib/classes/eventsmanager/event/test.php @@ -21,7 +21,7 @@ class eventsmanager_event_test extends eventsmanager_eventAbstract * * @var Array */ - protected $events = array('__EVENT__'); + protected $events = ['__EVENT__']; /** * diff --git a/lib/classes/eventsmanager/eventAbstract.php b/lib/classes/eventsmanager/eventAbstract.php index 3967503b5f..88d8582ad1 100644 --- a/lib/classes/eventsmanager/eventAbstract.php +++ b/lib/classes/eventsmanager/eventAbstract.php @@ -4,7 +4,7 @@ use Alchemy\Phrasea\Application; abstract class eventsmanager_eventAbstract { - protected $events = array(); + protected $events = []; protected $group = null; /** diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php index fb20884e54..5bc09600ee 100644 --- a/lib/classes/eventsmanager/notify/autoregister.php +++ b/lib/classes/eventsmanager/notify/autoregister.php @@ -24,7 +24,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__REGISTER_AUTOREGISTER__'); + public $events = ['__REGISTER_AUTOREGISTER__']; /** * @@ -44,10 +44,10 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'usr_id' => '' - , 'autoregister' => array() - ); + , 'autoregister' => [] + ]; $params = array_merge($default, $params); $base_ids = array_keys($params['autoregister']); @@ -56,7 +56,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract return; } - $mailColl = array(); + $mailColl = []; $sql = 'SELECT u.usr_id, b.base_id FROM usr u, basusr b WHERE u.usr_id = b.usr_id @@ -75,7 +75,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract foreach ($rs as $row) { if ( ! isset($mailColl[$row['usr_id']])) - $mailColl[$row['usr_id']] = array(); + $mailColl[$row['usr_id']] = []; $mailColl[$row['usr_id']][] = $row['base_id']; } @@ -149,16 +149,16 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract try { User_Adapter::getInstance($usr_id, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($usr_id, $this->app)->get_display_name(); - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s s\'est enregistre sur une ou plusieurs %2$scollections%3$s'), $sender, '', '') , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/bridgeuploadfail.php b/lib/classes/eventsmanager/notify/bridgeuploadfail.php index 692ab2ad54..be93dbe133 100644 --- a/lib/classes/eventsmanager/notify/bridgeuploadfail.php +++ b/lib/classes/eventsmanager/notify/bridgeuploadfail.php @@ -24,7 +24,7 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__BRIDGE_UPLOAD_FAIL__'); + public $events = ['__BRIDGE_UPLOAD_FAIL__']; /** * @@ -44,13 +44,13 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'usr_id' => null , 'reason' => '' , 'account_id' => null , 'base_id' => null , 'record_id' => null - ); + ]; $params = array_merge($default, $params); @@ -127,14 +127,14 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract $account = Bridge_Account::load_account($this->app, $account_id); $record = new record_adapter($this->app, $sbas_id, $rid); } catch (Exception $e) { - return array(); + return []; } - $ret = array( + $ret = [ 'text' => sprintf("L'upload concernant le record %s sur le comptre %s a echoue pour les raisons suivantes : %s" , $record->get_title(), $account->get_api()->get_connector()->get_name(), $reason) , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/downloadmailfail.php b/lib/classes/eventsmanager/notify/downloadmailfail.php index b73e55b5cd..a94448c3c1 100644 --- a/lib/classes/eventsmanager/notify/downloadmailfail.php +++ b/lib/classes/eventsmanager/notify/downloadmailfail.php @@ -24,7 +24,7 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__EXPORT_MAIL_FAIL__'); + public $events = ['__EXPORT_MAIL_FAIL__']; /** * @@ -44,13 +44,13 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'usr_id' => null , 'lst' => '' , 'ssttid' => '' , 'dest' => '' , 'reason' => '' - ); + ]; $params = array_merge($default, $params); @@ -117,10 +117,10 @@ class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract , $reason ); - $ret = array( + $ret = [ 'text' => $text , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php index f566989653..5a1ace4f22 100644 --- a/lib/classes/eventsmanager/notify/feed.php +++ b/lib/classes/eventsmanager/notify/feed.php @@ -24,7 +24,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__FEED_ENTRY_CREATE__'); + public $events = ['__FEED_ENTRY_CREATE__']; /** * @@ -44,10 +44,10 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$entry) { - $params = array( + $params = [ 'entry_id' => $entry->getId(), 'notify_email' => $params['notify_email'], - ); + ]; $dom_xml = new DOMDocument('1.0', 'UTF-8'); @@ -74,16 +74,16 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract ->email_not_null(true); if ($entry->getFeed()->getCollection($this->app)) { - $Query->on_base_ids(array($entry->getFeed()->getCollection($this->app)->get_base_id())); + $Query->on_base_ids([$entry->getFeed()->getCollection($this->app)->get_base_id()]); } $start = 0; $perLoop = 100; - $from = array( + $from = [ 'email' => $entry->getAuthorEmail(), 'name' => $entry->getAuthorName() - ); + ]; do { $results = $Query->limit($start, $perLoop)->execute()->get_results(); @@ -102,7 +102,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract , $entry->getId() ); - $url = $this->app->url('lightbox', array('LOG' => $token)); + $url = $this->app->url('lightbox', ['LOG' => $token]); $receiver = Receiver::fromUser($user_to_notif); $readyToSend = true; @@ -142,17 +142,17 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract $entry = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedEntry')->find((int) $sx->entry_id); if (null === $entry) { - return array(); + return []; } - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s has published %2$s') , $entry->getAuthorName() , '' . $entry->getTitle() . '' ) , 'class' => ($unread == 1 ? 'reload_baskets' : '') - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php index 1f92e77437..d4f898d8e0 100644 --- a/lib/classes/eventsmanager/notify/order.php +++ b/lib/classes/eventsmanager/notify/order.php @@ -24,7 +24,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__NEW_ORDER__'); + public $events = ['__NEW_ORDER__']; /** * @@ -44,22 +44,22 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'usr_id' => '' - , 'order_id' => array() - ); + , 'order_id' => [] + ]; $params = array_merge($default, $params); $order_id = $params['order_id']; - $users = array(); + $users = []; try { $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\OrderElement'); - $results = $repository->findBy(array('orderId' => $order_id)); + $results = $repository->findBy(['orderId' => $order_id]); - $base_ids = array(); + $base_ids = []; foreach ($results as $result) { $base_ids[] = $result->getBaseId(); } @@ -67,7 +67,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract $query = new User_Query($this->app); $users = $query->on_base_ids($base_ids) - ->who_have_right(array('order_master')) + ->who_have_right(['order_master']) ->execute()->get_results(); } catch (Exception $e) { @@ -147,18 +147,18 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract try { User_Adapter::getInstance($usr_id, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($usr_id, $this->app)->get_display_name(); - $ret = array( + $ret = [ 'text' => sprintf(_('%1$s a passe une %2$scommande%3$s') , $sender , '' , '') , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/orderdeliver.php b/lib/classes/eventsmanager/notify/orderdeliver.php index c95636e67f..4b72f18fcd 100644 --- a/lib/classes/eventsmanager/notify/orderdeliver.php +++ b/lib/classes/eventsmanager/notify/orderdeliver.php @@ -26,7 +26,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__ORDER_DELIVER__'); + public $events = ['__ORDER_DELIVER__']; /** * @@ -58,12 +58,12 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'from' => '' , 'to' => '' , 'ssel_id' => '' , 'n' => '' - ); + ]; $params = array_merge($default, $params); @@ -113,7 +113,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract } if ($readyToSend) { - $url = $this->app->url('lightbox_compare', array( + $url = $this->app->url('lightbox_compare', [ 'basket' => $basket->getId(), 'LOG' => $this->app['tokens']->getUrlToken( \random::TYPE_VIEW, @@ -121,7 +121,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract null, $basket->getId() ) - )); + ]); $mail = MailInfoOrderDelivered::create($this->app, $receiver, $emitter, null); $mail->setButtonUrl($url); @@ -153,7 +153,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract try { User_Adapter::getInstance($from, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($from, $this->app)->get_display_name(); @@ -161,16 +161,16 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract try { $basket = $this->app['converter.basket']->convert($ssel_id); } catch (Exception $e) { - return array(); + return []; } - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s vous a delivre %2$d document(s) pour votre commande %3$s'), $sender, $n, '' . $basket->getName() . '' ) , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.php b/lib/classes/eventsmanager/notify/ordernotdelivered.php index b555eedf07..d046f1afb0 100644 --- a/lib/classes/eventsmanager/notify/ordernotdelivered.php +++ b/lib/classes/eventsmanager/notify/ordernotdelivered.php @@ -25,7 +25,7 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac * * @var string */ - public $events = array('__ORDER_NOT_DELIVERED__'); + public $events = ['__ORDER_NOT_DELIVERED__']; public function __construct(Application $app, eventsmanager_broker $broker) { @@ -42,11 +42,11 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac public function fire($event, $params, &$object) { - $default = array( + $default = [ 'from' => '' , 'to' => '' , 'n' => '' - ); + ]; $params = array_merge($default, $params); @@ -115,17 +115,17 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac try { User_Adapter::getInstance($from, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($from, $this->app)->get_display_name(); - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s a refuse la livraison de %2$d document(s) pour votre commande'), $sender, $n ) , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/push.php b/lib/classes/eventsmanager/notify/push.php index b9a2143ff7..61fb451be2 100644 --- a/lib/classes/eventsmanager/notify/push.php +++ b/lib/classes/eventsmanager/notify/push.php @@ -25,7 +25,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__PUSH_DATAS__'); + public $events = ['__PUSH_DATAS__']; /** * @@ -45,12 +45,12 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'from' => '' , 'to' => '' , 'message' => '' , 'ssel_id' => '' - ); + ]; $params = array_merge($default, $params); @@ -128,17 +128,17 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract try { User_Adapter::getInstance($from, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($from, $this->app)->get_display_name(); - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s vous a envoye un %2$spanier%3$s'), $sender, '', '') , 'class' => ($unread == 1 ? 'reload_baskets' : '') - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/register.php b/lib/classes/eventsmanager/notify/register.php index 0df131a710..b2cebb6bff 100644 --- a/lib/classes/eventsmanager/notify/register.php +++ b/lib/classes/eventsmanager/notify/register.php @@ -24,7 +24,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__REGISTER_APPROVAL__'); + public $events = ['__REGISTER_APPROVAL__']; /** * @@ -44,10 +44,10 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'usr_id' => '' - , 'demand' => array() - ); + , 'demand' => [] + ]; $params = array_merge($default, $params); $base_ids = $params['demand']; @@ -56,7 +56,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract return; } - $mailColl = array(); + $mailColl = []; try { $sql = 'SELECT u.usr_id, b.base_id @@ -76,7 +76,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract foreach ($rs as $row) { if ( ! isset($mailColl[$row['usr_id']])) - $mailColl[$row['usr_id']] = array(); + $mailColl[$row['usr_id']] = []; $mailColl[$row['usr_id']][] = $row['base_id']; } @@ -159,17 +159,17 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract try { User_Adapter::getInstance($usr_id, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($usr_id, $this->app)->get_display_name(); - $ret = array( + $ret = [ 'text' => sprintf( - _('%1$s demande votre approbation sur une ou plusieurs %2$scollections%3$s'), $sender, '', '' + _('%1$s demande votre approbation sur une ou plusieurs %2$scollections%3$s'), $sender, '', '' ) , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php index 0fb8881cab..3d49b996b6 100644 --- a/lib/classes/eventsmanager/notify/uploadquarantine.php +++ b/lib/classes/eventsmanager/notify/uploadquarantine.php @@ -26,7 +26,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__UPLOAD_QUARANTINE__'); + public $events = ['__UPLOAD_QUARANTINE__']; /** * @@ -87,8 +87,8 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract $query = new User_Query($this->app); $users = $query - ->on_base_ids(array($lazaretFile->getBaseId())) - ->who_have_right(array('canaddrecord')) + ->on_base_ids([$lazaretFile->getBaseId()]) + ->who_have_right(['canaddrecord']) ->execute() ->get_results(); @@ -140,7 +140,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract { $sx = simplexml_load_string($datas); - $reasons = array(); + $reasons = []; foreach ($sx->reasons as $reason) { $checkClassName = (string) $reason->checkClassName; @@ -158,7 +158,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract $text .= ' ' . sprintf(_('for the following reasons : %s'), implode(', ', $reasons)); } - $ret = array('text' => $text, 'class' => ''); + $ret = ['text' => $text, 'class' => '']; return $ret; } diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php index 6b499a809f..f89ee3f8a1 100644 --- a/lib/classes/eventsmanager/notify/validate.php +++ b/lib/classes/eventsmanager/notify/validate.php @@ -20,7 +20,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__PUSH_VALIDATION__'); + public $events = ['__PUSH_VALIDATION__']; /** * @@ -52,12 +52,12 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'from' => '' , 'to' => '' , 'message' => '' , 'ssel_id' => '' - ); + ]; $params = array_merge($default, $params); @@ -140,7 +140,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract try { User_Adapter::getInstance($from, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($from, $this->app)->get_display_name(); @@ -153,17 +153,17 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract } $bask_link = '' . $basket_name . ''; - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s vous demande de valider %2$s') , $sender, $bask_link ) , 'class' => ($unread == 1 ? 'reload_baskets' : '') - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/validationdone.php b/lib/classes/eventsmanager/notify/validationdone.php index f3cf41b933..75f09fc7f0 100644 --- a/lib/classes/eventsmanager/notify/validationdone.php +++ b/lib/classes/eventsmanager/notify/validationdone.php @@ -20,7 +20,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract * * @var string */ - public $events = array('__VALIDATION_DONE__'); + public $events = ['__VALIDATION_DONE__']; /** * @@ -52,11 +52,11 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'from' => '' , 'to' => '' , 'ssel_id' => '' - ); + ]; $params = array_merge($default, $params); @@ -134,7 +134,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract try { $registered_user = User_Adapter::getInstance($from, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = $registered_user->get_display_name(); @@ -142,17 +142,17 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract try { $basket = $this->app['converter.basket']->convert($ssel_id); } catch (Exception $e) { - return array(); + return []; } - $ret = array( + $ret = [ 'text' => sprintf( _('%1$s a envoye son rapport de validation de %2$s'), $sender, '' . $basket->getName() . '' ) , 'class' => '' - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php index 2925583985..039e37c2d2 100644 --- a/lib/classes/eventsmanager/notify/validationreminder.php +++ b/lib/classes/eventsmanager/notify/validationreminder.php @@ -20,7 +20,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra * * @var string */ - public $events = array('__VALIDATION_REMINDER__'); + public $events = ['__VALIDATION_REMINDER__']; /** * @@ -52,12 +52,12 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra */ public function fire($event, $params, &$object) { - $default = array( + $default = [ 'from' => '' , 'to' => '' , 'ssel_id' => '' , 'url' => '' - ); + ]; $params = array_merge($default, $params); @@ -139,7 +139,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra try { User_Adapter::getInstance($from, $this->app); } catch (Exception $e) { - return array(); + return []; } $sender = User_Adapter::getInstance($from, $this->app)->get_display_name(); @@ -155,12 +155,12 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra . (string) $sx->ssel_id . '\');return false;">' . $basket_name . ''; - $ret = array( + $ret = [ 'text' => sprintf( _('Rappel : Il vous reste %1$d jours pour valider %2$s de %3$s'), $this->app['phraseanet.registry']->get('GV_validation_reminder'), $bask_link, $sender ) , 'class' => ($unread == 1 ? 'reload_baskets' : '') - ); + ]; return $ret; } diff --git a/lib/classes/eventsmanager/notifyAbstract.php b/lib/classes/eventsmanager/notifyAbstract.php index 2a7bb3372d..b57a6411f4 100644 --- a/lib/classes/eventsmanager/notifyAbstract.php +++ b/lib/classes/eventsmanager/notifyAbstract.php @@ -2,7 +2,7 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract { - protected $events = array('__EVENT__'); + protected $events = ['__EVENT__']; public function fire($event, $params, &$object) { diff --git a/lib/classes/format.php b/lib/classes/format.php index d368c9a5bd..0a0cc0ccdd 100644 --- a/lib/classes/format.php +++ b/lib/classes/format.php @@ -5,8 +5,8 @@ class format public static function arr_to_csv_line($arr, $tri_column = false) { - $line = array(); - $tmp = array(); + $line = []; + $tmp = []; foreach ($arr as $v) { if (is_array($v)) { $line[] = self::arr_to_csv_line($v); @@ -40,7 +40,7 @@ class format public static function arr_to_csv($arr, $tri_column = false) { - $lines = array(); + $lines = []; if ($tri_column) { $title = ""; @@ -60,7 +60,7 @@ class format public static function csv_to_arr($filename) { $separateur = ","; - $array = array(); + $array = []; // For mac $autoDetectLineEndings = ini_get("auto_detect_line_endings"); diff --git a/lib/classes/ftpclient.php b/lib/classes/ftpclient.php index 3c0102039a..81f739b019 100644 --- a/lib/classes/ftpclient.php +++ b/lib/classes/ftpclient.php @@ -5,7 +5,7 @@ class ftpclient protected $connexion; protected $proxy; protected $host; - protected $cached_dirs = array(); + protected $cached_dirs = []; protected $debug = false; public function __construct($host, $port = 21, $timeout = 90, $ssl = false, $proxy = false, $proxyport = false) @@ -365,7 +365,7 @@ class ftpclient $current_dir = $this->pwd(); $contents = ftp_rawlist($this->connexion, $current_dir, ! ! $recursive); - $list = array(); + $list = []; foreach ($contents as $content) { if ($content == '') @@ -388,9 +388,9 @@ class ftpclient $date = strtotime($info[6] . ' ' . $info[5] . ' ' . date('Y') . ' ' . $info[7]); } - $list[$file] = array( + $list[$file] = [ 'date' => $date - ); + ]; } return $list; diff --git a/lib/classes/media/Permalink/Adapter.php b/lib/classes/media/Permalink/Adapter.php index f5e5936bf9..c07a0aca88 100644 --- a/lib/classes/media/Permalink/Adapter.php +++ b/lib/classes/media/Permalink/Adapter.php @@ -148,13 +148,13 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea { $label = $this->get_label() . '.' . pathinfo($this->media_subdef->get_file(), PATHINFO_EXTENSION); - return $this->app->url('permalinks_permalink', array( + return $this->app->url('permalinks_permalink', [ 'sbas_id' => $this->media_subdef->get_sbas_id(), 'record_id' => $this->media_subdef->get_record_id(), 'subdef' => $this->media_subdef->get_name(), 'label' => $label, 'token' => $this->get_token(), - )); + ]); } /** @@ -163,12 +163,12 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea */ public function get_page() { - return $this->app->url('permalinks_permaview', array( + return $this->app->url('permalinks_permaview', [ 'sbas_id' => $this->media_subdef->get_sbas_id(), 'record_id' => $this->media_subdef->get_record_id(), 'subdef' => $this->media_subdef->get_name(), 'token' => $this->get_token(), - )); + ]); } /** @@ -183,7 +183,7 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea $sql = 'UPDATE permalinks SET token = :token, last_modified = NOW() WHERE id = :id'; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':token' => $this->token, ':id' => $this->get_id())); + $stmt->execute([':token' => $this->token, ':id' => $this->get_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -204,10 +204,10 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea WHERE id = :id'; $stmt = $this->databox->get_connection()->prepare($sql); - $params = array( + $params = [ ':activated' => $this->is_activated, ':id' => $this->get_id() - ); + ]; $stmt->execute($params); $stmt->closeCursor(); @@ -235,7 +235,7 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea $sql = 'UPDATE permalinks SET label = :label, last_modified = NOW() WHERE id = :id'; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':label' => $this->label, ':id' => $this->get_id())); + $stmt->execute([':label' => $this->label, ':id' => $this->get_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -268,7 +268,7 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea FROM permalinks p WHERE p.subdef_id = :subdef_id'; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':subdef_id' => $this->media_subdef->get_subdef_id())); + $stmt->execute([':subdef_id' => $this->media_subdef->get_subdef_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -282,14 +282,14 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea $this->last_modified = new DateTime($row['last_modified']); $this->label = $row['label']; - $datas = array( + $datas = [ 'id' => $this->id , 'token' => $this->token , 'is_activated' => $this->is_activated , 'created_on' => $this->created_on , 'last_modified' => $this->last_modified , 'label' => $this->label - ); + ]; $this->set_data_to_cache($datas); @@ -327,11 +327,11 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea (id, subdef_id, token, activated, created_on, last_modified, label) VALUES (null, :subdef_id, :token, :activated, NOW(), NOW(), "")'; - $params = array( + $params = [ ':subdef_id' => $media_subdef->get_subdef_id() , ':token' => random::generatePassword(8, random::LETTERS_AND_NUMBERS) , ':activated' => '1' - ); + ]; $error = null; $stmt = $databox->get_connection()->prepare($sql); @@ -371,11 +371,11 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea AND activated = "1" AND token = :token'; - $params = array( + $params = [ ':record_id' => $record_id , ':token' => $token , ':name' => $name - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php index e660a61572..c7598a6c50 100644 --- a/lib/classes/media/subdef.php +++ b/lib/classes/media/subdef.php @@ -190,10 +190,10 @@ class media_subdef extends media_abstract implements cache_cacheableInterface FROM subdef WHERE name = :name AND record_id = :record_id'; - $params = array( + $params = [ ':record_id' => $this->record->get_record_id(), ':name' => $this->name - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -225,7 +225,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->find_substitute_file(); } - $datas = array( + $datas = [ 'mime' => $this->mime , 'width' => $this->width , 'height' => $this->height @@ -238,7 +238,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface , 'subdef_id' => $this->subdef_id , 'modification_date' => $this->modification_date , 'creation_date' => $this->creation_date - ); + ]; $this->set_data_to_cache($datas); @@ -358,7 +358,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $sql = "UPDATE subdef SET etag = :etag WHERE subdef_id = :subdef_id"; $stmt = $this->record->get_databox()->get_connection()->prepare($sql); - $stmt->execute(array(':subdef_id' => $this->subdef_id, ':etag' => $etag)); + $stmt->execute([':subdef_id' => $this->subdef_id, ':etag' => $etag]); $stmt->closeCursor(); return $this; @@ -531,7 +531,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface public function getDevices() { if ($this->get_name() == 'document') { - return array(\databox_subdef::DEVICE_ALL); + return [\databox_subdef::DEVICE_ALL]; } try { @@ -541,7 +541,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface ->get_subdef($this->record->get_type(), $this->get_name()) ->getDevices(); } catch (\Exception_Databox_SubdefNotFound $e) { - return array(); + return []; } } @@ -574,12 +574,12 @@ class media_subdef extends media_abstract implements cache_cacheableInterface SET height = :height , width = :width, updated_on = NOW() WHERE record_id = :record_id AND name = :name"; - $params = array( + $params = [ ':width' => $media->getWidth(), ':height' => $media->getHeight(), ':record_id' => $this->get_record_id(), ':name' => $this->get_name(), - ); + ]; $stmt = $this->record->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -604,14 +604,14 @@ class media_subdef extends media_abstract implements cache_cacheableInterface public function readTechnicalDatas(MediaVorus $mediavorus) { if ( ! $this->is_physically_present()) { - return array(); + return []; } $media = $mediavorus->guess($this->get_pathfile()); - $datas = array(); + $datas = []; - $methods = array( + $methods = [ self::TC_DATA_WIDTH => 'getWidth', self::TC_DATA_HEIGHT => 'getHeight', self::TC_DATA_FOCALLENGTH => 'getFocalLength', @@ -630,11 +630,11 @@ class media_subdef extends media_abstract implements cache_cacheableInterface self::TC_DATA_AUDIOSAMPLERATE => 'getAudioSampleRate', self::TC_DATA_VIDEOCODEC => 'getVideoCodec', self::TC_DATA_AUDIOCODEC => 'getAudioCodec', - ); + ]; foreach ($methods as $tc_name => $method) { if (method_exists($media, $method)) { - $result = call_user_func(array($media, $method)); + $result = call_user_func([$media, $method]); if (null !== $result) { $datas[$tc_name] = $result; @@ -660,7 +660,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $path = $media->getFile()->getPath(); $newname = $media->getFile()->getFilename(); - $params = array( + $params = [ ':path' => $path, ':file' => $newname, ':width' => 0, @@ -668,7 +668,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface ':mime' => $media->getFile()->getMimeType(), ':size' => $media->getFile()->getSize(), ':dispatched' => 1, - ); + ]; if (method_exists($media, 'getWidth') && null !== $media->getWidth()) { $params[':width'] = $media->getWidth(); @@ -682,10 +682,10 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $sql = 'SELECT subdef_id FROM subdef WHERE record_id = :record_id AND name = :name'; $stmt = $connbas->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':record_id' => $record->get_record_id(), ':name' => $name, - )); + ]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -738,7 +738,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface return; } - if (in_array($this->mime, array('video/mp4'))) { + if (in_array($this->mime, ['video/mp4'])) { $token = p4file::apache_tokenize($this->app['phraseanet.registry'], $this->get_pathfile()); if ($token) { $this->url = $token; diff --git a/lib/classes/module/console/checkExtension.php b/lib/classes/module/console/checkExtension.php index ff4b9dee89..0ff803ad82 100644 --- a/lib/classes/module/console/checkExtension.php +++ b/lib/classes/module/console/checkExtension.php @@ -134,16 +134,16 @@ class module_console_checkExtension extends Command return 1; } - $tbases = array(); + $tbases = []; foreach ($phSession["bases"] as $phbase) { - $tcoll = array(); + $tcoll = []; foreach ($phbase["collections"] as $coll) { $tcoll[] = 0 + $coll["base_id"]; } if (sizeof($tcoll) > 0) { $kbase = "S" . $phbase["sbas_id"]; - $tbases[$kbase] = array(); + $tbases[$kbase] = []; $tbases[$kbase]["sbas_id"] = $phbase["sbas_id"]; $tbases[$kbase]["searchcoll"] = $tcoll; $tbases[$kbase]["mask_xor"] = $tbases[$kbase]["mask_and"] = 0; @@ -172,7 +172,7 @@ class module_console_checkExtension extends Command , false , PHRASEA_MULTIDOC_DOCONLY , '' - , array() + , [] ); if ($ret) { @@ -206,10 +206,10 @@ class module_console_checkExtension extends Command // prepare the test before closing session if (function_exists("phrasea_public_query")) { // fill an array for each sbas to query - $tbases = array(); + $tbases = []; foreach ($phSession["bases"] as $phbase) { // fill an array of collections to query for this sbas - $tcoll = array(); + $tcoll = []; foreach ($phbase["collections"] as $coll) { $tcoll[] = 0 + $coll["base_id"]; } @@ -220,11 +220,11 @@ class module_console_checkExtension extends Command $treeq = $qp->parsequery($input->getOption('query')); $arrayq = $qp->makequery($treeq); - $tbases["S".$phbase["sbas_id"]] = array( // key does no matter + $tbases["S".$phbase["sbas_id"]] = [ // key does no matter "sbas_id" => $phbase["sbas_id"], // sbas_id "searchcoll" => $tcoll, // colls to query "arrayq" => $arrayq // parsed query - ); + ]; } } } @@ -249,7 +249,7 @@ class module_console_checkExtension extends Command $tbases // array of sbas with colls and query , PHRASEA_MULTIDOC_DOCONLY // mode , '' // sortfield - , array() // search business fields + , [] // search business fields , '' // lng for stemmed search , 0 // offset for first answer (start=0) , 5 // nbr of answers diff --git a/lib/classes/module/console/fieldsMerge.php b/lib/classes/module/console/fieldsMerge.php index ae750629ea..5296cdf672 100644 --- a/lib/classes/module/console/fieldsMerge.php +++ b/lib/classes/module/console/fieldsMerge.php @@ -57,7 +57,7 @@ class module_console_fieldsMerge extends Command return 1; } - $sources = array(); + $sources = []; foreach ($input->getArgument('source') as $source_id) { $sources[] = $databox->get_meta_structure()->get_element($source_id); @@ -71,7 +71,7 @@ class module_console_fieldsMerge extends Command $destination = $databox->get_meta_structure()->get_element($input->getArgument('destination')); - $types = $multis = array(); + $types = $multis = []; foreach ($sources as $source) { array_push($types, $source->get_type()); @@ -97,7 +97,7 @@ class module_console_fieldsMerge extends Command ); } - $field_names = array(); + $field_names = []; foreach ($sources as $source) { $field_names[] = $source->get_name(); @@ -172,7 +172,7 @@ class module_console_fieldsMerge extends Command foreach ($results as $row) { $record = $databox->get_record($row['record_id']); - $datas = array(); + $datas = []; foreach ($sources as $source) { try { @@ -195,11 +195,11 @@ class module_console_fieldsMerge extends Command } foreach ((array) $datas as $data) { - $record->set_metadatas(array(array( + $record->set_metadatas([[ 'meta_struct_id' => $destination->get_id(), 'meta_id' => null, 'value' => $data, - )), true); + ]], true); } $this->getService('phraseanet.SE')->updateRecord($record); diff --git a/lib/classes/module/console/fieldsRename.php b/lib/classes/module/console/fieldsRename.php index b1414f3e7a..e2b8159959 100644 --- a/lib/classes/module/console/fieldsRename.php +++ b/lib/classes/module/console/fieldsRename.php @@ -102,7 +102,7 @@ class module_console_fieldsRename extends Command foreach ($results as $row) { $record = $databox->get_record($row['record_id']); - $record->set_metadatas(array()); + $record->set_metadatas([]); unset($record); } diff --git a/lib/classes/module/console/sphinxGenerateSuggestion.php b/lib/classes/module/console/sphinxGenerateSuggestion.php index a68f5c2b75..b9a4fad4f6 100644 --- a/lib/classes/module/console/sphinxGenerateSuggestion.php +++ b/lib/classes/module/console/sphinxGenerateSuggestion.php @@ -43,7 +43,7 @@ class module_console_sphinxGenerateSuggestion extends Command foreach ($params as $sbas_id => $p) { $index = sprintf("%u", crc32( str_replace( - array('.', '%') + ['.', '%'] , '_' , sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname']) ) @@ -61,7 +61,7 @@ class module_console_sphinxGenerateSuggestion extends Command return 1; } - $builder = ProcessBuilder::create(array('/usr/local/bin/indexer')); + $builder = ProcessBuilder::create(['/usr/local/bin/indexer']); $builder->add('metadatas' . $index) ->add('--buildstops') ->add($tmp_file) diff --git a/lib/classes/module/console/systemClearCache.php b/lib/classes/module/console/systemClearCache.php index 9f350f7188..7cb8489bf1 100644 --- a/lib/classes/module/console/systemClearCache.php +++ b/lib/classes/module/console/systemClearCache.php @@ -39,13 +39,13 @@ class module_console_systemClearCache extends Command $finder ->exclude('.git') ->exclude('.svn') - ->in(array( + ->in([ $this->container['root.path'] . '/tmp/cache_minify/', $this->container['root.path'] . '/tmp/cache_twig/', $this->container['root.path'] . '/tmp/cache/profiler/', $this->container['root.path'] . '/tmp/doctrine/', $this->container['root.path'] . '/tmp/serializer/', - )); + ]); $filesystem = new Filesystem(); diff --git a/lib/classes/module/console/systemExport.php b/lib/classes/module/console/systemExport.php index 2c2dfceb27..95873dda68 100644 --- a/lib/classes/module/console/systemExport.php +++ b/lib/classes/module/console/systemExport.php @@ -39,7 +39,7 @@ class module_console_systemExport extends Command * To implement */ // $this->addOption('excludefield', 'f', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY -// , 'Exclude field from XML', array()); +// , 'Exclude field from XML', []); /** * To implement @@ -57,10 +57,10 @@ class module_console_systemExport extends Command , 'Limit files quantity (for test purposes)', false); $this->addOption('base_id', 'b', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY - , 'Restrict on base_ids', array()); + , 'Restrict on base_ids', []); $this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY - , 'Restrict on sbas_ids', array()); + , 'Restrict on sbas_ids', []); $this->addArgument('directory', InputOption::VALUE_REQUIRED , 'The directory where to export'); @@ -134,7 +134,7 @@ class module_console_systemExport extends Command } $go = true; - $coll_ids = array(); + $coll_ids = []; if (count($restrictBaseIds) > 0) { $go = false; @@ -187,7 +187,7 @@ class module_console_systemExport extends Command $record = $databox->get_record($row['record_id']); if (($done % $docPerDir) === 0) { $dir_increment ++; - $in_dir_files = array(); + $in_dir_files = []; $current_dir = $local_export . sprintf($dir_format, $dir_increment) . '/'; $this->getService('filesystem')->mkdir($current_dir); } diff --git a/lib/classes/module/console/systemMailCheck.php b/lib/classes/module/console/systemMailCheck.php index 17940fddd6..3059308c20 100644 --- a/lib/classes/module/console/systemMailCheck.php +++ b/lib/classes/module/console/systemMailCheck.php @@ -42,7 +42,7 @@ class module_console_systemMailCheck extends Command { $output->writeln("Processing..."); - $bad_users = array(); + $bad_users = []; if (version_compare($this->getService('phraseanet.appbox')->get_version(), '3.9', '<')) { $bad_users = MailChecker::getWrongEmailUsers($this->container); } @@ -76,7 +76,7 @@ class module_console_systemMailCheck extends Command . 'continue (C), detach from mail (d), or stop (s)'; $continue = mb_strtolower($dialog->ask($output, $question, 'C')); - } while ( ! in_array($continue, array('c', 'd', 's'))); + } while ( ! in_array($continue, ['c', 'd', 's'])); if ($continue == 's') { return false; diff --git a/lib/classes/module/console/systemTemplateGenerator.php b/lib/classes/module/console/systemTemplateGenerator.php index 428ed7c68d..fc5f5a0f1b 100644 --- a/lib/classes/module/console/systemTemplateGenerator.php +++ b/lib/classes/module/console/systemTemplateGenerator.php @@ -35,10 +35,10 @@ class module_console_systemTemplateGenerator extends Command protected function doExecute(InputInterface $input, OutputInterface $output) { - $tplDirs = array( + $tplDirs = [ realpath(__DIR__ . '/../../../../templates/web/'), realpath(__DIR__ . '/../../../../templates/mobile/') - ); + ]; $n_ok = $n_error = 0; @@ -48,9 +48,9 @@ class module_console_systemTemplateGenerator extends Command $this->container['twig']; foreach ($tplDirs as $tplDir) { - $this->container['twig.loader.filesystem']->setPaths(array($tplDir)); + $this->container['twig.loader.filesystem']->setPaths([$tplDir]); $finder = new Finder(); - foreach ($finder->files()->in(array($tplDir)) as $file) { + foreach ($finder->files()->in([$tplDir]) as $file) { try { $this->container['twig']->loadTemplate(str_replace($tplDir, '', $file->getPathname())); $output->writeln('' . $file . ''); diff --git a/lib/classes/module/console/systemUpgrade.php b/lib/classes/module/console/systemUpgrade.php index 960d22f7b5..d4ba3a18df 100644 --- a/lib/classes/module/console/systemUpgrade.php +++ b/lib/classes/module/console/systemUpgrade.php @@ -58,7 +58,7 @@ class module_console_systemUpgrade extends Command do { $continue = mb_strtolower($dialog->ask($output, '' . _('Continuer ?') . ' (Y/n)', 'Y')); - } while (!in_array($continue, array('y', 'n'))); + } while (!in_array($continue, ['y', 'n'])); } else { $continue = 'y'; } diff --git a/lib/classes/module/report.php b/lib/classes/module/report.php index 0607e84634..7043e1f765 100644 --- a/lib/classes/module/report.php +++ b/lib/classes/module/report.php @@ -41,7 +41,7 @@ class module_report * The result of the report * @var array */ - public $report = array(); + public $report = []; /** * The title of the report @@ -53,25 +53,25 @@ class module_report * default displayed value in the formated tab * @var array */ - protected $display = array(); + protected $display = []; /** * ? * @var */ - protected $default_display = array(); + protected $default_display = []; /** * Contain all the field from the sql request * @var array */ - protected $champ = array(); + protected $champ = []; /** * result of the report * @var array */ - protected $result = array(); + protected $result = []; /** * The id of all collections from a databox @@ -117,7 +117,7 @@ class module_report /** * the request executed */ - protected $params = array(); + protected $params = []; /** * do we display next and previous button @@ -159,33 +159,33 @@ class module_report * filter executed on report choose by the user * @var array; */ - protected $tab_filter = array(); + protected $tab_filter = []; /** * column displayed in the report choose by the user * @var */ - protected $active_column = array(); + protected $active_column = []; /** * array that contains the string displayed * foreach filters * @var */ - protected $posting_filter = array(); + protected $posting_filter = []; /** * The ORDER BY filters of the query * by default is empty * @var array */ - protected $tab_order = array(); + protected $tab_order = []; /** * define columns that are boundable * @var */ - protected $bound = array(); + protected $bound = []; /** * do we display print button @@ -209,7 +209,7 @@ class module_report * gettext correspondance for all available columns in report * @var array */ - protected $cor = array(); + protected $cor = []; /** * group result of a report this is the name ogf the grouped column @@ -232,7 +232,7 @@ class module_report /** * */ - protected $cor_query = array(); + protected $cor_query = []; protected $isInformative; /** @@ -596,8 +596,8 @@ class module_report { $row = array_shift($rs); - $this->champ = is_array($row) ? array_keys($row) : array(); - $this->default_display = is_array($row) ? array_keys($row) : array(); + $this->champ = is_array($row) ? array_keys($row) : []; + $this->default_display = is_array($row) ? array_keys($row) : []; return; } @@ -657,7 +657,7 @@ class module_report */ private function setCor() { - return array( + return [ 'user' => _('report:: utilisateur'), 'coll_id' => _('report:: collections'), 'connexion' => _('report:: Connexion'), @@ -680,7 +680,7 @@ class module_report 'size' => _('report:: taille'), 'copyright' => _('report:: copyright'), 'final' => _('phraseanet:: sous definition') - ); + ]; return; } @@ -691,14 +691,14 @@ class module_report */ private function setDay() { - return Array( + return [ 1 => _('phraseanet::jours:: lundi'), 2 => _('phraseanet::jours:: mardi'), 3 => _('phraseanet::jours:: mercredi'), 4 => _('phraseanet::jours:: jeudi'), 5 => _('phraseanet::jours:: vendredi'), 6 => _('phraseanet::jours:: samedi'), - 7 => _('phraseanet::jours:: dimanche')); + 7 => _('phraseanet::jours:: dimanche')]; } /** @@ -707,7 +707,7 @@ class module_report */ private function setMonth() { - return array( + return [ _('janvier'), _('fevrier'), _('mars'), @@ -720,7 +720,7 @@ class module_report _('octobre'), _('novembre'), _('decembre') - ); + ]; } /** @@ -759,9 +759,9 @@ class module_report */ protected function initDefaultConfigColumn($display) { - $array = array(); + $array = []; foreach ($display as $key => $value) - $array[$value] = array("", 0, 0, 0, 0); + $array[$value] = ["", 0, 0, 0, 0]; $this->setConfigColumn($array); } @@ -791,13 +791,13 @@ class module_report $bound = array_key_exists($column, $this->bound) ? $this->bound[$column] : $row[2]; $filter = (isset($row[3]) ? $row[3] : 0); $groupby = $row[4]; - $config = array( + $config = [ 'title' => empty($title) ? (empty($title_text) ? $column : $title_text) : $title, 'sort' => $sort, 'bound' => $bound, 'filter' => $filter, 'groupby' => $groupby - ); + ]; $this->display[$column] = $config; } @@ -857,7 +857,7 @@ class module_report public static function getPreff(Application $app, $sbasid) { - $tab = array(); + $tab = []; $databox = $app['phraseanet.appbox']->get_databox((int) $sbasid); diff --git a/lib/classes/module/report/activity.php b/lib/classes/module/report/activity.php index 2258dacb15..432ca1b619 100644 --- a/lib/classes/module/report/activity.php +++ b/lib/classes/module/report/activity.php @@ -23,7 +23,7 @@ class module_report_activity extends module_report * Array correspondance column -> to query * @var array */ - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -39,7 +39,7 @@ class module_report_activity extends module_report 'final' => 'log_docs.final', 'comment' => 'log_docs.comment', 'size' => 'subdef.size' - ); + ]; public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist) { @@ -69,7 +69,7 @@ class module_report_activity extends module_report private function setDisplayForActivity($rs) { - $hours = array(); + $hours = []; for ($i = 0; $i < 24; $i ++) { array_push($this->display, $i); @@ -90,13 +90,13 @@ class module_report_activity extends module_report */ public function getActivityPerHours() { - $this->result = array(); + $this->result = []; $this->title = _('report:: activite par heure'); $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(), $filter['params']); + $params = array_merge([], $filter['params']); $sql = " SELECT tt.heures, SUM(1) AS nb @@ -150,12 +150,12 @@ class module_report_activity extends module_report */ public function getAllQuestionByUser($value, $what) { - $result = array(); + $result = []; $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(':main_value' => $value), $filter['params']); + $params = array_merge([':main_value' => $value], $filter['params']); $sql = " SELECT DATE_FORMAT(log_search.date,'%Y-%m-%d %H:%i:%S') AS date , @@ -203,12 +203,12 @@ class module_report_activity extends module_report */ public function getTopQuestion($tab = false, $no_answer = false) { - $this->report['value'] = array(); - $this->report['value2'] = array(); + $this->report['value'] = []; + $this->report['value2'] = []; $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(), $filter['params']); + $params = array_merge([], $filter['params']); ($no_answer) ? $this->title = _('report:: questions sans reponses') : $this->title = _('report:: questions les plus posees'); @@ -268,10 +268,10 @@ class module_report_activity extends module_report */ public function getAllDownloadByUserBase($usr, $config = false) { - $result = array(); + $result = []; $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(), $filter['params']); + $params = array_merge([], $filter['params']); $databox = $this->app['phraseanet.appbox']->get_databox($this->sbas_id); $sql = " @@ -331,7 +331,7 @@ class module_report_activity extends module_report $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(), $filter['params']); + $params = array_merge([], $filter['params']); $sql = " SELECT tt.record_id, DATE_FORMAT(tt.the_date, GET_FORMAT(DATE, 'INTERNAL')) AS ddate, tt.final, SUM(1) AS nb @@ -357,7 +357,7 @@ class module_report_activity extends module_report $this->setChamp($rs); $this->setDisplay($tab); - $total = array('tot_doc' => 0, 'tot_prev' => 0, 'tot_dl' => 0); + $total = ['tot_doc' => 0, 'tot_prev' => 0, 'tot_dl' => 0]; $i = -1; $last_date = null; @@ -366,12 +366,12 @@ class module_report_activity extends module_report $date = $this->app['date-formatter']->getPrettyString(new DateTime($row['ddate'])); if ($date != $last_date) { $i ++; - $this->result[$i] = array( + $this->result[$i] = [ 'ddate' => $date, 'document' => 0, 'preview' => 0, 'total' => 0 - ); + ]; $last_date = $date; } @@ -419,7 +419,7 @@ class module_report_activity extends module_report $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(), $filter['params']); + $params = array_merge([], $filter['params']); $this->req = " SELECT SUM(1) AS connexion, tt.user, tt.usrid FROM ( @@ -452,9 +452,9 @@ class module_report_activity extends module_report //set title $this->title = _('report:: Detail des connexions'); //set champ - $this->champ = array($on, 'connexion'); + $this->champ = [$on, 'connexion']; //set display - $this->default_display = array($on, 'connexion'); + $this->default_display = [$on, 'connexion']; //set configuration of column ($tab) ? $this->setConfigColumn($tab) : $this->initDefaultConfigColumn($this->default_display); @@ -507,7 +507,7 @@ class module_report_activity extends module_report $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters()->getReportFilter(); - $params = array_merge(array(), $filter['params']); + $params = array_merge([], $filter['params']); $sql = " SELECT tt.usrid, TRIM(" . $on . ") AS " . $on . ", tt.final, sum(1) AS nb, sum(size) AS poid @@ -532,12 +532,12 @@ class module_report_activity extends module_report $save_user = ""; $i = -1; - $total = array( + $total = [ 'nbdoc' => 0, 'poiddoc' => 0, 'nbprev' => 0, 'poidprev' => 0 - ); + ]; $this->setChamp($rs); @@ -618,13 +618,13 @@ class module_report_activity extends module_report public static function topTenUser(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); - $result['top_ten_doc'] = array(); - $result['top_ten_prev'] = array(); - $result['top_ten_poiddoc'] = array(); - $result['top_ten_poidprev'] = array(); + $result = []; + $result['top_ten_doc'] = []; + $result['top_ten_prev'] = []; + $result['top_ten_poiddoc'] = []; + $result['top_ten_poidprev'] = []; - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $params = array_merge($params, $datefilter['params']); @@ -698,13 +698,13 @@ class module_report_activity extends module_report public static function activity(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $res = array(); + $res = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -744,14 +744,14 @@ class module_report_activity extends module_report public static function activityDay(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); - $res = array(); + $result = []; + $res = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -786,13 +786,13 @@ class module_report_activity extends module_report public static function activityQuestion(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); + $result = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -826,13 +826,13 @@ class module_report_activity extends module_report public static function activiteTopQuestion(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); + $result = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -854,7 +854,7 @@ class module_report_activity extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $conv = array(" " => ""); + $conv = [" " => ""]; foreach ($rs as $row) { $question = $row['question']; $question = mb_strtolower(strtr($question, $conv)); @@ -869,11 +869,11 @@ class module_report_activity extends module_report public static function activiteTopTenSiteView(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); + $result = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(); + $params = []; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -912,11 +912,11 @@ class module_report_activity extends module_report public static function activiteAddedDocument(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); + $result = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(); + $params = []; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -947,11 +947,11 @@ class module_report_activity extends module_report public static function activiteEditedDocument(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); + $result = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(); + $params = []; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " @@ -983,11 +983,11 @@ class module_report_activity extends module_report public static function activiteAddedTopTenUser(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id) { $conn = connection::getPDOConnection($app, $sbas_id); - $result = array(); + $result = []; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array(); + $params = []; $params = array_merge($params, $datefilter['params'], $collfilter['params']); $sql = " diff --git a/lib/classes/module/report/add.php b/lib/classes/module/report/add.php index 762a29d040..f4163443de 100644 --- a/lib/classes/module/report/add.php +++ b/lib/classes/module/report/add.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_add extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -29,7 +29,7 @@ class module_report_add extends module_report 'final' => 'd.final', 'comment' => 'd.comment', 'size' => 's.size' - ); + ]; /** * constructor @@ -71,7 +71,7 @@ class module_report_add extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $value = $row['val']; @@ -88,7 +88,7 @@ class module_report_add extends module_report elseif ($field == 'size') $caption = p4string::format_octets($value); - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; diff --git a/lib/classes/module/report/connexion.php b/lib/classes/module/report/connexion.php index 95a92af078..160b6be345 100644 --- a/lib/classes/module/report/connexion.php +++ b/lib/classes/module/report/connexion.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_connexion extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'usrid' => 'log.usrid', 'ddate' => 'log.date', @@ -25,7 +25,7 @@ class module_report_connexion extends module_report 'sit_session' => 'log.sit_session', 'appli' => 'log.appli', 'ip' => 'log.ip' - ); + ]; /** * constructor @@ -64,7 +64,7 @@ class module_report_connexion extends module_report */ public function colFilter($field) { - $ret = array(); + $ret = []; $sqlBuilder = $this->sqlBuilder('connexion'); $var = $sqlBuilder->sqlDistinctValByField($field); $sql = $var['sql']; @@ -83,7 +83,7 @@ class module_report_connexion extends module_report $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); else $caption = $row['val']; - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; @@ -140,9 +140,9 @@ class module_report_connexion extends module_report $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); - $params = array_merge(array( + $params = array_merge([ ':site_id' => $app['configuration']['main']['key'] - ), + ], $datefilter['params'], $collfilter['params'] ); diff --git a/lib/classes/module/report/dashboard.php b/lib/classes/module/report/dashboard.php index 493989a9d4..52c00c85f7 100644 --- a/lib/classes/module/report/dashboard.php +++ b/lib/classes/module/report/dashboard.php @@ -36,13 +36,13 @@ class module_report_dashboard implements module_report_dashboard_componentInterf * a le droit de report * @var */ - public $authorizedCollection = array(); + public $authorizedCollection = []; /** * @desc le tableau qui contient le dashboard * @var */ - public $dashboard = array(); + public $dashboard = []; /** * @des le nombre par defaut de resultats afficher par categorie @@ -207,7 +207,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf $tri = $this->group()->tri(); $x = $tri->getDash(); $a = $tri->top()->getTop($this->nbtop); - $this->dashboard = array(); + $this->dashboard = []; foreach ($a as $k => $v) { if (array_key_exists($k, $x)) { $x[$k] = $v; @@ -239,23 +239,23 @@ class module_report_dashboard implements module_report_dashboard_componentInterf */ public function getAllColl() { - $all_coll = array(); + $all_coll = []; - $base_ids = $this->app['acl']->get($this->usr)->get_granted_base(array('canreport')); + $base_ids = $this->app['acl']->get($this->usr)->get_granted_base(['canreport']); foreach ($base_ids as $base_id => $collection) { $databox = $collection->get_databox(); $sbas_id = $databox->get_sbas_id(); if ( ! isset($all_coll[$sbas_id])) { - $all_coll[$sbas_id] = array(); + $all_coll[$sbas_id] = []; $all_coll[$sbas_id]['name_sbas'] = $databox->get_label($this->app['locale.I18n']); } - $all_coll[$sbas_id]['sbas_collections'][] = array( + $all_coll[$sbas_id]['sbas_collections'][] = [ 'base_id' => $base_id, 'sbas_id' => $sbas_id, 'coll_id' => $collection->get_base_id(), 'name' => $collection->get_label($this->app['locale.I18n']) - ); + ]; } return $all_coll; @@ -270,17 +270,17 @@ class module_report_dashboard implements module_report_dashboard_componentInterf $all_coll = $this->getAllColl(); foreach ($all_coll as $sbas => $info) { - $listeColl = array(); + $listeColl = []; foreach ($info['sbas_collections'] as $key => $value) { $listeColl[] = (int) $value['coll_id']; } - $this->authorizedCollection[(int) $sbas] = array( + $this->authorizedCollection[(int) $sbas] = [ 'sbas_id' => (int) $sbas, 'coll' => implode(',', $listeColl), 'name' => phrasea::sbas_labels($sbas, $this->app) - ); + ]; } return; diff --git a/lib/classes/module/report/dashboard/feed.php b/lib/classes/module/report/dashboard/feed.php index a49ce226ae..de0ac71740 100644 --- a/lib/classes/module/report/dashboard/feed.php +++ b/lib/classes/module/report/dashboard/feed.php @@ -54,7 +54,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI * @desc le tableau qui contien les resultats * @var */ - public $report = array(); + public $report = []; private $app; /** @@ -242,9 +242,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI public function __sleep() { - $vars = array(); + $vars = []; foreach ($this as $key => $value) { - if (in_array($key, array('app'))) + if (in_array($key, ['app'])) continue; $vars[] = $key; } diff --git a/lib/classes/module/report/dashboard/group.php b/lib/classes/module/report/dashboard/group.php index 79723bc1bc..4fea10c869 100644 --- a/lib/classes/module/report/dashboard/group.php +++ b/lib/classes/module/report/dashboard/group.php @@ -12,7 +12,7 @@ class module_report_dashboard_group implements module_report_dashboard_componentInterface { public $group_dash; - public $dashboard = array(); + public $dashboard = []; private $valid = false; /** @@ -35,7 +35,7 @@ class module_report_dashboard_group implements module_report_dashboard_component { if ($this->valid) { if (is_null($this->group_dash)) - $this->group_dash = array(); + $this->group_dash = []; foreach ($this->dashboard as $key => $dash) { if (is_object($dash) && $dash instanceof module_report_dashboard_feed && diff --git a/lib/classes/module/report/dashboard/merge.php b/lib/classes/module/report/dashboard/merge.php index 7168a5b113..f64846df6c 100644 --- a/lib/classes/module/report/dashboard/merge.php +++ b/lib/classes/module/report/dashboard/merge.php @@ -11,8 +11,8 @@ class module_report_dashboard_merge implements module_report_dashboard_componentInterface { - public $sort = array(); - public $sorted = array(); + public $sort = []; + public $sorted = []; private $currentkey; private $valid = false; diff --git a/lib/classes/module/report/dashboard/sort.php b/lib/classes/module/report/dashboard/sort.php index a0b89ad093..cecbde6048 100644 --- a/lib/classes/module/report/dashboard/sort.php +++ b/lib/classes/module/report/dashboard/sort.php @@ -11,8 +11,8 @@ class module_report_dashboard_sort implements module_report_dashboard_componentInterface { - public $arrayToSort = array(); - public $arraySorted = array(); + public $arrayToSort = []; + public $arraySorted = []; public function __construct(module_report_dashboard_merge $tridash) { @@ -99,7 +99,7 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI foreach ($args as $n => $field) { if (is_string($field)) { // = clef - $tmp = array(); + $tmp = []; foreach ($data as $key => $row) $tmp[$key] = $row[$field]; $args[$n] = &$tmp; @@ -130,15 +130,15 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI public function getTop($nbtop) { if ( ! is_int($nbtop)) { - return array(); + return []; } - $tmp = array(); + $tmp = []; if ($this->isValid()) { foreach ($this->arraySorted as $k => $v) { $i = 0; - $tmp[$k] = array(); + $tmp[$k] = []; foreach ($v as $a) { if ($i < $nbtop) array_push($tmp[$k], $a); diff --git a/lib/classes/module/report/download.php b/lib/classes/module/report/download.php index 20cdf733bf..2ebfcbfb42 100644 --- a/lib/classes/module/report/download.php +++ b/lib/classes/module/report/download.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_download extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -31,7 +31,7 @@ class module_report_download extends module_report 'size' => 'subdef.size', 'mime' => 'subdef.mime', 'file' => 'subdef.file' - ); + ]; /** * constructor @@ -65,7 +65,7 @@ class module_report_download extends module_report public function colFilter($field, $on = false) { - $ret = array(); + $ret = []; $sqlBuilder = $this->sqlBuilder('download'); $var = $sqlBuilder->sqlDistinctValByField($field); $sql = $var['sql']; @@ -86,7 +86,7 @@ class module_report_download extends module_report $caption = p4string::format_octets($value); else $caption = $value; - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; @@ -174,7 +174,7 @@ class module_report_download extends module_report { $conn = connection::getPDOConnection($app, $sbas_id); - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); $params = array_merge($params, $datefilter['params'], $collfilter['params']); @@ -210,16 +210,16 @@ class module_report_download extends module_report $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $conn = $databox->get_connection(); - $params = array(':site_id' => $app['configuration']['main']['key']); + $params = [':site_id' => $app['configuration']['main']['key']]; $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); $params = array_merge($params, $datefilter['params'], $collfilter['params']); $finalfilter = ""; - $array = array( - 'preview' => array(), - 'document' => array() - ); + $array = [ + 'preview' => [], + 'document' => [] + ]; $finalfilter .= $datefilter['sql'] . ' AND '; $finalfilter .= $collfilter['sql'] . ' AND '; diff --git a/lib/classes/module/report/edit.php b/lib/classes/module/report/edit.php index b041c1bd72..7ee7b818ee 100644 --- a/lib/classes/module/report/edit.php +++ b/lib/classes/module/report/edit.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_edit extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -29,7 +29,7 @@ class module_report_edit extends module_report 'final' => 'd.final', 'comment' => 'd.comment', 'size' => 's.size' - ); + ]; /** * constructor @@ -72,7 +72,7 @@ class module_report_edit extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $value = $row['val']; $caption = $value; @@ -89,7 +89,7 @@ class module_report_edit extends module_report $caption = p4string::format_octets($value); } - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; diff --git a/lib/classes/module/report/filter.php b/lib/classes/module/report/filter.php index 9804458ec6..992dd119d3 100644 --- a/lib/classes/module/report/filter.php +++ b/lib/classes/module/report/filter.php @@ -14,10 +14,10 @@ use Alchemy\Phrasea\Application; class module_report_filter { private $app; - private $posting_filter = array(); - private $cor_query = array(); - private $active_column = array(); - private $trans = array( + private $posting_filter = []; + private $cor_query = []; + private $active_column = []; + private $trans = [ 'user' => 'phraseanet::utilisateurs', 'ddate' => 'report:: date', 'ip' => 'report:: IP', @@ -31,7 +31,7 @@ class module_report_filter 'coll_id' => 'report:: collections', 'comment' => 'report:: commentaire', 'search' => 'report:: question', - ); + ]; public function __construct(Application $app, $current_filter, $correspondance) { @@ -64,7 +64,7 @@ class module_report_filter public function addFilter($field, $operator, $value) { if ($this->checkSameFilter($field, $operator, $value)) - $this->tab_filter[] = array('f' => $field, 'o' => $operator, 'v' => $value); + $this->tab_filter[] = ['f' => $field, 'o' => $operator, 'v' => $value]; } public function getPostingFilter() @@ -87,7 +87,7 @@ class module_report_filter $value = $this->app['date-formatter']->getPrettyString(new DateTime($value)); } - $this->posting_filter[] = array('f' => $field, 'v' => $value); + $this->posting_filter[] = ['f' => $field, 'v' => $value]; } } diff --git a/lib/classes/module/report/nav.php b/lib/classes/module/report/nav.php index a93dc79564..aa039a8682 100644 --- a/lib/classes/module/report/nav.php +++ b/lib/classes/module/report/nav.php @@ -19,7 +19,7 @@ class module_report_nav extends module_report */ public $total_pourcent = null; public $config = false; - public $cor_query = array( + public $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -35,7 +35,7 @@ class module_report_nav extends module_report 'final' => 'log_docs.final', 'comment' => 'log_docs.comment', 'size' => 'subdef.size' - ); + ]; /** * constructor @@ -57,7 +57,7 @@ class module_report_nav extends module_report $filter = $sqlBuilder->getFilters(); $report_filter = $filter->getReportFilter(); - $params = array_merge(array(), $report_filter['params']); + $params = array_merge([], $report_filter['params']); $sql = ' SELECT SUM(1) AS total FROM ( @@ -81,12 +81,12 @@ class module_report_nav extends module_report */ private function initialize() { - $this->report['legend'] = array(); - $this->report['value'] = array(); - $this->result = array(); - $this->champ = array(); - $this->default_display = array(); - $this->display = array(); + $this->report['legend'] = []; + $this->report['value'] = []; + $this->result = []; + $this->champ = []; + $this->default_display = []; + $this->display = []; } /** @@ -109,7 +109,7 @@ class module_report_nav extends module_report } $report_filter = $filter->getReportFilter(); - $params = array_merge(array(), $report_filter['params']); + $params = array_merge([], $report_filter['params']); $sql = ' SELECT tt.nav, SUM(1) AS nb, ROUND((SUM(1) / ' . $this->total_pourcent . ' * 100), 1) AS pourcent @@ -168,7 +168,7 @@ class module_report_nav extends module_report } $report_filter = $filter->getReportFilter(); - $params = array_merge(array(), $report_filter['params']); + $params = array_merge([], $report_filter['params']); $sql = ' SELECT tt.os, COUNT(os) AS nb, ROUND((COUNT(os)/' . $this->total_pourcent . '*100),1) AS pourcent @@ -226,7 +226,7 @@ class module_report_nav extends module_report } $report_filter = $filter->getReportFilter(); - $params = array_merge(array(), $report_filter['params']); + $params = array_merge([], $report_filter['params']); $sql = ' SELECT tt.res, COUNT(res) AS nb, ROUND((COUNT(res)/ ' . $this->total_pourcent . '*100),1) AS pourcent @@ -286,7 +286,7 @@ class module_report_nav extends module_report } $report_filter = $filter->getReportFilter(); - $params = array_merge(array(), $report_filter['params']); + $params = array_merge([], $report_filter['params']); $sql = " SELECT tt.combo, COUNT( tt.combo ) AS nb, ROUND((COUNT(tt.combo)/" . $this->total_pourcent . "*100), 1) AS pourcent @@ -338,8 +338,8 @@ class module_report_nav extends module_report $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters(); $this->title = _('report:: modules'); - $x = array(); - $tab_appli = array(); + $x = []; + $tab_appli = []; $this->total_pourcent = $this->setTotalPourcent(); @@ -348,7 +348,7 @@ class module_report_nav extends module_report } $report_filter = $filter->getReportFilter(); - $params = array_merge(array(), $report_filter['params']); + $params = array_merge([], $report_filter['params']); $sql = ' SELECT tt.appli @@ -391,11 +391,11 @@ class module_report_nav extends module_report foreach ($tab_appli as $appli => $nb) { $pourcent = round(($nb / $total) * 100, 1); foreach ($this->champ as $key => $value) { - $this->result[] = array( + $this->result[] = [ 'appli' => $appli, 'nb' => $nb, 'pourcent' => $pourcent . '%' - ); + ]; } $this->report['value'][] = $nb; $this->report['legend'][] = $appli; @@ -412,7 +412,7 @@ class module_report_nav extends module_report { $this->initialize(); empty($on) ? $on = false : ""; - $filter_id_apbox = $filter_id_datbox = array(); + $filter_id_apbox = $filter_id_datbox = []; $conn = $this->app['phraseanet.appbox']->get_connection(); $this->title = sprintf(_('report:: Information sur les utilisateurs correspondant a %s'), $val); @@ -452,7 +452,7 @@ class module_report_nav extends module_report WHERE (usr_id = :value)'; } - $params2 = array(':value' => $val); + $params2 = [':value' => $val]; $stmt = $conn->prepare($sql); $stmt->execute($params2); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -503,21 +503,21 @@ class module_report_nav extends module_report } $this->setDisplay($tab); - $this->champ = array( + $this->champ = [ 'photo', 'record_id', 'date', 'type', 'titre', 'taille' - ); + ]; $document = $record->get_subdef('document'); $this->title = sprintf( _('report:: Information sur l\'enregistrement numero %d'), (int) $rid); $x = $record->get_thumbnail(); - $this->result[] = array( + $this->result[] = [ 'photo' => "" @@ -526,7 +526,7 @@ class module_report_nav extends module_report , 'type' => $document->get_mime() , 'titre' => $record->get_title() , 'taille' => $document->get_size() - ); + ]; $this->setDisplayNav(); $this->setReport(); @@ -542,7 +542,7 @@ class module_report_nav extends module_report $sqlBuilder = new module_report_sql($this->app, $this); $filter = $sqlBuilder->getFilters(); $report_filter = $filter->getReportFilter(); - $params = array_merge($report_filter['params'], array(':browser' => $navigator)); + $params = array_merge($report_filter['params'], [':browser' => $navigator]); $sql = " SELECT DISTINCT(tt.version), COUNT(tt.version) as nb diff --git a/lib/classes/module/report/push.php b/lib/classes/module/report/push.php index a6fb89fa59..e49284e3a8 100644 --- a/lib/classes/module/report/push.php +++ b/lib/classes/module/report/push.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_push extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -29,7 +29,7 @@ class module_report_push extends module_report 'final' => 'd.final', 'comment' => 'd.comment', 'size' => 's.size' - ); + ]; /** * constructor @@ -72,7 +72,7 @@ class module_report_push extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $value = $row['val']; @@ -90,7 +90,7 @@ class module_report_push extends module_report $caption = p4string::format_octets($value); } - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; diff --git a/lib/classes/module/report/question.php b/lib/classes/module/report/question.php index 14343c4fab..3d10d6875e 100644 --- a/lib/classes/module/report/question.php +++ b/lib/classes/module/report/question.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_question extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'usrid' => 'log.usrid', 'ddate' => 'log_search.date', @@ -26,7 +26,7 @@ class module_report_question extends module_report 'sit_session' => 'log.sit_session', 'appli' => 'log.appli', 'ip' => 'log.ip' - ); + ]; /** * constructor @@ -58,7 +58,7 @@ class module_report_question extends module_report public function colFilter($field) { - $ret = array(); + $ret = []; $sqlBuilder = $this->sqlBuilder('question'); $var = $sqlBuilder->sqlDistinctValByField($field); $sql = $var['sql']; @@ -76,7 +76,7 @@ class module_report_question extends module_report $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value)); else $caption = $row['val']; - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; diff --git a/lib/classes/module/report/sent.php b/lib/classes/module/report/sent.php index 519286fb54..b16a006267 100644 --- a/lib/classes/module/report/sent.php +++ b/lib/classes/module/report/sent.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_sent extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -29,7 +29,7 @@ class module_report_sent extends module_report 'final' => 'd.final', 'comment' => 'd.comment', 'size' => 's.size' - ); + ]; /** * constructor @@ -72,7 +72,7 @@ class module_report_sent extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $value = $row['val']; @@ -90,7 +90,7 @@ class module_report_sent extends module_report $caption = p4string::format_octets($value); } - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; diff --git a/lib/classes/module/report/sql.php b/lib/classes/module/report/sql.php index f88711aa7c..c1dfa0873a 100644 --- a/lib/classes/module/report/sql.php +++ b/lib/classes/module/report/sql.php @@ -43,7 +43,7 @@ class module_report_sql $this->connbas = connection::getPDOConnection($app, $report->getSbasId()); $this->filter = new module_report_sqlfilter($app, $report); $this->sql = ''; - $this->params = array(); + $this->params = []; $this->total_row = 0; $this->enable_limit = $report->getEnableLimit(); } diff --git a/lib/classes/module/report/sqlaction.php b/lib/classes/module/report/sqlaction.php index b29a0273d1..b39abea283 100644 --- a/lib/classes/module/report/sqlaction.php +++ b/lib/classes/module/report/sqlaction.php @@ -22,7 +22,7 @@ class module_report_sqlaction extends module_report_sql implements module_report public function setAction($action) { - $a = array('edit', 'add', 'push', 'validate', 'mail'); + $a = ['edit', 'add', 'push', 'validate', 'mail']; if (in_array($action, $a)) { $this->action = $action; @@ -38,10 +38,10 @@ class module_report_sqlaction extends module_report_sql implements module_report public function buildSql() { - $customFieldMap = array(); + $customFieldMap = []; - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(':action' => $this->action), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([':action' => $this->action], $filter['params']); if ($this->groupby == false) { $this->sql = " @@ -55,7 +55,7 @@ class module_report_sqlaction extends module_report_sql implements module_report WHERE (" . $filter['sql'] . ") AND (d.action = :action) ) AS tt"; - $customFieldMap = array( + $customFieldMap = [ 'log.usrid' => 'tt.usrid', 'log.user' => 'tt.user', 'd.final' => 'getter', @@ -64,7 +64,7 @@ class module_report_sqlaction extends module_report_sql implements module_report 'record.mime' => 'tt.mime', 'file' => 'tt.file', 'd.comment' => 'tt.comment' - ); + ]; $stmt = $this->getConnBas()->prepare($this->sql); $stmt->execute($this->params); @@ -100,8 +100,8 @@ class module_report_sqlaction extends module_report_sql implements module_report public function sqlDistinctValByField($field) { - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(':action' => $this->action), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([':action' => $this->action], $filter['params']); $this->sql = " SELECT DISTINCT(val) @@ -116,6 +116,6 @@ class module_report_sqlaction extends module_report_sql implements module_report AND (d.action = :action) ) AS tt " . ($this->filter->getOrderFilter() ? $this->filter->getOrderFilter() : ''); - return array('sql' => $this->sql, 'params' => $this->params); + return ['sql' => $this->sql, 'params' => $this->params]; } } diff --git a/lib/classes/module/report/sqlconnexion.php b/lib/classes/module/report/sqlconnexion.php index eb30201584..585a91736d 100644 --- a/lib/classes/module/report/sqlconnexion.php +++ b/lib/classes/module/report/sqlconnexion.php @@ -21,8 +21,8 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep public function buildSql() { - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([], $filter['params']); if ($this->groupby == false) { $this->sql = " @@ -76,8 +76,8 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep public function sqlDistinctValByField($field) { - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([], $filter['params']); $this->sql = ' SELECT DISTINCT(val) @@ -88,6 +88,6 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep WHERE (' . $filter['sql'] . ') ) AS tt ORDER BY val ASC'; - return array('sql' => $this->sql, 'params' => $this->params); + return ['sql' => $this->sql, 'params' => $this->params]; } } diff --git a/lib/classes/module/report/sqldownload.php b/lib/classes/module/report/sqldownload.php index 4edc45e30c..51acccb793 100644 --- a/lib/classes/module/report/sqldownload.php +++ b/lib/classes/module/report/sqldownload.php @@ -25,10 +25,10 @@ class module_report_sqldownload extends module_report_sql implements module_repo public function buildSql() { - $customFieldMap = array(); + $customFieldMap = []; - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([], $filter['params']); if ($this->groupby == false) { $this->sql = " @@ -57,14 +57,14 @@ class module_report_sqldownload extends module_report_sql implements module_repo INNER JOIN record ON (log_docs.record_id = record.record_id) INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)'; - $customFieldMap = array( + $customFieldMap = [ $field => $name, 'log_docs.comment' => 'tt.comment', 'subdef.size' => 'tt.size', 'subdef.file' => 'tt.file', 'subdef.mime' => 'tt.mime', 'log_docs.final' => 'tt.final', - ); + ]; } elseif ($this->on == 'DOC') { $this->sql = ' @@ -115,8 +115,8 @@ class module_report_sqldownload extends module_report_sql implements module_repo public function sqlDistinctValByField($field) { - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([], $filter['params']); $this->sql = ' SELECT DISTINCT(tt.val) @@ -135,6 +135,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo $this->sql .= $this->filter->getOrderFilter() ? : ''; $this->sql .= $this->filter->getLimitFilter() ? : ''; - return array('sql' => $this->sql, 'params' => $this->params); + return ['sql' => $this->sql, 'params' => $this->params]; } } diff --git a/lib/classes/module/report/sqlfilter.php b/lib/classes/module/report/sqlfilter.php index 0509ddea79..fa62093b58 100644 --- a/lib/classes/module/report/sqlfilter.php +++ b/lib/classes/module/report/sqlfilter.php @@ -15,7 +15,7 @@ class module_report_sqlfilter { public $conn; private $filter; - private $cor_query = array(); + private $cor_query = []; private $app; private $report; @@ -34,16 +34,16 @@ class module_report_sqlfilter public static function constructDateFilter($dmin, $dmax) { - return array( + return [ 'sql' => ($dmin && $dmax ? ' log_date.date > :date_min AND log_date.date < :date_max ' : false) - , 'params' => ($dmin && $dmax ? array(':date_min' => $dmin, ':date_max' => $dmax) : array()) - ); + , 'params' => ($dmin && $dmax ? [':date_min' => $dmin, ':date_max' => $dmax] : []) + ]; } public static function constructCollectionFilter(Application $app, $list_coll_id) { - $ret = array('sql' => '', 'params' => array()); - $coll_filter = array(); + $ret = ['sql' => '', 'params' => []]; + $coll_filter = []; foreach (array_filter(explode(',', $list_coll_id)) as $val) { $val = \phrasea::collFromBas($app, $val); if ($val) { @@ -64,7 +64,7 @@ class module_report_sqlfilter { $finalfilter = ''; - $params = array(':log_site' => $this->app['configuration']['main']['key']); + $params = [':log_site' => $this->app['configuration']['main']['key']]; if ($this->filter['date']) { $finalfilter .= $this->filter['date']['sql'] . ' AND '; @@ -80,22 +80,22 @@ class module_report_sqlfilter } $finalfilter .= ' log.site = :log_site'; - return array('sql' => $finalfilter, 'params' => $params); + return ['sql' => $finalfilter, 'params' => $params]; } public function getGvSitFilter() { - $params = array(); + $params = []; $sql = 'log.site = :log_site_gv_filter'; $params[':log_site_gv_filter'] = $this->app['configuration']['main']['key']; - return array('sql' => $sql, 'params' => $params); + return ['sql' => $sql, 'params' => $params]; } public function getUserIdFilter($id) { - return array('sql' => "log.usrid = :usr_id_filter", 'params' => array(':usr_id_filter' => $id)); + return ['sql' => "log.usrid = :usr_id_filter", 'params' => [':usr_id_filter' => $id]]; } public function getDateFilter() @@ -136,13 +136,13 @@ class module_report_sqlfilter { $this->filter['date'] = false; if ($report->getDmin() && $report->getDmax()) { - $this->filter['date'] = array( + $this->filter['date'] = [ 'sql' => ' (log.date > :date_min_f AND log.date < :date_max_f) ' - , 'params' => array( + , 'params' => [ ':date_min_f' => $report->getDmin() , ':date_max_f' => $report->getDmax() - ) - ); + ] + ]; } return; @@ -154,15 +154,15 @@ class module_report_sqlfilter $f = $report->getTabFilter(); if (sizeof($f) > 0) { - $filter = array(); - $params = array(); + $filter = []; + $params = []; $n = 0; foreach ($f as $field => $value) { if (array_key_exists($value['f'], $this->cor_query)) $value['f'] = $this->cor_query[$value['f']]; if ($value['o'] == 'LIKE') { - $filter[] = $value['f'] . ' ' . $value['o'] . ' \'%' . str_replace(array("'", '%'), array("\'", '\%'), ' :user_filter' . $n) . '%\''; + $filter[] = $value['f'] . ' ' . $value['o'] . ' \'%' . str_replace(["'", '%'], ["\'", '\%'], ' :user_filter' . $n) . '%\''; $params[':user_filter' . $n] = $value['v']; } elseif ($value['o'] == 'OR') { $filter[] = $value['f'] . ' ' . $value['o'] . ' :user_filter' . $n; @@ -174,7 +174,7 @@ class module_report_sqlfilter $n ++; } - $filter_user = array('sql' => implode(' AND ', $filter), 'params' => $params); + $filter_user = ['sql' => implode(' AND ', $filter), 'params' => $params]; $this->filter['user'] = $filter_user; } @@ -185,7 +185,7 @@ class module_report_sqlfilter private function collectionFilter(module_report $report) { $this->filter['collection'] = false; - $coll_filter = array(); + $coll_filter = []; if ($report->getUserId() == '') { return; @@ -201,7 +201,7 @@ class module_report_sqlfilter } } - $this->filter['collection'] = array('sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => array()); + $this->filter['collection'] = ['sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => []]; } return; @@ -210,7 +210,7 @@ class module_report_sqlfilter private function recordFilter(module_report $report) { $this->filter['record'] = false; - $dl_coll_filter = $params = array(); + $dl_coll_filter = $params = []; $n = 0; if (($report->getUserId() != '')) { $tab = explode(",", $report->getListCollId()); @@ -219,7 +219,7 @@ class module_report_sqlfilter $params[":record_fil" . $n] = phrasea::collFromBas($this->app, $val); $n ++; } - $this->filter['record'] = array('sql' => implode(' OR ', $dl_coll_filter), 'params' => $params); + $this->filter['record'] = ['sql' => implode(' OR ', $dl_coll_filter), 'params' => $params]; } return; diff --git a/lib/classes/module/report/sqlquestion.php b/lib/classes/module/report/sqlquestion.php index d27d9298d8..dcf34510af 100644 --- a/lib/classes/module/report/sqlquestion.php +++ b/lib/classes/module/report/sqlquestion.php @@ -21,8 +21,8 @@ class module_report_sqlquestion extends module_report_sql implements module_repo public function buildSql() { - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([], $filter['params']); if ($this->groupby == false) { $this->sql =" @@ -65,8 +65,8 @@ class module_report_sqlquestion extends module_report_sql implements module_repo public function sqlDistinctValByField($field) { - $filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false); - $this->params = array_merge(array(), $filter['params']); + $filter = $this->filter->getReportFilter() ? : ['params' => [], 'sql' => false]; + $this->params = array_merge([], $filter['params']); $this->sql = " SELECT DISTINCT(tt.val) @@ -79,6 +79,6 @@ class module_report_sqlquestion extends module_report_sql implements module_repo ) as tt ORDER BY tt.val ASC"; - return array('sql' => $this->sql, 'params' => $this->params); + return ['sql' => $this->sql, 'params' => $this->params]; } } diff --git a/lib/classes/module/report/validate.php b/lib/classes/module/report/validate.php index c42de8ef12..19eca4d99a 100644 --- a/lib/classes/module/report/validate.php +++ b/lib/classes/module/report/validate.php @@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application; class module_report_validate extends module_report { - protected $cor_query = array( + protected $cor_query = [ 'user' => 'log.user', 'site' => 'log.site', 'societe' => 'log.societe', @@ -29,7 +29,7 @@ class module_report_validate extends module_report 'final' => 'd.final', 'comment' => 'd.comment', 'size' => 's.size' - ); + ]; /** * constructor @@ -72,7 +72,7 @@ class module_report_validate extends module_report $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $value = $row['val']; @@ -90,7 +90,7 @@ class module_report_validate extends module_report $caption = p4string::format_octets($value); } - $ret[] = array('val' => $caption, 'value' => $value); + $ret[] = ['val' => $caption, 'value' => $value]; } return $ret; diff --git a/lib/classes/p4string.php b/lib/classes/p4string.php index 7016f88ecd..b8aa6817ff 100644 --- a/lib/classes/p4string.php +++ b/lib/classes/p4string.php @@ -51,7 +51,7 @@ class p4string $lastCharacter = substr($path, -1, 1); - if ( ! in_array($lastCharacter, array('\\', '/'))) { + if ( ! in_array($lastCharacter, ['\\', '/'])) { $path .= DIRECTORY_SEPARATOR; } @@ -90,7 +90,7 @@ class p4string */ public static function JSstring($s) { - return(str_replace(array("\\", "\"", "\r", "\n"), array("\\\\", "\\\"", "\\r", "\\n"), $s)); + return(str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s)); } /** @@ -104,42 +104,42 @@ class p4string { switch (mb_strtolower($context . '_' . $quoted)) { case 'js_': // old method - $s = str_replace(array("\\", "\"", "'", "\r", "\n"), array("\\\\", "\\\"", "\\'", "\\r", "\\n"), $s); + $s = str_replace(["\\", "\"", "'", "\r", "\n"], ["\\\\", "\\\"", "\\'", "\\r", "\\n"], $s); break; case 'js_"': - $s = str_replace(array("\\", "\"", "\r", "\n"), array("\\\\", "\\\"", "\\r", "\\n"), $s); + $s = str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s); break; case 'js_\'': - $s = str_replace(array("\\", "'", "\r", "\n"), array("\\\\", "\\'", "\\r", "\\n"), $s); + $s = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $s); break; case 'dquot_"': - $s = str_replace(array("\\", "\"", "\r", "\n"), array("\\\\", "\\\"", "\\r", "\\n"), $s); + $s = str_replace(["\\", "\"", "\r", "\n"], ["\\\\", "\\\"", "\\r", "\\n"], $s); break; case 'squot_"': - $s = str_replace(array("\\", "'", "\r", "\n"), array("\\\\", "\\'", "\\r", "\\n"), $s); + $s = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $s); break; case 'html_': // old method case 'html_\'': case 'html_"': - $s = str_replace(array("&", "<", ">", "\n"), array("&", "<", ">", "
          \n"), $s); + $s = str_replace(["&", "<", ">", "\n"], ["&", "<", ">", "
          \n"], $s); break; case 'htmlprop_': - $s = str_replace(array("\"", "'", "<", ">"), array(""", "'", "<", ">"), $s); + $s = str_replace(["\"", "'", "<", ">"], [""", "'", "<", ">"], $s); break; case 'htmlprop_\'': - $s = str_replace(array("'", "<", ">"), array("'", "<", ">"), $s); + $s = str_replace(["'", "<", ">"], ["'", "<", ">"], $s); break; case 'htmlprop_"': - $s = str_replace(array("\"", "<", ">"), array(""", "<", ">"), $s); + $s = str_replace(["\"", "<", ">"], [""", "<", ">"], $s); break; case 'form_': case 'form_\'': // case 'form_"': - $s = str_replace(array("&", "\"", "'", "<", ">"), array("&", """, "'", "<", ">"), $s); + $s = str_replace(["&", "\"", "'", "<", ">"], ["&", """, "'", "<", ">"], $s); break; case 'none_"': diff --git a/lib/classes/patch/320alpha1a.php b/lib/classes/patch/320alpha1a.php index 95e0c26ef5..b50520f006 100644 --- a/lib/classes/patch/320alpha1a.php +++ b/lib/classes/patch/320alpha1a.php @@ -29,7 +29,7 @@ class patch_320alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * diff --git a/lib/classes/patch/320alpha1b.php b/lib/classes/patch/320alpha1b.php index cb64eb3bc7..051e23f804 100644 --- a/lib/classes/patch/320alpha1b.php +++ b/lib/classes/patch/320alpha1b.php @@ -28,7 +28,7 @@ class patch_320alpha1b implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/320alpha2a.php b/lib/classes/patch/320alpha2a.php index 5f20daa8db..a67a054af4 100644 --- a/lib/classes/patch/320alpha2a.php +++ b/lib/classes/patch/320alpha2a.php @@ -28,7 +28,7 @@ class patch_320alpha2a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -66,7 +66,7 @@ class patch_320alpha2a implements patchInterface $stmt = $appbox->get_connection()->prepare($sql); foreach ($rs as $row) { $nonce = random::generatePassword(16); - $params = array(':usr_id' => $row['usr_id'], ':nonce' => $nonce); + $params = [':usr_id' => $row['usr_id'], ':nonce' => $nonce]; $stmt->execute($params); } $stmt->closeCursor(); @@ -83,10 +83,10 @@ class patch_320alpha2a implements patchInterface if (strpos($row['class'], 'task_period_') !== false) continue; - $params = array( + $params = [ ':task_id' => $row['task_id'] , ':class' => str_replace('task_', 'task_period_', $row['class']) - ); + ]; $stmt->execute($params); } diff --git a/lib/classes/patch/320alpha3a.php b/lib/classes/patch/320alpha3a.php index 4c016767bc..9fa14b3821 100644 --- a/lib/classes/patch/320alpha3a.php +++ b/lib/classes/patch/320alpha3a.php @@ -28,7 +28,7 @@ class patch_320alpha3a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/320alpha4a.php b/lib/classes/patch/320alpha4a.php index f700f39c8b..89d4118a50 100644 --- a/lib/classes/patch/320alpha4a.php +++ b/lib/classes/patch/320alpha4a.php @@ -28,7 +28,7 @@ class patch_320alpha4a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * @@ -70,7 +70,7 @@ class patch_320alpha4a implements patchInterface $stmt->execute(); $stmt->closeCursor(); - $phrasea_maps = array( + $phrasea_maps = [ 'pdftext' => 'Phraseanet:pdftext' , 'tf-archivedate' => 'Phraseanet:tf-archivedate' , 'tf-atime' => 'Phraseanet:tf-atime' @@ -89,7 +89,7 @@ class patch_320alpha4a implements patchInterface , 'tf-recordid' => 'Phraseanet:tf-recordid' , 'tf-size' => 'Phraseanet:tf-size' , 'tf-width' => 'Phraseanet:tf-width' - ); + ]; $sxe = $databox->get_sxml_structure(); $dom_struct = $databox->get_dom_structure(); diff --git a/lib/classes/patch/320alpha4b.php b/lib/classes/patch/320alpha4b.php index 2526da5577..1018ea50cc 100644 --- a/lib/classes/patch/320alpha4b.php +++ b/lib/classes/patch/320alpha4b.php @@ -34,7 +34,7 @@ class patch_320alpha4b implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -61,7 +61,7 @@ class patch_320alpha4b implements patchInterface public function apply(base $appbox, Application $app) { - $feeds = array(); + $feeds = []; try { $sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"'; @@ -118,7 +118,7 @@ class patch_320alpha4b implements patchInterface $sql = 'SELECT sselcont_id, ssel_id, base_id, record_id FROM sselcont WHERE ssel_id = :ssel_id ORDER BY ord ASC'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $row['ssel_id'])); + $stmt->execute([':ssel_id' => $row['ssel_id']]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -141,7 +141,7 @@ class patch_320alpha4b implements patchInterface $sql = 'UPDATE ssel SET deleted = "1", migrated="1" WHERE ssel_id = :ssel_id'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $row['ssel_id'])); + $stmt->execute([':ssel_id' => $row['ssel_id']]); $stmt->closeCursor(); $app['EM']->persist($feed); $n++; @@ -169,7 +169,7 @@ class patch_320alpha4b implements patchInterface return; } - protected static $feeds = array(); + protected static $feeds = []; protected function get_feed(appbox $appbox, User_Adapter $user, $pub_restrict, $homelink, Application $app) { diff --git a/lib/classes/patch/320alpha5a.php b/lib/classes/patch/320alpha5a.php index f507659c73..38d516e2a3 100644 --- a/lib/classes/patch/320alpha5a.php +++ b/lib/classes/patch/320alpha5a.php @@ -28,7 +28,7 @@ class patch_320alpha5a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -67,10 +67,10 @@ class patch_320alpha5a implements patchInterface $stmt = $appbox->get_connection()->prepare($sql); foreach ($rs as $row) { - $params = array( + $params = [ ':base_id' => $row['base_id'], ':usr_id' => $row['usr_id'] - ); + ]; $stmt->execute($params); } diff --git a/lib/classes/patch/320alpha6a.php b/lib/classes/patch/320alpha6a.php index 3e4e45fd86..878b40f6de 100644 --- a/lib/classes/patch/320alpha6a.php +++ b/lib/classes/patch/320alpha6a.php @@ -28,7 +28,7 @@ class patch_320alpha6a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * diff --git a/lib/classes/patch/320alpha8a.php b/lib/classes/patch/320alpha8a.php index 7ec5f3423a..0b6a404c64 100644 --- a/lib/classes/patch/320alpha8a.php +++ b/lib/classes/patch/320alpha8a.php @@ -28,7 +28,7 @@ class patch_320alpha8a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/360alpha1a.php b/lib/classes/patch/360alpha1a.php index f28e2eddad..c7fb59eca0 100644 --- a/lib/classes/patch/360alpha1a.php +++ b/lib/classes/patch/360alpha1a.php @@ -28,7 +28,7 @@ class patch_360alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -55,7 +55,7 @@ class patch_360alpha1a implements patchInterface public function apply(base $appbox, Application $app) { - $tables = array('StoryWZ', 'ValidationDatas', 'ValidationParticipants', 'ValidationSessions', 'BasketElements', 'Baskets'); + $tables = ['StoryWZ', 'ValidationDatas', 'ValidationParticipants', 'ValidationSessions', 'BasketElements', 'Baskets']; foreach ($tables as $table) { $sql = 'DELETE FROM ' . $table; @@ -64,7 +64,7 @@ class patch_360alpha1a implements patchInterface $stmt->closeCursor(); } - $stories = array(); + $stories = []; $sql = 'SELECT sbas_id, rid as record_id, usr_id FROM ssel @@ -75,7 +75,7 @@ class patch_360alpha1a implements patchInterface $rs_s = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $current = array(); + $current = []; foreach ($rs_s as $row_story) { $serial = $row_story['sbas_id'] . '_' . $row_story['usr_id'] . '_' . $row_story['record_id']; @@ -93,11 +93,11 @@ class patch_360alpha1a implements patchInterface $stmt = $appbox->get_connection()->prepare($sql); foreach ($stories as $row) { - $params = array( + $params = [ ':usr_id' => $row['usr_id'], ':sbas_id' => $row['sbas_id'], ':record_id' => $row['record_id'] - ); + ]; $stmt->execute($params); } @@ -133,7 +133,7 @@ class patch_360alpha1a implements patchInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $sselcont_ids = array(); + $sselcont_ids = []; foreach ($rs as $row) { $sql = 'SELECT c.sselcont_id, c.record_id, b.sbas_id @@ -142,11 +142,11 @@ class patch_360alpha1a implements patchInterface AND c.ssel_id = :ssel_id AND s.ssel_id = c.ssel_id'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':ssel_id' => $row['ssel_id'])); + $stmt->execute([':ssel_id' => $row['ssel_id']]); $rs_be = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $current = array(); + $current = []; foreach ($rs_be as $row_sselcont) { $serial = $row_sselcont['sbas_id'] . '_' . $row_sselcont['record_id']; @@ -163,7 +163,7 @@ class patch_360alpha1a implements patchInterface $stmt = $appbox->get_connection()->prepare($sql); foreach ($sselcont_ids as $sselcont_id) { - $stmt->execute(array(':sselcont_id' => $sselcont_id)); + $stmt->execute([':sselcont_id' => $sselcont_id]); } $stmt->closeCursor(); @@ -231,11 +231,11 @@ class patch_360alpha1a implements patchInterface )'; $stmt = $appbox->get_connection()->prepare($sql); foreach ($rs as $row) { - $params = array( + $params = [ ':participant_id' => $row['participant_id'], ':basket_id' => $row['basket_id'], ':usr_id' => $row['usr_id'], - ); + ]; $stmt->execute($params); } diff --git a/lib/classes/patch/360alpha1b.php b/lib/classes/patch/360alpha1b.php index 7e07492d23..09009c2d8d 100644 --- a/lib/classes/patch/360alpha1b.php +++ b/lib/classes/patch/360alpha1b.php @@ -28,7 +28,7 @@ class patch_360alpha1b implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * diff --git a/lib/classes/patch/360alpha2a.php b/lib/classes/patch/360alpha2a.php index c1ae020ae3..dd8893ff69 100644 --- a/lib/classes/patch/360alpha2a.php +++ b/lib/classes/patch/360alpha2a.php @@ -28,7 +28,7 @@ class patch_360alpha2a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/360alpha2b.php b/lib/classes/patch/360alpha2b.php index 61db6a32b8..20480fec22 100644 --- a/lib/classes/patch/360alpha2b.php +++ b/lib/classes/patch/360alpha2b.php @@ -28,7 +28,7 @@ class patch_360alpha2b implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * @@ -117,7 +117,7 @@ class patch_360alpha2b implements patchInterface VALUES (null, :record_id, :meta_struct_id, :value)'; $stmt = $databox->get_connection()->prepare($sql); - $databox_fields = array(); + $databox_fields = []; foreach ($rs as $row) { $meta_struct_id = $row['meta_struct_id']; @@ -129,11 +129,11 @@ class patch_360alpha2b implements patchInterface $values = \caption_field::get_multi_values($row['value'], $databox_fields[$meta_struct_id]->get_separator()); foreach ($values as $value) { - $params = array( + $params = [ ':record_id' => $row['record_id'], ':meta_struct_id' => $row['meta_struct_id'], ':value' => $value, - ); + ]; $stmt->execute($params); } } @@ -144,7 +144,7 @@ class patch_360alpha2b implements patchInterface $stmt = $databox->get_connection()->prepare($sql); foreach ($rs as $row) { - $params = array(':id' => $row['id']); + $params = [':id' => $row['id']]; $stmt->execute($params); } diff --git a/lib/classes/patch/361alpha1a.php b/lib/classes/patch/361alpha1a.php index baba8b4121..4fa4563196 100644 --- a/lib/classes/patch/361alpha1a.php +++ b/lib/classes/patch/361alpha1a.php @@ -29,7 +29,7 @@ class patch_361alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -77,7 +77,7 @@ class patch_361alpha1a implements patchInterface $sql = 'SELECT record_id FROM record WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $rowCount = $stmt->rowCount(); $stmt->closeCursor(); diff --git a/lib/classes/patch/370alpha1a.php b/lib/classes/patch/370alpha1a.php index 1c13bcb4c1..86c29a004a 100644 --- a/lib/classes/patch/370alpha1a.php +++ b/lib/classes/patch/370alpha1a.php @@ -28,7 +28,7 @@ class patch_370alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * @@ -84,7 +84,7 @@ class patch_370alpha1a implements patchInterface $sql = 'UPDATE pref SET value = :structure WHERE prop = "structure"'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':structure' => $DOMDocument->saveXML())); + $stmt->execute([':structure' => $DOMDocument->saveXML()]); $stmt->closeCursor(); return true; diff --git a/lib/classes/patch/370alpha3a.php b/lib/classes/patch/370alpha3a.php index 849e7352a8..e4c744dfcd 100644 --- a/lib/classes/patch/370alpha3a.php +++ b/lib/classes/patch/370alpha3a.php @@ -29,7 +29,7 @@ class patch_370alpha3a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/370alpha4a.php b/lib/classes/patch/370alpha4a.php index 1f2c165006..755791348b 100644 --- a/lib/classes/patch/370alpha4a.php +++ b/lib/classes/patch/370alpha4a.php @@ -28,7 +28,7 @@ class patch_370alpha4a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * @@ -62,7 +62,7 @@ class patch_370alpha4a implements patchInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $update = array(); + $update = []; $tagDirname = new \Alchemy\Phrasea\Metadata\Tag\TfDirname(); $tagBasename = new \Alchemy\Phrasea\Metadata\Tag\TfBasename(); @@ -70,10 +70,10 @@ class patch_370alpha4a implements patchInterface foreach ($rs as $row) { if (strpos(strtolower($row['src']), 'tf-parentdir') !== false) { - $update[] = array('id' => $row['id'], 'src' => $tagDirname->getTagname()); + $update[] = ['id' => $row['id'], 'src' => $tagDirname->getTagname()]; } if (strpos(strtolower($row['src']), 'tf-filename') !== false) { - $update[] = array('id' => $row['id'], 'src' => $tagBasename->getTagname()); + $update[] = ['id' => $row['id'], 'src' => $tagBasename->getTagname()]; } } @@ -81,7 +81,7 @@ class patch_370alpha4a implements patchInterface $stmt = $databox->get_connection()->prepare($sql); foreach ($update as $row) { - $stmt->execute(array(':src' => $row['src'], ':id' => $row['id'])); + $stmt->execute([':src' => $row['src'], ':id' => $row['id']]); } $stmt->closeCursor(); diff --git a/lib/classes/patch/370alpha5a.php b/lib/classes/patch/370alpha5a.php index c31ca080a2..aa31ffcd10 100644 --- a/lib/classes/patch/370alpha5a.php +++ b/lib/classes/patch/370alpha5a.php @@ -28,7 +28,7 @@ class patch_370alpha5a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * @@ -62,20 +62,20 @@ class patch_370alpha5a implements patchInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $update = array(); + $update = []; foreach ($rs as $row) { $src = str_replace( - array('/rdf:RDF/rdf:Description/PHRASEANET:', '/rdf:RDF/rdf:Description/'), array('Phraseanet:', ''), $row['src'] + ['/rdf:RDF/rdf:Description/PHRASEANET:', '/rdf:RDF/rdf:Description/'], ['Phraseanet:', ''], $row['src'] ); - $update[] = array('id' => $row['id'], 'src' => $src); + $update[] = ['id' => $row['id'], 'src' => $src]; } $sql = 'UPDATE metadatas_structure SET src = :src WHERE id = :id'; $stmt = $databox->get_connection()->prepare($sql); foreach ($update as $row) { - $stmt->execute(array(':src' => $row['src'], ':id' => $row['id'])); + $stmt->execute([':src' => $row['src'], ':id' => $row['id']]); } $stmt->closeCursor(); diff --git a/lib/classes/patch/370alpha6a.php b/lib/classes/patch/370alpha6a.php index 165349f8ee..0d80e5d2d3 100644 --- a/lib/classes/patch/370alpha6a.php +++ b/lib/classes/patch/370alpha6a.php @@ -28,7 +28,7 @@ class patch_370alpha6a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * @@ -80,7 +80,7 @@ class patch_370alpha6a implements patchInterface $this->addScreenDeviceOption($subdefgroups, $subdef, $groupname); - if (in_array($name, array('preview', 'thumbnail'))) { + if (in_array($name, ['preview', 'thumbnail'])) { if ($name == 'thumbnail' || $subdef->getSubdefType()->getType() != \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO) { $this->addMobileSubdefImage($subdefgroups, $subdef, $groupname); @@ -104,7 +104,7 @@ class patch_370alpha6a implements patchInterface { $optionsSubdef = $subdef->getOptions(); - $options = array(); + $options = []; foreach ($optionsSubdef as $optname => $option) { $options[$optname] = $option->getValue(); @@ -113,19 +113,19 @@ class patch_370alpha6a implements patchInterface $options['path'] = $subdef->get_path(); $options['mediatype'] = $subdef->getSubdefType()->getType(); $options['meta'] = $subdef->meta_writeable() ? 'yes' : 'no'; - $options['devices'] = array(databox_subdef::DEVICE_SCREEN); + $options['devices'] = [databox_subdef::DEVICE_SCREEN]; - $root->set_subdef($groupname, $subdef->get_name(), $subdef->get_class(), $subdef->is_downloadable(), $options, array()); + $root->set_subdef($groupname, $subdef->get_name(), $subdef->get_class(), $subdef->is_downloadable(), $options, []); } protected function addMobileSubdefVideo($root, $baseSubdef, $groupname) { - $newSubdefOptionsWebM = $newSubdefOptionsOgg = $newSubdefOptionsX264 = array( + $newSubdefOptionsWebM = $newSubdefOptionsOgg = $newSubdefOptionsX264 = [ 'path' => $baseSubdef->get_path(), 'mediatype' => \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO - ); + ]; - $options = array( + $options = [ 'path' => $baseSubdef->get_path(), 'mediatype' => \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO, 'bitrate' => '300', @@ -133,8 +133,8 @@ class patch_370alpha6a implements patchInterface 'GOPsize' => '25', 'size' => '480', 'fps' => '15', - 'devices' => array(databox_subdef::DEVICE_HANDHELD), - ); + 'devices' => [databox_subdef::DEVICE_HANDHELD], + ]; foreach ($options as $name => $value) { $newSubdefOptionsWebM[$name] = $value; @@ -151,14 +151,14 @@ class patch_370alpha6a implements patchInterface $newSubdefOptionsX264['acodec'] = 'libvo_aacenc'; $newSubdefOptionsX264['vcodec'] = 'libx264'; - $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM, array()); - $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg, array()); - $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_X264', $baseSubdef->get_class(), false, $newSubdefOptionsX264, array()); + $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM, []); + $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg, []); + $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_X264', $baseSubdef->get_class(), false, $newSubdefOptionsX264, []); } protected function addMobileSubdefImage($root, $baseSubdef, $groupname) { - $optionMobile = array(); + $optionMobile = []; $optionMobile['size'] = $baseSubdef->get_name() == 'thumbnail' ? '150' : '480'; $optionMobile['resolution'] = '72'; @@ -168,18 +168,18 @@ class patch_370alpha6a implements patchInterface $optionMobile['mediatype'] = \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_IMAGE; $optionMobile['meta'] = 'no'; - $optionMobile['devices'] = array(databox_subdef::DEVICE_HANDHELD); + $optionMobile['devices'] = [databox_subdef::DEVICE_HANDHELD]; - $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile', $baseSubdef->get_class(), false, $optionMobile, array()); + $root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile', $baseSubdef->get_class(), false, $optionMobile, []); } protected function addHtml5Video($root, $baseSubdef, $groupname) { - $newSubdefOptionsWebM = $newSubdefOptionsOgg = array( + $newSubdefOptionsWebM = $newSubdefOptionsOgg = [ 'path' => $baseSubdef->get_path(), 'mediatype' => \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO, - 'devices' => array(\databox_subdef::DEVICE_SCREEN) - ); + 'devices' => [\databox_subdef::DEVICE_SCREEN] + ]; foreach ($baseSubdef->getOptions() as $optionname => $option) { $newSubdefOptionsWebM[$optionname] = $option->getValue(); @@ -192,7 +192,7 @@ class patch_370alpha6a implements patchInterface $newSubdefOptionsOgg['vcodec'] = 'libtheora'; $newSubdefOptionsOgg['acodec'] = 'libvorbis'; - $root->set_subdef($groupname, $baseSubdef->get_name() . '_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM, array()); - $root->set_subdef($groupname, $baseSubdef->get_name() . '_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg, array()); + $root->set_subdef($groupname, $baseSubdef->get_name() . '_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM, []); + $root->set_subdef($groupname, $baseSubdef->get_name() . '_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg, []); } } diff --git a/lib/classes/patch/370alpha7a.php b/lib/classes/patch/370alpha7a.php index 2a6a1a8875..a34f3e247c 100644 --- a/lib/classes/patch/370alpha7a.php +++ b/lib/classes/patch/370alpha7a.php @@ -32,7 +32,7 @@ class patch_370alpha7a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/370alpha8a.php b/lib/classes/patch/370alpha8a.php index d2786e8ad6..e4c714712e 100644 --- a/lib/classes/patch/370alpha8a.php +++ b/lib/classes/patch/370alpha8a.php @@ -29,7 +29,7 @@ class patch_370alpha8a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -65,7 +65,7 @@ class patch_370alpha8a implements patchInterface */ public function apply(base $appbox, Application $app) { - $ttasks = array(); + $ttasks = []; $conn = $appbox->get_connection(); $sql = 'SELECT task_id, active, name, class, settings FROM task2 WHERE class=\'task_period_workflow01\''; if (($stmt = $conn->prepare($sql)) !== FALSE) { @@ -74,11 +74,11 @@ class patch_370alpha8a implements patchInterface $stmt->closeCursor(); } - $tdom = array(); // key = period - $taskstodel = array(); + $tdom = []; // key = period + $taskstodel = []; foreach ($ttasks as $task) { $active = true; - $warning = array(); + $warning = []; /* * migrating task 'workflow01' @@ -95,7 +95,7 @@ class patch_370alpha8a implements patchInterface $ts->appendChild($dom->createElement('period'))->appendChild($dom->createTextNode(60 * $period)); $ts->appendChild($dom->createElement('logsql'))->appendChild($dom->createTextNode('1')); $tasks = $ts->appendChild($dom->createElement('tasks')); - $tdom['_' . $period] = array('dom' => $dom, 'tasks' => $tasks); + $tdom['_' . $period] = ['dom' => $dom, 'tasks' => $tasks]; } else { $dom = &$tdom['_' . $period]['dom']; $tasks = &$tdom['_' . $period]['tasks']; diff --git a/lib/classes/patch/370alpha9a.php b/lib/classes/patch/370alpha9a.php index bfe9d95965..802da59f3e 100644 --- a/lib/classes/patch/370alpha9a.php +++ b/lib/classes/patch/370alpha9a.php @@ -28,7 +28,7 @@ class patch_370alpha9a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/3715alpha1a.php b/lib/classes/patch/3715alpha1a.php index 5dff067890..15590a63d9 100644 --- a/lib/classes/patch/3715alpha1a.php +++ b/lib/classes/patch/3715alpha1a.php @@ -23,7 +23,7 @@ class patch_3715alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/371alpha1a.php b/lib/classes/patch/371alpha1a.php index fff51b8ae3..4065052db1 100644 --- a/lib/classes/patch/371alpha1a.php +++ b/lib/classes/patch/371alpha1a.php @@ -28,7 +28,7 @@ class patch_371alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * diff --git a/lib/classes/patch/373alpha1a.php b/lib/classes/patch/373alpha1a.php index f9f6e0d0a3..26958e1a0f 100644 --- a/lib/classes/patch/373alpha1a.php +++ b/lib/classes/patch/373alpha1a.php @@ -28,7 +28,7 @@ class patch_373alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * @@ -62,7 +62,7 @@ class patch_373alpha1a implements patchInterface $sql = 'SELECT * FROM registry WHERE `key` = :key'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $Regbinaries = array( + $Regbinaries = [ 'GV_cli', 'GV_swf_extract', 'GV_pdf2swf', @@ -72,9 +72,9 @@ class patch_373alpha1a implements patchInterface 'GV_ffprobe', 'GV_mp4box', 'GV_pdftotext', - ); + ]; - $mapping = array( + $mapping = [ 'GV_cli' => 'php_binary', 'GV_swf_extract' => 'swf_extract_binary', 'GV_pdf2swf' => 'pdf2swf_binary', @@ -84,12 +84,12 @@ class patch_373alpha1a implements patchInterface 'GV_ffprobe' => 'ffprobe_binary', 'GV_mp4box' => 'mp4box_binary', 'GV_pdftotext' => 'pdftotext_binary', - ); + ]; - $binaries = array('ghostscript_binary' => null); + $binaries = ['ghostscript_binary' => null]; foreach ($Regbinaries as $name) { - $stmt->execute(array(':key' => $name)); + $stmt->execute([':key' => $name]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $value = is_executable($row['value']) ? $row['value'] : null; @@ -105,14 +105,14 @@ class patch_373alpha1a implements patchInterface $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); foreach ($Regbinaries as $name) { - $stmt->execute(array(':key' => $name)); + $stmt->execute([':key' => $name]); } $stmt->closeCursor(); $sql = 'SELECT value FROM registry WHERE `key` = :key'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':key'=>'GV_sit')); + $stmt->execute([':key'=>'GV_sit']); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -122,7 +122,7 @@ class patch_373alpha1a implements patchInterface $sql = 'DELETE FROM registry WHERE `key` = :key'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':key'=>'GV_sit')); + $stmt->execute([':key'=>'GV_sit']); $stmt->closeCursor(); return true; diff --git a/lib/classes/patch/379alpha1a.php b/lib/classes/patch/379alpha1a.php index f5e04ee247..ae8081c36f 100644 --- a/lib/classes/patch/379alpha1a.php +++ b/lib/classes/patch/379alpha1a.php @@ -23,7 +23,7 @@ class patch_379alpha1a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * diff --git a/lib/classes/patch/380alpha10a.php b/lib/classes/patch/380alpha10a.php index 0a77d138fe..86d24c1104 100644 --- a/lib/classes/patch/380alpha10a.php +++ b/lib/classes/patch/380alpha10a.php @@ -17,7 +17,7 @@ class patch_380alpha10a implements patchInterface private $release = '3.8.0-alpha.10'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -58,10 +58,10 @@ class patch_380alpha10a implements patchInterface $stmt = $appbox->get_connection()->prepare($sql); foreach ($rs as $row) { - $stmt->execute(array( + $stmt->execute([ ':usage' => strip_tags($row['usage']), ':id' => $row['id'], - )); + ]); } $stmt->closeCursor(); diff --git a/lib/classes/patch/380alpha11a.php b/lib/classes/patch/380alpha11a.php index a6390d38a9..fce0e78819 100644 --- a/lib/classes/patch/380alpha11a.php +++ b/lib/classes/patch/380alpha11a.php @@ -19,7 +19,7 @@ class patch_380alpha11a implements patchInterface private $release = '3.8.0-alpha.11'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha13a.php b/lib/classes/patch/380alpha13a.php index 05034de70c..3c71683878 100644 --- a/lib/classes/patch/380alpha13a.php +++ b/lib/classes/patch/380alpha13a.php @@ -17,7 +17,7 @@ class patch_380alpha13a implements patchInterface private $release = '3.8.0-alpha.13'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -59,22 +59,22 @@ class patch_380alpha13a implements patchInterface $config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : ''; if (null !== $xsendfilePath && null !== $xsendfileMountPoint) { - $config['xsendfile']['mapping'] = array(array( + $config['xsendfile']['mapping'] = [[ 'directory' => $xsendfilePath, 'mount-point' => $xsendfileMountPoint, - )); + ]]; } $app['configuration']->setConfig($config); - $toRemove = array('GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile'); + $toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile']; $sql = 'DELETE FROM registry WHERE `key` = :k'; $stmt = $appbox->get_connection()->prepare($sql); foreach ($toRemove as $registryKey) { - $stmt->execute(array( + $stmt->execute([ ':k' => $registryKey - )); + ]); } $stmt->closeCursor(); diff --git a/lib/classes/patch/380alpha14a.php b/lib/classes/patch/380alpha14a.php index c138ec7cd1..b94ce3235f 100644 --- a/lib/classes/patch/380alpha14a.php +++ b/lib/classes/patch/380alpha14a.php @@ -17,7 +17,7 @@ class patch_380alpha14a implements patchInterface private $release = '3.8.0-alpha.14'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha15a.php b/lib/classes/patch/380alpha15a.php index 1854a3bb5a..8a541c8b6f 100644 --- a/lib/classes/patch/380alpha15a.php +++ b/lib/classes/patch/380alpha15a.php @@ -17,7 +17,7 @@ class patch_380alpha15a implements patchInterface private $release = '3.8.0-alpha.15'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha16a.php b/lib/classes/patch/380alpha16a.php index 5ac1ebadcc..33b54816a6 100644 --- a/lib/classes/patch/380alpha16a.php +++ b/lib/classes/patch/380alpha16a.php @@ -17,7 +17,7 @@ class patch_380alpha16a implements patchInterface private $release = '3.8.0-alpha.16'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -51,17 +51,17 @@ class patch_380alpha16a implements patchInterface $xsendfile = $app['configuration']['xsendfile']; if (!isset($xsendfile['mapping'])) { - $xsendfile['mapping'] = array(); + $xsendfile['mapping'] = []; } - $xsendfile['mapping'][] = array( + $xsendfile['mapping'][] = [ 'directory' => $app['root.path'] . '/tmp/lazaret/', 'mount-point' => '/lazaret/', - ); - $xsendfile['mapping'][] = array( + ]; + $xsendfile['mapping'][] = [ 'directory' => $app['root.path'] . '/tmp/download/', 'mount-point' => '/download/', - ); + ]; $app['configuration']['xsendfile'] = $xsendfile; diff --git a/lib/classes/patch/380alpha17a.php b/lib/classes/patch/380alpha17a.php index 250344d209..810373e371 100644 --- a/lib/classes/patch/380alpha17a.php +++ b/lib/classes/patch/380alpha17a.php @@ -17,7 +17,7 @@ class patch_380alpha17a implements patchInterface private $release = '3.8.0-alpha.17'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha18a.php b/lib/classes/patch/380alpha18a.php index 7a666d027b..11725c566e 100644 --- a/lib/classes/patch/380alpha18a.php +++ b/lib/classes/patch/380alpha18a.php @@ -18,7 +18,7 @@ class patch_380alpha18a implements patchInterface private $release = '3.8.0-alpha.18'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha2a.php b/lib/classes/patch/380alpha2a.php index 279422b470..327c2cc31b 100644 --- a/lib/classes/patch/380alpha2a.php +++ b/lib/classes/patch/380alpha2a.php @@ -28,7 +28,7 @@ class patch_380alpha2a implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/380alpha2b.php b/lib/classes/patch/380alpha2b.php index a6a627a2c6..ffdb4def3f 100644 --- a/lib/classes/patch/380alpha2b.php +++ b/lib/classes/patch/380alpha2b.php @@ -28,7 +28,7 @@ class patch_380alpha2b implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/380alpha3a.php b/lib/classes/patch/380alpha3a.php index d31caa8c91..ce033d518e 100644 --- a/lib/classes/patch/380alpha3a.php +++ b/lib/classes/patch/380alpha3a.php @@ -29,7 +29,7 @@ class patch_380alpha3a implements patchInterface * * @var Array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * diff --git a/lib/classes/patch/380alpha3b.php b/lib/classes/patch/380alpha3b.php index cc4fefc55b..94ec26f94c 100644 --- a/lib/classes/patch/380alpha3b.php +++ b/lib/classes/patch/380alpha3b.php @@ -29,7 +29,7 @@ class patch_380alpha3b implements patchInterface * * @var Array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * diff --git a/lib/classes/patch/380alpha4a.php b/lib/classes/patch/380alpha4a.php index 8391adc65f..e256520661 100644 --- a/lib/classes/patch/380alpha4a.php +++ b/lib/classes/patch/380alpha4a.php @@ -18,7 +18,7 @@ class patch_380alpha4a implements patchInterface private $release = '3.8.0-alpha.4'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha6a.php b/lib/classes/patch/380alpha6a.php index 617658d7e1..e1c5f8db0e 100644 --- a/lib/classes/patch/380alpha6a.php +++ b/lib/classes/patch/380alpha6a.php @@ -17,7 +17,7 @@ class patch_380alpha6a implements patchInterface private $release = '3.8.0-alpha.6'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha8a.php b/lib/classes/patch/380alpha8a.php index 4772ba6d1a..8681218cfb 100644 --- a/lib/classes/patch/380alpha8a.php +++ b/lib/classes/patch/380alpha8a.php @@ -17,7 +17,7 @@ class patch_380alpha8a implements patchInterface private $release = '3.8.0-alpha.8'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/380alpha9a.php b/lib/classes/patch/380alpha9a.php index 1282b3f366..4fd9a97d8a 100644 --- a/lib/classes/patch/380alpha9a.php +++ b/lib/classes/patch/380alpha9a.php @@ -17,7 +17,7 @@ class patch_380alpha9a implements patchInterface private $release = '3.8.0-alpha.9'; /** @var array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/381alpha1a.php b/lib/classes/patch/381alpha1a.php index c8919b9fc3..47c01c5915 100644 --- a/lib/classes/patch/381alpha1a.php +++ b/lib/classes/patch/381alpha1a.php @@ -17,7 +17,7 @@ class patch_381alpha1a implements patchInterface private $release = '3.8.1-alpha.1'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -56,13 +56,13 @@ class patch_381alpha1a implements patchInterface $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $sbasData = array(); + $sbasData = []; $sbas_id = null; - $reorder = array(); + $reorder = []; foreach ($rs as $row) { - $sbasData[$row['sbas_id']][] = array('base_id' => $row['base_id']); + $sbasData[$row['sbas_id']][] = ['base_id' => $row['base_id']]; if ($sbas_id !== $row['sbas_id']) { - $orders = array(); + $orders = []; } $sbas_id = $row['sbas_id']; if (in_array($row['ord'], $orders, true)) { @@ -78,7 +78,7 @@ class patch_381alpha1a implements patchInterface foreach ($reorder as $sbas_id) { $i = 1; foreach ($sbasData[$sbas_id] as $data) { - $stmt->execute(array('base_id' => $data['base_id'], 'ord' => $i++)); + $stmt->execute(['base_id' => $data['base_id'], 'ord' => $i++]); } } $stmt->closeCursor(); diff --git a/lib/classes/patch/381alpha1b.php b/lib/classes/patch/381alpha1b.php index 793c93a38f..921f83b257 100644 --- a/lib/classes/patch/381alpha1b.php +++ b/lib/classes/patch/381alpha1b.php @@ -17,7 +17,7 @@ class patch_381alpha1b implements patchInterface private $release = '3.8.1-alpha.1'; /** @var array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/381alpha2a.php b/lib/classes/patch/381alpha2a.php index 73ba680e32..06ae412c32 100644 --- a/lib/classes/patch/381alpha2a.php +++ b/lib/classes/patch/381alpha2a.php @@ -17,7 +17,7 @@ class patch_381alpha2a implements patchInterface private $release = '3.8.1-alpha.2'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/381alpha3a.php b/lib/classes/patch/381alpha3a.php index 4d391c529c..26fcc42673 100644 --- a/lib/classes/patch/381alpha3a.php +++ b/lib/classes/patch/381alpha3a.php @@ -17,7 +17,7 @@ class patch_381alpha3a implements patchInterface private $release = '3.8.1-alpha.3'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -48,7 +48,7 @@ class patch_381alpha3a implements patchInterface */ public function apply(base $appbox, Application $app) { - $propSql = $propArgs = array(); + $propSql = $propArgs = []; $n = 0; foreach (\User_Adapter::$def_values as $prop => $value) { diff --git a/lib/classes/patch/381alpha4a.php b/lib/classes/patch/381alpha4a.php index ddc8c3f273..157c965829 100644 --- a/lib/classes/patch/381alpha4a.php +++ b/lib/classes/patch/381alpha4a.php @@ -17,7 +17,7 @@ class patch_381alpha4a implements patchInterface private $release = '3.8.1-alpha.4'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -69,7 +69,7 @@ class patch_381alpha4a implements patchInterface $value = substr($value, 0, -1); } - $stmt->execute(array(':value' => $value, ':usr_id' => $row['usr_id'], ':prop' => $row['prop'])); + $stmt->execute([':value' => $value, ':usr_id' => $row['usr_id'], ':prop' => $row['prop']]); } $stmt->closeCursor(); diff --git a/lib/classes/patch/390alpha1a.php b/lib/classes/patch/390alpha1a.php index b7f49420c4..013ad6d67f 100644 --- a/lib/classes/patch/390alpha1a.php +++ b/lib/classes/patch/390alpha1a.php @@ -18,7 +18,7 @@ class patch_390alpha1a implements patchInterface private $release = '3.9.0-alpha.1'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/390alpha1b.php b/lib/classes/patch/390alpha1b.php index faca65af83..247578c577 100644 --- a/lib/classes/patch/390alpha1b.php +++ b/lib/classes/patch/390alpha1b.php @@ -20,7 +20,7 @@ class patch_390alpha1b implements patchInterface private $release = '3.9.0-alpha.1'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -76,7 +76,7 @@ class patch_390alpha1b implements patchInterface $sql = 'SELECT count(id) as todo FROM order_elements WHERE deny = NULL AND order_id = :id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':id' => $row['id'])); + $stmt->execute([':id' => $row['id']]); $todo = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -94,7 +94,7 @@ class patch_390alpha1b implements patchInterface FROM order_elements WHERE order_id = :id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':id' => $row['id'])); + $stmt->execute([':id' => $row['id']]); $elements = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/classes/patch/390alpha2a.php b/lib/classes/patch/390alpha2a.php index b236c93e54..297fdbb6ce 100644 --- a/lib/classes/patch/390alpha2a.php +++ b/lib/classes/patch/390alpha2a.php @@ -20,7 +20,7 @@ class patch_390alpha2a implements patchInterface private $release = '3.9.0-alpha.2'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/390alpha3a.php b/lib/classes/patch/390alpha3a.php index a1c8aadef4..e8b152d35d 100644 --- a/lib/classes/patch/390alpha3a.php +++ b/lib/classes/patch/390alpha3a.php @@ -18,7 +18,7 @@ class patch_390alpha3a implements patchInterface private $release = '3.9.0-alpha.3'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/390alpha4a.php b/lib/classes/patch/390alpha4a.php index 0b9d583b4c..cf7b918532 100644 --- a/lib/classes/patch/390alpha4a.php +++ b/lib/classes/patch/390alpha4a.php @@ -18,7 +18,7 @@ class patch_390alpha4a implements patchInterface private $release = '3.9.0-alpha.4'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/390alpha5a.php b/lib/classes/patch/390alpha5a.php index 8ea831e1c6..f46842e37d 100644 --- a/lib/classes/patch/390alpha5a.php +++ b/lib/classes/patch/390alpha5a.php @@ -18,7 +18,7 @@ class patch_390alpha5a implements patchInterface private $release = '3.9.0-alpha.5'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/390alpha6a.php b/lib/classes/patch/390alpha6a.php index 4c2b54669b..91baaf310b 100644 --- a/lib/classes/patch/390alpha6a.php +++ b/lib/classes/patch/390alpha6a.php @@ -20,7 +20,7 @@ class patch_390alpha6a implements patchInterface private $release = '3.9.0-alpha.6'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -114,7 +114,7 @@ class patch_390alpha6a implements patchInterface $em->persist($export); - $stmt->execute(array('export_id' => $row['id'])); + $stmt->execute(['export_id' => $row['id']]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($rs as $element) { diff --git a/lib/classes/patch/390alpha7a.php b/lib/classes/patch/390alpha7a.php index 4af5ad9e3a..5c2fdeb583 100644 --- a/lib/classes/patch/390alpha7a.php +++ b/lib/classes/patch/390alpha7a.php @@ -23,7 +23,7 @@ class patch_390alpha7a implements patchInterface private $release = '3.9.0-alpha.7'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -132,7 +132,7 @@ class patch_390alpha7a implements patchInterface $feed->setUpdatedOn(new \DateTime($row['updated_on'])); $feed->setCollection($row['base_id'] ? collection::get_from_base_id($app, $row['base_id']) : null); - $fpStmt->execute(array(':feed_id' => $row['id'])); + $fpStmt->execute([':feed_id' => $row['id']]); $fpRes = $fpStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($fpRes as $fpRow) { @@ -143,7 +143,7 @@ class patch_390alpha7a implements patchInterface $feedPublisher->setIsOwner((Boolean) $fpRow['owner']); $feedPublisher->setUsrId($fpRow['usr_id']); - $feStmt->execute(array(':feed_id' => $row['id'], ':publisher_id' => $fpRow['id'])); + $feStmt->execute([':feed_id' => $row['id'], ':publisher_id' => $fpRow['id']]); $feRes = $feStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($feRes as $feRow) { @@ -158,7 +158,7 @@ class patch_390alpha7a implements patchInterface $feedEntry->setCreatedOn(new \DateTime($feRow['created_on'])); $feedEntry->setUpdatedOn(new \DateTime($feRow['updated_on'])); - $fiStmt->execute(array(':entry_id' => $feRow['id'])); + $fiStmt->execute([':entry_id' => $feRow['id']]); $fiRes = $fiStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($fiRes as $fiRow) { @@ -176,7 +176,7 @@ class patch_390alpha7a implements patchInterface $em->persist($feedPublisher); } - $ftStmt->execute(array(':feed_id' => $row['id'])); + $ftStmt->execute([':feed_id' => $row['id']]); $ftRes = $ftStmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($ftRes as $ftRow) { diff --git a/lib/classes/patch/390alpha8a.php b/lib/classes/patch/390alpha8a.php index d2fef15b04..7b9f137213 100644 --- a/lib/classes/patch/390alpha8a.php +++ b/lib/classes/patch/390alpha8a.php @@ -18,7 +18,7 @@ class patch_390alpha8a implements patchInterface private $release = '3.9.0-alpha.8'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patchthesaurus/100.php b/lib/classes/patchthesaurus/100.php index 1e4ee8ed92..66e83d4a25 100644 --- a/lib/classes/patchthesaurus/100.php +++ b/lib/classes/patchthesaurus/100.php @@ -25,7 +25,7 @@ class patchthesaurus_100 implements patchthesaurus_interface $te0 = $te->item(0); $th->setAttribute("nextid", $te0->getAttribute("nextid")); $te = $xp->query("te", $te0); - $te1 = array(); + $te1 = []; for ($i = 0; $i < $te->length; $i ++) { $te1[] = $te->item($i); } @@ -61,7 +61,7 @@ class patchthesaurus_100 implements patchthesaurus_interface if ($tenode->getAttribute("nextid") == "") $tenode->setAttribute("nextid", "0"); // $tenode->setAttribute("id", "0.".$tenode->getAttribute("id")); - $todel = array(); + $todel = []; for ($n = $tenode->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "ta") $todel[] = $n; diff --git a/lib/classes/patchthesaurus/202.php b/lib/classes/patchthesaurus/202.php index 2b43a35229..c2d036d56c 100644 --- a/lib/classes/patchthesaurus/202.php +++ b/lib/classes/patchthesaurus/202.php @@ -29,7 +29,7 @@ class patchthesaurus_202 implements patchthesaurus_interface $sql = "UPDATE pref SET thesaurus_moddate = :date1, cterms_moddate = :date2"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':date1' => $th->getAttribute("modification_date"), ':date2' => $ct->getAttribute("modification_date"))); + $stmt->execute([':date1' => $th->getAttribute("modification_date"), ':date2' => $ct->getAttribute("modification_date")]); $stmt->closeCursor(); $ct->setAttribute("version", $version = "2.0.3"); diff --git a/lib/classes/patchthesaurus/203.php b/lib/classes/patchthesaurus/203.php index fc88598a59..16b17e3aa5 100644 --- a/lib/classes/patchthesaurus/203.php +++ b/lib/classes/patchthesaurus/203.php @@ -45,7 +45,7 @@ class patchthesaurus_203 implements patchthesaurus_interface $xp = new DOMXPath($domct); $nodes = $xp->query("//te[not(starts-with(@id, 'R')) and count(te[starts-with(@id, 'R')])=0]"); - $nodestodel = array(); + $nodestodel = []; for ($i = 0; $i < $nodes->length; $i ++ ) $nodestodel[] = $nodes->item($i); $ctdel = 0; @@ -53,7 +53,7 @@ class patchthesaurus_203 implements patchthesaurus_interface $sql2 = "DELETE FROM thit WHERE value LIKE :like"; $stmt = $connbas->prepare($sql2); - $stmt->execute(array(':like' => str_replace(".", "d", $node->getAttribute("id")) . "d%")); + $stmt->execute([':like' => str_replace(".", "d", $node->getAttribute("id")) . "d%"]); $stmt->closeCursor(); $node->parentNode->removeChild($node); @@ -115,7 +115,7 @@ class patchthesaurus_203 implements patchthesaurus_interface $sql = "UPDATE thit SET value = :newid WHERE value = :oldid"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':newid' => $newid, ':oldid' => $id)); + $stmt->execute([':newid' => $newid, ':oldid' => $id]); $stmt->closeCursor(); } } @@ -144,7 +144,7 @@ class patchthesaurus_203 implements patchthesaurus_interface $sql = "UPDATE thit SET value = :newid WHERE value = :oldid"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':newid' => $newid, ':oldid' => $id)); + $stmt->execute([':newid' => $newid, ':oldid' => $id]); $stmt->closeCursor(); } } diff --git a/lib/classes/patchthesaurus/204.php b/lib/classes/patchthesaurus/204.php index 3719cee4c9..a949c79ead 100644 --- a/lib/classes/patchthesaurus/204.php +++ b/lib/classes/patchthesaurus/204.php @@ -45,7 +45,7 @@ class patchthesaurus_204 implements patchthesaurus_interface $xp = new DOMXPath($domct); $nodes = $xp->query("//te[not(starts-with(@id, 'R')) and count(te[starts-with(@id, 'R')])=0]"); - $nodestodel = array(); + $nodestodel = []; for ($i = 0; $i < $nodes->length; $i ++ ) $nodestodel[] = $nodes->item($i); $ctdel = 0; @@ -53,7 +53,7 @@ class patchthesaurus_204 implements patchthesaurus_interface $sql2 = "DELETE FROM thit WHERE value LIKE :like"; $stmt = $connbas->prepare($sql2); - $stmt->execute(array(':like' => str_replace(".", "d", $node->getAttribute("id")) . "d%")); + $stmt->execute([':like' => str_replace(".", "d", $node->getAttribute("id")) . "d%"]); $stmt->closeCursor(); $node->parentNode->removeChild($node); @@ -117,7 +117,7 @@ class patchthesaurus_204 implements patchthesaurus_interface $sql = "UPDATE thit SET value = :newid WHERE value = :oldid"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':newid' => $newid, ':oldid' => $id)); + $stmt->execute([':newid' => $newid, ':oldid' => $id]); $stmt->closeCursor(); } } @@ -146,7 +146,7 @@ class patchthesaurus_204 implements patchthesaurus_interface $sql = "UPDATE thit SET value = :newid WHERE value = :oldid"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':newid' => $newid, ':oldid' => $id)); + $stmt->execute([':newid' => $newid, ':oldid' => $id]); $stmt->closeCursor(); } } diff --git a/lib/classes/phrasea.php b/lib/classes/phrasea.php index 911cbb4663..ed00b54ade 100644 --- a/lib/classes/phrasea.php +++ b/lib/classes/phrasea.php @@ -52,7 +52,7 @@ class phrasea } - self::$_sbas_params = array(); + self::$_sbas_params = []; $sql = 'SELECT sbas_id, host, port, user, pwd, dbname FROM sbas'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); @@ -88,9 +88,9 @@ class phrasea public static function modulesName($array_modules) { - $array = array(); + $array = []; - $modules = array( + $modules = [ 1 => _('admin::monitor: module production'), 2 => _('admin::monitor: module client'), 3 => _('admin::monitor: module admin'), @@ -99,7 +99,7 @@ class phrasea 6 => _('admin::monitor: module comparateur'), 7 => _('admin::monitor: module validation'), 8 => _('admin::monitor: module upload') - ); + ]; foreach ($array_modules as $a) { if (isset($modules[$a])) @@ -144,7 +144,7 @@ class phrasea foreach ($rs as $row) { if (!isset(self::$_coll2bas[$row['sbas_id']])) - self::$_coll2bas[$row['sbas_id']] = array(); + self::$_coll2bas[$row['sbas_id']] = []; self::$_coll2bas[$row['sbas_id']][$row['server_coll_id']] = (int) $row['base_id']; } } @@ -156,12 +156,12 @@ class phrasea { self::$_coll2bas = self::$_bas2coll = self::$_bas_labels = self::$_bas2sbas = null; $appbox->delete_data_from_cache( - array( + [ self::CACHE_BAS_2_COLL , self::CACHE_BAS_2_COLL , self::CACHE_BAS_LABELS , self::CACHE_SBAS_FROM_BAS - ) + ] ); return; @@ -171,12 +171,12 @@ class phrasea { self::$_sbas_names = self::$_sbas_labels = self::$_sbas_params = self::$_bas2sbas = null; $appbox->delete_data_from_cache( - array( + [ self::CACHE_SBAS_NAMES, self::CACHE_SBAS_LABELS, self::CACHE_SBAS_FROM_BAS, self::CACHE_SBAS_PARAMS, - ) + ] ); return; @@ -223,12 +223,12 @@ class phrasea self::$_sbas_labels = $app['phraseanet.appbox']->get_data_from_cache(self::CACHE_SBAS_LABELS); } catch (Exception $e) { foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { - self::$_sbas_labels[$databox->get_sbas_id()] = array( + self::$_sbas_labels[$databox->get_sbas_id()] = [ 'fr' => $databox->get_label('fr'), 'en' => $databox->get_label('en'), 'de' => $databox->get_label('de'), 'nl' => $databox->get_label('nl'), - ); + ]; } $app['phraseanet.appbox']->set_data_to_cache(self::$_sbas_labels, self::CACHE_SBAS_LABELS); } @@ -249,12 +249,12 @@ class phrasea } catch (Exception $e) { foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { - self::$_bas_labels[$collection->get_base_id()] = array( + self::$_bas_labels[$collection->get_base_id()] = [ 'fr' => $collection->get_label('fr'), 'en' => $collection->get_label('en'), 'de' => $collection->get_label('de'), 'nl' => $collection->get_label('nl'), - ); + ]; } } diff --git a/lib/classes/phraseadate.php b/lib/classes/phraseadate.php index eeee52ae97..c8ac09b0df 100644 --- a/lib/classes/phraseadate.php +++ b/lib/classes/phraseadate.php @@ -180,8 +180,8 @@ class phraseadate */ public function isodateToDate($isodelimdate, $format) { - $tc = array(); - $bal = array(); + $tc = []; + $bal = []; $isodelimdate = trim($isodelimdate); while ($isodelimdate != "") { @@ -198,14 +198,14 @@ class phraseadate $isodelimdate = ""; } } else { - $tc[] = array("char" => $c, "bals" => $bal); + $tc[] = ["char" => $c, "bals" => $bal]; $isodelimdate = substr($isodelimdate, 1); } } $strdate = ""; - $paterns = array("YYYY" => 0, "YY" => 2, "MM" => 5, - "DD" => 8, "HH" => 11, "NN" => 14, "SS" => 17); + $paterns = ["YYYY" => 0, "YY" => 2, "MM" => 5, + "DD" => 8, "HH" => 11, "NN" => 14, "SS" => 17]; while ($format != "") { $patfound = false; @@ -245,12 +245,12 @@ class phraseadate { $v_y = $v_m = $v_d = $v_h = $v_n = $v_s = 0; $v = str_replace( - array("-", ":", "/", "."), array(" ", " ", " ", " "), trim($strdate) + ["-", ":", "/", "."], [" ", " ", " ", " "], trim($strdate) ); $n = 0; $format = str_replace( - array("-", ":", "/", "."), array(" ", " ", " ", " "), $format + ["-", ":", "/", "."], [" ", " ", " ", " "], $format ); $isodelimdate = null; switch ($format) { diff --git a/lib/classes/queries.php b/lib/classes/queries.php index d33fba4f75..f8c6165236 100644 --- a/lib/classes/queries.php +++ b/lib/classes/queries.php @@ -189,10 +189,10 @@ class queries $queries = $app['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\UserQuery') - ->findBy(array('usrId' => $usrId), array('created' => 'ASC'), 25, 0); + ->findBy(['usrId' => $usrId], ['created' => 'ASC'], 25, 0); foreach ($queries as $query) { - $history .= '
        2. getQuery()) . '\')">' . $query->getQuery() . '
        3. '; + $history .= '
        4. getQuery()) . '\')">' . $query->getQuery() . '
        5. '; } $history .= '
            '; @@ -220,7 +220,7 @@ class queries $t .= '{ '; $t .= 'label:"' . p4string::MakeString(utf8_decode($subtopic->label), 'js') . '"'; if ($q = $subtopic->query) { - $q = str_replace(array("\\", "'", "\r", "\n"), array("\\\\", "\\'", "\\r", "\\n"), $subtopic->query); + $q = str_replace(["\\", "'", "\r", "\n"], ["\\\\", "\\'", "\\r", "\\n"], $subtopic->query); $t .= ", query:'" . $q . "'"; } else { $t .= ', query:null'; @@ -246,7 +246,7 @@ class queries $l = p4string::MakeString($s, 'html'); $l = '' . $l . ''; if ($subtopic->query) { - $q = str_replace(array("\\", "\"", "'", "\r", "\n"), array("\\\\", """, "\\'", "\\r", "\\n"), $subtopic->query); + $q = str_replace(["\\", "\"", "'", "\r", "\n"], ["\\\\", """, "\\'", "\\r", "\\n"], $subtopic->query); $q = '' . $l . ''; } else { $q = $l; diff --git a/lib/classes/random.php b/lib/classes/random.php index 38355a689e..3ce11aac57 100644 --- a/lib/classes/random.php +++ b/lib/classes/random.php @@ -56,7 +56,7 @@ class random $sql = 'SELECT * FROM tokens WHERE expire_on < :date AND datas IS NOT NULL AND (type="download" OR type="email")'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':date' => $date)); + $stmt->execute([':date' => $date]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { @@ -72,7 +72,7 @@ class random $sql = 'DELETE FROM tokens WHERE expire_on < :date and (type="download" OR type="email")'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':date' => $date)); + $stmt->execute([':date' => $date]); $stmt->closeCursor(); return true; @@ -95,7 +95,7 @@ class random throw new Exception_InvalidArgument (); $password = ""; - if ( ! in_array($possible, array(self::LETTERS_AND_NUMBERS, self::LETTERS, self::NUMBERS))) + if ( ! in_array($possible, [self::LETTERS_AND_NUMBERS, self::LETTERS, self::NUMBERS])) $possible = self::LETTERS_AND_NUMBERS; $i = 0; $possible_length = strlen($possible); @@ -145,7 +145,7 @@ class random $stmt = $conn->prepare($sql); while ($n < 100) { $test = self::generatePassword(16); - $stmt->execute(array(':test' => $test)); + $stmt->execute([':test' => $test]); if ($stmt->rowCount() === 0) { $token = $test; break; @@ -159,13 +159,13 @@ class random VALUES (null, :token, :type, :usr, NOW(), :end_date, :datas)'; $stmt = $conn->prepare($sql); - $params = array( + $params = [ ':token' => $token , ':type' => $type , ':usr' => ($usr ? $usr : '-1') , ':end_date' => ($end_date instanceof DateTime ? $end_date->format(DATE_ISO8601) : null) , ':datas' => ((trim($datas) != '') ? $datas : null) - ); + ]; $stmt->execute($params); $stmt->closeCursor(); } @@ -181,7 +181,7 @@ class random $conn = connection::getPDOConnection($this->app); $sql = 'DELETE FROM tokens WHERE value = :token'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':token' => $token)); + $stmt->execute([':token' => $token]); $stmt->closeCursor(); return true; @@ -201,7 +201,7 @@ class random WHERE value = :token'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':datas' => $datas, ':token' => $token)); + $stmt->execute([':datas' => $datas, ':token' => $token]); $stmt->closeCursor(); return true; @@ -221,7 +221,7 @@ class random WHERE value = :token AND (expire_on > NOW() OR expire_on IS NULL)'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':token' => $token)); + $stmt->execute([':token' => $token]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -252,11 +252,11 @@ class random AND (expire_on > NOW() OR expire_on IS NULL)'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':type' => self::TYPE_VALIDATE, ':usr_id' => (int) $userId, ':basket_id' => (int) $basketId, - )); + ]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 5e4030602e..2d5d374ea4 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -201,7 +201,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface , type, originalname, bitly, sha256, mime FROM record WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->record_id)); + $stmt->execute([':record_id' => $this->record_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -221,7 +221,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $this->sha256 = $row['sha256']; $this->mime = $row['mime']; - $datas = array( + $datas = [ 'mime' => $this->mime , 'sha256' => $this->sha256 , 'bitly_link' => $this->bitly_link @@ -232,7 +232,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface , 'modification_date' => $this->modification_date , 'creation_date' => $this->creation_date , 'base_id' => $this->base_id - ); + ]; $this->set_data_to_cache($datas); @@ -299,7 +299,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $old_type = $this->get_type(); - if (!in_array($type, array('document', 'audio', 'video', 'image', 'flash', 'map'))) { + if (!in_array($type, ['document', 'audio', 'video', 'image', 'flash', 'map'])) { throw new Exception('unrecognized document type'); } @@ -307,7 +307,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET type = :type WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':type' => $type, ':record_id' => $this->get_record_id())); + $stmt->execute([':type' => $type, ':record_id' => $this->get_record_id()]); $stmt->closeCursor(); if ($old_type !== $type) @@ -489,10 +489,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id"; - $params = array( + $params = [ ':coll_id' => $collection->get_coll_id(), ':record_id' => $this->get_record_id() - ); + ]; $stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -574,7 +574,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'SELECT BIN(status) as status FROM record WHERE record_id = :record_id'; $stmt = $this->get_databox()->get_connection()->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -617,7 +617,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } if (!$this->subdefs) { - $this->subdefs = array(); + $this->subdefs = []; } $substitute = ($name !== 'document'); @@ -634,7 +634,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ public function getSubdfefByDeviceAndMime($devices = null, $mimes = null) { - $subdefNames = $subdefs = array(); + $subdefNames = $subdefs = []; $availableSubdefs = $this->get_subdefs(); @@ -695,7 +695,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface public function get_subdefs() { if (!$this->subdefs) { - $this->subdefs = array(); + $this->subdefs = []; } $subdefs = $this->get_available_subdefs(); @@ -724,11 +724,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface WHERE s.record_id = r.record_id AND r.record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $subdefs = array('preview', 'thumbnail'); + $subdefs = ['preview', 'thumbnail']; foreach ($rs as $row) { $subdefs[] = $row['name']; @@ -760,11 +760,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface try { $this->technical_datas = $this->get_data_from_cache(self::CACHE_TECHNICAL_DATAS); } catch (Exception $e) { - $this->technical_datas = array(); + $this->technical_datas = []; $connbas = $this->get_databox()->get_connection(); $sql = 'SELECT name, value FROM technical_datas WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -847,11 +847,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface $meta_id = null; } - $metas = array( + $metas = [ 'meta_struct_id' => $field->get_meta_struct_id() , 'meta_id' => $meta_id , 'value' => $original_name - ); + ]; $this->set_metadatas($metas, true); } @@ -859,10 +859,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET originalname = :originalname WHERE record_id = :record_id'; - $params = array( + $params = [ ':originalname' => $original_name , ':record_id' => $this->get_record_id() - ); + ]; $stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -893,17 +893,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface $fields = $this->get_databox()->get_meta_structure(); - $fields_to_retrieve = array(); + $fields_to_retrieve = []; foreach ($fields as $field) { - if (in_array($field->get_thumbtitle(), array('1', $this->app['locale.I18n']))) { + if (in_array($field->get_thumbtitle(), ['1', $this->app['locale.I18n']])) { $fields_to_retrieve [] = $field->get_name(); } } if (count($fields_to_retrieve) > 0) { $retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine); - $titles = array(); + $titles = []; foreach ($retrieved_fields as $key => $value) { if (trim($value['value'] === '')) continue; @@ -1048,10 +1048,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET xml = :xml WHERE record_id= :record_id'; $stmt = $connbas->prepare($sql); $stmt->execute( - array( + [ ':xml' => $dom_doc->saveXML(), ':record_id' => $this->record_id - ) + ] ); $this->reindex(); @@ -1067,7 +1067,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface */ protected function set_metadata(Array $params, databox $databox) { - $mandatoryParams = array('meta_struct_id', 'meta_id', 'value'); + $mandatoryParams = ['meta_struct_id', 'meta_id', 'value']; foreach ($mandatoryParams as $param) { if (!array_key_exists($param, $params)) { @@ -1178,7 +1178,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $connbas = connection::getPDOConnection($this->app, $this->get_sbas_id()); $sql = 'UPDATE record SET jeton=(jeton | ' . JETON_MAKE_SUBDEF . ') WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); return $this; } @@ -1194,7 +1194,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface SET jeton = ' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . ' WHERE record_id= :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->record_id)); + $stmt->execute([':record_id' => $this->record_id]); return $this; } @@ -1210,7 +1210,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET status = :status WHERE record_id= :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->record_id, ':status' => bindec($status))); + $stmt->execute([':record_id' => $this->record_id, ':status' => bindec($status)]); $stmt->closeCursor(); $sql = 'REPLACE INTO status (id, record_id, name, value) VALUES (null, :record_id, :name, :value)'; @@ -1219,11 +1219,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface $status = strrev($status); $length = strlen($status); for ($i = 4; $i < $length; $i++) { - $stmt->execute(array( + $stmt->execute([ ':record_id' => $this->get_record_id(), ':name' => $i, ':value' => $status[$i] - )); + ]); } $stmt->closeCursor(); @@ -1253,7 +1253,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':coll_id' => $collection->get_coll_id(), ':parent_record_id' => 1, ':type' => 'unknown', @@ -1261,7 +1261,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface ':uuid' => \uuid::generate_v4(), ':originalname' => null, ':mime' => null, - )); + ]); $story_id = $databox->get_connection()->lastInsertId(); @@ -1274,11 +1274,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface VALUES (null, :log_id, now(), :record_id, "add", :coll_id,"")'; $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':log_id' => $log_id, ':record_id' => $story_id, ':coll_id' => $collection->get_coll_id() - )); + ]); $stmt->closeCursor(); } catch (Exception $e) { unset($e); @@ -1308,7 +1308,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':coll_id' => $file->getCollection()->get_coll_id(), ':parent_record_id' => 0, ':type' => $file->getType() ? $file->getType()->getType() : 'unknown', @@ -1316,7 +1316,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface ':uuid' => $file->getUUID(true), ':originalname' => $file->getOriginalName(), ':mime' => $file->getFile()->getMimeType(), - )); + ]); $record_id = $databox->get_connection()->lastInsertId(); @@ -1329,11 +1329,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface VALUES (null, :log_id, now(), :record_id, "add", :coll_id,"")'; $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':log_id' => $log_id, ':record_id' => $record_id, ':coll_id' => $file->getCollection()->get_coll_id() - )); + ]); $stmt->closeCursor(); } catch (Exception $e) { unset($e); @@ -1384,11 +1384,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface } } - $stmt->execute(array( + $stmt->execute([ ':record_id' => $this->get_record_id() , ':name' => $name , ':value' => $value - )); + ]); } $stmt->closeCursor(); @@ -1415,7 +1415,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface WHERE sha256 IS NOT NULL AND sha256 = :sha256"; - $params = array(':sha256' => $sha256); + $params = [':sha256' => $sha256]; if (!is_null($record_id)) { $sql .= ' AND record_id = :record_id'; @@ -1427,7 +1427,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $records = array(); + $records = []; foreach ($rs as $row) { $records[] = new record_adapter($app, $sbas_id, $row['record_id']); @@ -1451,7 +1451,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = "SELECT record_id FROM record r WHERE uuid IS NOT NULL AND uuid = :uuid"; - $params = array(':uuid' => $uuid); + $params = [':uuid' => $uuid]; if (!is_null($record_id)) { $sql .= ' AND record_id = :record_id'; @@ -1463,7 +1463,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $records = array(); + $records = []; foreach ($rs as $row) { $records[] = new record_adapter($app, $databox->get_sbas_id(), $row['record_id']); @@ -1495,7 +1495,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface { $connbas = $this->get_databox()->get_connection(); - $ftodel = array(); + $ftodel = []; foreach ($this->get_subdefs() as $subdef) { if (!$subdef->is_physically_present()) continue; @@ -1518,60 +1518,60 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = "DELETE FROM record WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM metadatas WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM prop WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM idx WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM permalinks WHERE subdef_id IN (SELECT subdef_id FROM subdef WHERE record_id=:record_id)"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM subdef WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM technical_datas WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM thit WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM regroup WHERE rid_parent = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM regroup WHERE rid_child = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $orderElementRepository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\OrderElement'); /* @var $repository Alchemy\Phrasea\Model\Repositories\OrderElementRepository */ - foreach ($orderElementRepository->findBy(array('recordId' => $this->get_record_id())) as $order_element) { + foreach ($orderElementRepository->findBy(['recordId' => $this->get_record_id()]) as $order_element) { if ($order_element->getSbasId($this->app) == $this->get_sbas_id()) { $this->app['EM']->remove($order_element); } @@ -1832,12 +1832,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface VALUES (null, :log_id, now(), :rec, :referrer, :site)'; - $params = array( + $params = [ ':log_id' => $log_id , ':rec' => $this->get_record_id() , ':referrer' => $referrer , ':site' => $gv_sit - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -1884,11 +1884,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface , $offset_start, $how_many); $stmt = $databox->get_connection()->prepare($sql); - $stmt->execute(array(':original_name' => $original_name)); + $stmt->execute([':original_name' => $original_name]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $records = array(); + $records = []; foreach ($rs as $row) { $records[] = $databox->get_record($row['record_id']); } @@ -1920,11 +1920,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface ON (g.rid_child = r.record_id AND g.rid_parent = :record_id) ORDER BY g.ord ASC, dateadd ASC, record_id ASC'; - $params = array( + $params = [ ':GV_site' => $this->app['configuration']['main']['key'], ':usr_id' => $this->app['authentication']->getUser()->get_id(), ':record_id' => $this->get_record_id(), - ); + ]; } else { $sql = 'SELECT record_id FROM regroup g @@ -1932,9 +1932,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface ON (g.rid_child = r.record_id AND g.rid_parent = :record_id) ORDER BY g.ord ASC, dateadd ASC, record_id ASC'; - $params = array( + $params = [ ':record_id' => $this->get_record_id() - ); + ]; } $stmt = $this->get_databox()->get_connection()->prepare($sql); @@ -1971,11 +1971,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface ON (g.rid_parent = r.record_id) WHERE rid_child = :record_id'; - $params = array( + $params = [ ':GV_site' => $this->app['configuration']['main']['key'] , ':usr_id' => $this->app['authentication']->getUser()->get_id() , ':record_id' => $this->get_record_id() - ); + ]; $stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -2010,7 +2010,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $stmt = $connbas->prepare($sql); - $stmt->execute(array(':parent_record_id' => $this->get_record_id())); + $stmt->execute([':parent_record_id' => $this->get_record_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); @@ -2023,11 +2023,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'INSERT INTO regroup (id, rid_parent, rid_child, dateadd, ord) VALUES (null, :parent_record_id, :record_id, NOW(), :ord)'; - $params = array( + $params = [ ':parent_record_id' => $this->get_record_id() , ':record_id' => $record->get_record_id() , ':ord' => $ord - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -2036,7 +2036,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -2055,10 +2055,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = "DELETE FROM regroup WHERE rid_parent = :parent_record_id AND rid_child = :record_id"; - $params = array( + $params = [ ':parent_record_id' => $this->get_record_id() , ':record_id' => $record->get_record_id() - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -2066,7 +2066,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); diff --git a/lib/classes/record/exportElement.php b/lib/classes/record/exportElement.php index b7f949abfa..962a1d469c 100644 --- a/lib/classes/record/exportElement.php +++ b/lib/classes/record/exportElement.php @@ -69,7 +69,7 @@ class record_exportElement extends record_adapter } $this->remain_hd = $remain_hd; - $this->size = array(); + $this->size = []; parent::__construct($app, $sbas_id, $record_id); $this->get_actions($remain_hd); @@ -83,8 +83,8 @@ class record_exportElement extends record_adapter */ protected function get_actions() { - $this->downloadable = $downloadable = array(); - $this->orderable = $orderable = array(); + $this->downloadable = $downloadable = []; + $this->orderable = $orderable = []; $sd = $this->get_subdefs(); @@ -92,7 +92,7 @@ class record_exportElement extends record_adapter $subdefgroups = $this->app['phraseanet.appbox']->get_databox($sbas_id)->get_subdef_structure(); - $subdefs = array(); + $subdefs = []; foreach ($subdefgroups as $subdef_type => $subdefs_obj) { if ($subdef_type == $this->get_type()) { @@ -101,11 +101,11 @@ class record_exportElement extends record_adapter } } - $go_dl = array( + $go_dl = [ 'document' => false, 'preview' => false, 'thumbnail' => true - ); + ]; if ($this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($this->get_base_id(), 'candwnldhd')) { $go_dl['document'] = true; @@ -123,8 +123,8 @@ class record_exportElement extends record_adapter $query = new User_Query($this->app); - $masters = $query->on_base_ids(array($this->base_id)) - ->who_have_right(array('order_master')) + $masters = $query->on_base_ids([$this->base_id]) + ->who_have_right(['order_master']) ->execute()->get_results(); $go_cmd = (count($masters) > 0 && $this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($this->base_id, 'cancmd')); @@ -137,15 +137,15 @@ class record_exportElement extends record_adapter if ($this->app['acl']->get($this->app['authentication']->getUser())->is_restricted_download($this->base_id)) { $this->remain_hd --; if ($this->remain_hd >= 0) - $downloadable['document'] = array( + $downloadable['document'] = [ 'class' => 'document', 'label' => _('document original') - ); + ]; } else - $downloadable['document'] = array( + $downloadable['document'] = [ 'class' => 'document', 'label' => _('document original') - ); + ]; } if ($go_cmd === true) { $orderable['document'] = true; @@ -185,20 +185,20 @@ class record_exportElement extends record_adapter if ($this->app['acl']->get($this->app['authentication']->getUser())->is_restricted_download($this->base_id)) { $this->remain_hd --; if ($this->remain_hd >= 0) - $downloadable[$name] = array( + $downloadable[$name] = [ 'class' => $class, 'label' => $subdef_label - ); + ]; } else - $downloadable[$name] = array( + $downloadable[$name] = [ 'class' => $class, 'label' => $subdef_label - ); + ]; } else { - $downloadable[$name] = array( + $downloadable[$name] = [ 'class' => $class, 'label' => $subdef_label - ); + ]; } $this->add_count($name, $sd[$name]->get_size()); @@ -209,15 +209,15 @@ class record_exportElement extends record_adapter $xml = $this->get_caption()->serialize(caption_record::SERIALIZE_XML); if ($xml) { - $downloadable['caption'] = array( + $downloadable['caption'] = [ 'class' => 'caption', 'label' => _('caption XML') - ); + ]; $this->add_count('caption', strlen($xml)); - $downloadable['caption-yaml'] = array( + $downloadable['caption-yaml'] = [ 'class' => 'caption', 'label' => _('caption YAML') - ); + ]; $this->add_count('caption-yaml', strlen(strip_tags($xml))); } @@ -236,7 +236,7 @@ class record_exportElement extends record_adapter private function add_count($name, $size) { if (! $this->size) { - $objectsize = array(); + $objectsize = []; } else $objectsize = $this->size; diff --git a/lib/classes/record/preview.php b/lib/classes/record/preview.php index e0e119e74f..82c487cd1d 100644 --- a/lib/classes/record/preview.php +++ b/lib/classes/record/preview.php @@ -333,7 +333,7 @@ class record_preview extends record_adapter return $this->short_history; } - $tab = array(); + $tab = []; $report = $this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($this->get_base_id(), 'canreport'); @@ -343,7 +343,7 @@ class record_preview extends record_adapter FROM log_docs d, log l WHERE d.log_id = l.id AND d.record_id = :record_id '; - $params = array(':record_id' => $this->get_record_id()); + $params = [':record_id' => $this->get_record_id()]; if (! $report) { $sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")'; @@ -362,17 +362,17 @@ class record_preview extends record_adapter $hour = $this->app['date-formatter']->getPrettyString(new DateTime($row['date'])); if ( ! isset($tab[$hour])) - $tab[$hour] = array(); + $tab[$hour] = []; $site = $row['site']; if ( ! isset($tab[$hour][$site])) - $tab[$hour][$site] = array(); + $tab[$hour][$site] = []; $action = $row['action']; if ( ! isset($tab[$hour][$site][$action])) - $tab[$hour][$site][$action] = array(); + $tab[$hour][$site][$action] = []; if ( ! isset($tab[$hour][$site][$action][$row['usr_id']])) { $user = null; @@ -384,11 +384,11 @@ class record_preview extends record_adapter } $tab[$hour][$site][$action][$row['usr_id']] = - array( - 'final' => array() - , 'comment' => array() + [ + 'final' => [] + , 'comment' => [] , 'user' => $user - ); + ]; } if ( ! in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final'])) { @@ -427,7 +427,7 @@ class record_preview extends record_adapter return $this->view_popularity; } - $views = $dwnls = array(); + $views = $dwnls = []; $top = 1; $day = 30; $min = 0; @@ -451,10 +451,10 @@ class record_preview extends record_adapter $connsbas = connection::getPDOConnection($this->app, $this->get_sbas_id()); $stmt = $connsbas->prepare($sql); $stmt->execute( - array( + [ ':record_id' => $this->get_record_id(), ':site' => $this->app['configuration']['main']['key'] - ) + ] ); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -525,11 +525,11 @@ class record_preview extends record_adapter GROUP BY referrer ORDER BY referrer ASC'; $stmt = $connsbas->prepare($sql); - $stmt->execute(array(':record_id' => $this->get_record_id())); + $stmt->execute([':record_id' => $this->get_record_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $referrers = array(); + $referrers = []; foreach ($rs as $row) { if ($row['referrer'] == 'NO REFERRER') @@ -588,7 +588,7 @@ class record_preview extends record_adapter return $this->download_popularity; } - $views = $dwnls = array(); + $views = $dwnls = []; $top = 1; $day = 30; @@ -612,10 +612,10 @@ class record_preview extends record_adapter $connsbas = connection::getPDOConnection($this->app, $this->get_sbas_id()); $stmt = $connsbas->prepare($sql); $stmt->execute( - array( + [ ':record_id' => $this->get_record_id(), ':site' => $this->app['configuration']['main']['key'] - ) + ] ); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/classes/recordutils/image.php b/lib/classes/recordutils/image.php index c168c67cb3..b430b159fd 100644 --- a/lib/classes/recordutils/image.php +++ b/lib/classes/recordutils/image.php @@ -34,7 +34,7 @@ class recordutils_image extends recordutils $palette = new RGB(); } - $xmlToColor = function($attr, $ret = array(255, 255, 255)) use ($palette) { + $xmlToColor = function ($attr, $ret = [255, 255, 255]) use ($palette) { try { return $palette->color($attr, 0); } catch (ImagineException $e) { @@ -134,20 +134,20 @@ class recordutils_image extends recordutils } - $tables = array( - 'TOP' => array('h' => 0, 'rows' => array()), - 'TOP-OVER' => array('h' => 0, 'rows' => array()), - 'BOTTOM' => array('h' => 0, 'rows' => array()), - 'BOTTOM-OVER' => array('h' => 0, 'rows' => array()) - ); + $tables = [ + 'TOP' => ['h' => 0, 'rows' => []], + 'TOP-OVER' => ['h' => 0, 'rows' => []], + 'BOTTOM' => ['h' => 0, 'rows' => []], + 'BOTTOM-OVER' => ['h' => 0, 'rows' => []] + ]; for ($istamp = 0; $istamp < $stampNodes->length; $istamp++) { $stamp = $stampNodes->item($istamp); - $stamp_background = $xmlToColor($stamp->getAttribute('background'), array(255, 255, 255)); + $stamp_background = $xmlToColor($stamp->getAttribute('background'), [255, 255, 255]); $stamp_position = strtoupper(trim($stamp->getAttribute('position'))); - if (!in_array($stamp_position, array('TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'))) { + if (!in_array($stamp_position, ['TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'])) { $stamp_position = 'BOTTOM'; } @@ -232,7 +232,7 @@ class recordutils_image extends recordutils // compute text blocks $txth = 0; - $txtblock = array(); + $txtblock = []; $texts = $xpprefs->query('text', $stamp); $fontsize = "100%"; for ($i = 0; $i < $texts->length; $i++) { @@ -255,12 +255,12 @@ class recordutils_image extends recordutils if ($txtline != '') { $wrap = static::wrap($app['imagine'], $fontsize, 0, __DIR__ . '/arial.ttf', $txtline, $text_width); - $txtblock[] = array( + $txtblock[] = [ 'fontsize' => $fontsize, - 'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), array(0, 0, 0)), + 'fontcolor' => $xmlToColor($texts->item($i)->getAttribute('color'), [0, 0, 0]), 'h' => $wrap['toth'], 'lines' => $wrap['l'] - ); + ]; $txth += $wrap['toth']; } } @@ -305,13 +305,13 @@ class recordutils_image extends recordutils } // memo into one of the 4 buffer - $tables[$stamp_position]['rows'][] = array( + $tables[$stamp_position]['rows'][] = [ 'x0' => 0, 'y0' => $tables[$stamp_position]['h'], 'w' => $image_width, 'h' => $stampheight, 'img' => $imfg - ); + ]; $tables[$stamp_position]['h'] += $stampheight; } @@ -336,7 +336,7 @@ class recordutils_image extends recordutils } // paste blocks - foreach (array('TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM') as $ta) { + foreach (['TOP', 'TOP-OVER', 'BOTTOM-OVER', 'BOTTOM'] as $ta) { foreach ($tables[$ta]['rows'] as $row) { if ($row['h'] > 0) { $image_out->paste($row['img'], new Point($row['x0'], $row['y0'])); @@ -427,10 +427,10 @@ class recordutils_image extends recordutils $draw->line(new Point(1, $in_h - 1), new Point($in_w - 1, 1), $white); $fsize = max(8, (int) (max($in_w, $in_h) / 30)); - $fonts = array( + $fonts = [ $app['imagine']->font(__DIR__ . '/arial.ttf', $fsize, $black), $app['imagine']->font(__DIR__ . '/arial.ttf', $fsize, $white) - ); + ]; $testbox = $fonts[0]->box($collname, 0); $tx_w = min($in_w, $testbox->getWidth()); $tx_h = min($in_h, $testbox->getHeight()); @@ -482,21 +482,21 @@ class recordutils_image extends recordutils $testbox = $font->box("M", $angle); // 1 em $dy = $testbox->getHeight(); $toth = 0; - $ret = array(); + $ret = []; foreach (explode("\n", $string) as $lig) { if ($lig == '') { - $ret[] = array('w' => 0, 'h' => $dy, 't' => ''); + $ret[] = ['w' => 0, 'h' => $dy, 't' => '']; $toth += $dy; } else { - $twords = array(); + $twords = []; $iword = -1; $lastc = ''; $length = strlen($lig); for ($i = 0; $i < $length; $i++) { $c = $lig[$i]; if ($iword == -1 || (ctype_space($c) && !ctype_space($lastc))) { - $twords[++$iword] = array(($part = 0) => '', 1 => ''); + $twords[++$iword] = [($part = 0) => '', 1 => '']; } if (!ctype_space($c) && $part == 0) { $part++; @@ -512,7 +512,7 @@ class recordutils_image extends recordutils $w = $testbox->getWidth(); $h = $testbox->getHeight(); if ($i > 0 && $testbox->getWidth() > $width) { - $ret[] = array('w' => $lastw, 'h' => $lasth, 't' => $buff); + $ret[] = ['w' => $lastw, 'h' => $lasth, 't' => $buff]; $toth += $lasth; $buff = $wrd[1]; } else { @@ -522,13 +522,13 @@ class recordutils_image extends recordutils $lasth = $h; } if ($buff != '') { - $ret[] = array('w' => $lastw, 'h' => $lasth, 't' => $buff); + $ret[] = ['w' => $lastw, 'h' => $lasth, 't' => $buff]; $toth += $lasth; } } } } - return array('toth' => $toth, 'l' => $ret, 'h' => $height, 'dy' => $dy); + return ['toth' => $toth, 'l' => $ret, 'h' => $height, 'dy' => $dy]; } } diff --git a/lib/classes/registry.php b/lib/classes/registry.php index 37b282999e..6a0bfc4f49 100644 --- a/lib/classes/registry.php +++ b/lib/classes/registry.php @@ -67,7 +67,7 @@ class registry implements registryInterface protected function load() { if ($this->cache->fetch('registry_loaded') !== true) { - $rs = array(); + $rs = []; $loaded = false; try { $conn = connection::getPDOConnection($this->app); @@ -81,7 +81,7 @@ class registry implements registryInterface } foreach ($rs as $row) { - if (in_array($row['key'], array('GV_ServerName', 'GV_sit', 'GV_debug'))) { + if (in_array($row['key'], ['GV_ServerName', 'GV_sit', 'GV_debug'])) { continue; } @@ -180,7 +180,7 @@ class registry implements registryInterface $sql = 'REPLACE INTO registry (`id`, `key`, `value`, `type`) VALUES (null, :key, :value, :type)'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':key' => $key, ':value' => $sql_value, ':type' => $type)); + $stmt->execute([':key' => $key, ':value' => $sql_value, ':type' => $type]); $stmt->closeCursor(); $this->cache->save($key, $value); @@ -217,7 +217,7 @@ class registry implements registryInterface $sql = 'DELETE FROM registry WHERE `key` = :key'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':key' => $key)); + $stmt->execute([':key' => $key]); $stmt->closeCursor(); $this->cache->delete($key); diff --git a/lib/classes/set/abstract.php b/lib/classes/set/abstract.php index 6ef7b6567f..44e804c23c 100644 --- a/lib/classes/set/abstract.php +++ b/lib/classes/set/abstract.php @@ -21,7 +21,7 @@ abstract class set_abstract implements IteratorAggregate * * @var Array */ - protected $elements = array(); + protected $elements = []; /** * @@ -175,7 +175,7 @@ abstract class set_abstract implements IteratorAggregate */ public function serialize_list() { - $basrec = array(); + $basrec = []; foreach ($this->elements as $record) { $basrec[] = $record->get_serialize_key(); } diff --git a/lib/classes/set/export.php b/lib/classes/set/export.php index 43d4791cf6..86e15ce8b0 100644 --- a/lib/classes/set/export.php +++ b/lib/classes/set/export.php @@ -21,7 +21,7 @@ use Symfony\Component\Filesystem\Filesystem; class set_export extends set_abstract { protected $app; - protected $storage = array(); + protected $storage = []; protected $total_download; protected $total_order; protected $total_ftp; @@ -45,9 +45,9 @@ class set_export extends set_abstract { $this->app = $app; - $download_list = array(); + $download_list = []; - $remain_hd = array(); + $remain_hd = []; if ($storyWZid) { $repository = $app['EM']->getRepository('\\Entities\\StoryWZ'); @@ -61,7 +61,7 @@ class set_export extends set_abstract $Basket = $app['converter.basket']->convert($sstid); $app['acl.basket']->hasAccess($Basket, $app['authentication']->getUser()); - $this->exportName = str_replace(array(' ', '\\', '/'), '_', $Basket->getName()) . "_" . date("Y-n-d"); + $this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d"); foreach ($Basket->getElements() as $basket_element) { $base_id = $basket_element->getRecord($this->app)->get_base_id(); @@ -156,8 +156,8 @@ class set_export extends set_abstract $this->elements = $download_list; - $display_download = array(); - $display_orderable = array(); + $display_download = []; + $display_orderable = []; $this->total_download = 0; $this->total_order = 0; @@ -172,12 +172,12 @@ class set_export extends set_abstract foreach ($download_element->get_downloadable() as $name => $properties) { if (!isset($display_download[$name])) { - $display_download[$name] = array( + $display_download[$name] = [ 'size' => 0, 'total' => 0, 'available' => 0, - 'refused' => array() - ); + 'refused' => [] + ]; } $display_download[$name]['total']++; @@ -194,11 +194,11 @@ class set_export extends set_abstract } foreach ($download_element->get_orderable() as $name => $properties) { if (!isset($display_orderable[$name])) { - $display_orderable[$name] = array( + $display_orderable[$name] = [ 'total' => 0, 'available' => 0, - 'refused' => array() - ); + 'refused' => [] + ]; } $display_orderable[$name]['total']++; @@ -216,7 +216,7 @@ class set_export extends set_abstract $display_download[$name]['size'] = (int) $values['size']; } - $display_ftp = array(); + $display_ftp = []; $hasadminright = $app['acl']->get($app['authentication']->getUser())->has_right('addrecord') || $app['acl']->get($app['authentication']->getUser())->has_right('deleterecord') @@ -224,7 +224,7 @@ class set_export extends set_abstract || $app['acl']->get($app['authentication']->getUser())->has_right('coll_manage') || $app['acl']->get($app['authentication']->getUser())->has_right('coll_modify_struct'); - $this->ftp_datas = array(); + $this->ftp_datas = []; if ($this->app['phraseanet.registry']->get('GV_activeFTP') && ($hasadminright || $this->app['phraseanet.registry']->get('GV_ftp_for_user'))) { $display_ftp = $display_download; @@ -245,7 +245,7 @@ class set_export extends set_abstract ) ) GROUP BY usr_id "; - $params = array(); + $params = []; } elseif ($this->app['phraseanet.registry']->get('GV_ftp_for_user')) { $sql = "SELECT usr.usr_id,usr_login,usr.usr_mail, FtpCredential.* FROM ( @@ -260,10 +260,10 @@ class set_export extends set_abstract ) ) GROUP BY usr_id "; - $params = array(':usr_id' => $app['authentication']->getUser()->get_id()); + $params = [':usr_id' => $app['authentication']->getUser()->get_id()]; } - $datas[] = array( + $datas[] = [ 'name' => _('export::ftp: reglages manuels'), 'usr_id' => '0', 'address' => '', @@ -275,7 +275,7 @@ class set_export extends set_abstract 'passive' => false, 'max_retry' => 5, 'sendermail' => $app['authentication']->getUser()->get_email() - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -283,7 +283,7 @@ class set_export extends set_abstract $stmt->closeCursor(); foreach ($rs as $row) { - $datas[] = array( + $datas[] = [ 'name' => $row["usr_login"], 'usr_id' => $row['usr_id'], 'address' => $row['address'], @@ -299,7 +299,7 @@ class set_export extends set_abstract 'max_retry' => $row['max_retry'], 'usr_mail' => $row['usr_mail'], 'sender_mail' => $app['authentication']->getUser()->get_email() - ); + ]; } $this->ftp_datas = $datas; @@ -408,11 +408,11 @@ class set_export extends set_abstract $includeBusinessFields = !!$includeBusinessFields; - $files = array(); + $files = []; $n_files = 0; - $file_names = array(); + $file_names = []; $size = 0; @@ -421,13 +421,13 @@ class set_export extends set_abstract foreach ($this->elements as $download_element) { $id = count($files); - $files[$id] = array( + $files[$id] = [ 'base_id' => $download_element->get_base_id(), 'record_id' => $download_element->get_record_id(), 'original_name' => '', 'export_name' => '', - 'subdefs' => array() - ); + 'subdefs' => [] + ]; $BF = false; @@ -466,7 +466,7 @@ class set_export extends set_abstract if ($properties === false || !in_array($name, $subdefs)) { continue; } - if (!in_array($name, array('caption', 'caption-yaml')) && !isset($sd[$name])) { + if (!in_array($name, ['caption', 'caption-yaml']) && !isset($sd[$name])) { continue; } @@ -475,7 +475,7 @@ class set_export extends set_abstract $n_files++; - $tmp_pathfile = array('path' => null, 'file' => null); + $tmp_pathfile = ['path' => null, 'file' => null]; switch ($properties['class']) { case 'caption': @@ -484,25 +484,25 @@ class set_export extends set_abstract $subdef_alive = true; break; case 'thumbnail': - $tmp_pathfile = array( + $tmp_pathfile = [ 'path' => $sd[$name]->get_path() , 'file' => $sd[$name]->get_file() - ); + ]; $subdef_export = true; $subdef_alive = true; break; case 'document': $subdef_export = true; $path = \recordutils_image::stamp($this->app , $sd[$name]); - $tmp_pathfile = array( + $tmp_pathfile = [ 'path' => $sd[$name]->get_path() , 'file' => $sd[$name]->get_file() - ); + ]; if (file_exists($path)) { - $tmp_pathfile = array( + $tmp_pathfile = [ 'path' => dirname($path) , 'file' => basename($path) - ); + ]; $subdef_alive = true; } break; @@ -510,19 +510,19 @@ class set_export extends set_abstract case 'preview': $subdef_export = true; - $tmp_pathfile = array( + $tmp_pathfile = [ 'path' => $sd[$name]->get_path() , 'file' => $sd[$name]->get_file() - ); + ]; if (!$this->app['acl']->get($user)->has_right_on_base($download_element->get_base_id(), "nowatermark") && !$this->app['acl']->get($user)->has_preview_grant($download_element) && $sd[$name]->get_type() == media_subdef::TYPE_IMAGE) { $path = recordutils_image::watermark($this->app, $sd[$name]); if (file_exists($path)) { - $tmp_pathfile = array( + $tmp_pathfile = [ 'path' => dirname($path) , 'file' => basename($path) - ); + ]; $subdef_alive = true; } } else { @@ -615,10 +615,10 @@ class set_export extends set_abstract $i = 0; $name = utf8_decode($files[$id]["export_name"]); $tmp_name = ""; - $good_keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + $good_keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', '-', '_', '.', '#'); + '4', '5', '6', '7', '8', '9', '-', '_', '.', '#']; while (isset($name[$i])) { if (!in_array(mb_strtolower($name[$i]), $good_keys)) @@ -677,12 +677,12 @@ class set_export extends set_abstract } } - $this->list = array( + $this->list = [ 'files' => $files, 'names' => $file_names, 'size' => $size, 'count' => $n_files - ); + ]; return $this->list; } @@ -713,7 +713,7 @@ class set_export extends set_abstract $app['tokens']->updateToken($token, serialize($list)); - $toRemove = array(); + $toRemove = []; foreach ($files as $record) { if (isset($record["subdefs"])) { @@ -765,13 +765,13 @@ class set_export extends set_abstract */ public static function log_download(Application $app, Array $list, $type, $anonymous = false, $comment = '') { - $tmplog = array(); + $tmplog = []; $files = $list['files']; - $event_names = array( + $event_names = [ 'mail-export' => Session_Logger::EVENT_EXPORTMAIL, 'download' => Session_Logger::EVENT_EXPORTDOWNLOAD - ); + ]; $event_name = isset($event_names[$type]) ? $event_names[$type] : Session_Logger::EVENT_EXPORTDOWNLOAD; @@ -810,11 +810,11 @@ class set_export extends set_abstract foreach ($list_base as $base_id) { if ($app['acl']->get($app['authentication']->getUser())->is_restricted_download($base_id)) { - $params = array( + $params = [ ':remain_dl' => $app['acl']->get($app['authentication']->getUser())->remaining_download($base_id) , ':base_id' => $base_id , ':usr_id' => $app['acl']->get($app['authentication']->getUser())->get_id() - ); + ]; $stmt->execute($params); } diff --git a/lib/classes/set/selection.php b/lib/classes/set/selection.php index 8af560da28..0d05b435bf 100644 --- a/lib/classes/set/selection.php +++ b/lib/classes/set/selection.php @@ -28,7 +28,7 @@ class set_selection extends set_abstract public function __construct(Application $app) { $this->app = $app; - $this->elements = array(); + $this->elements = []; return $this; } @@ -54,9 +54,9 @@ class set_selection extends set_abstract * * @return set_selection */ - public function grep_authorized(Array $rights = array(), Array $sbas_rights = array()) + public function grep_authorized(Array $rights = [], Array $sbas_rights = []) { - $to_remove = array(); + $to_remove = []; foreach ($this->elements as $id => $record) { $base_id = $record->get_base_id(); @@ -99,7 +99,7 @@ class set_selection extends set_abstract AND record_id = :record_id'; $stmt = $connsbas->prepare($sql); - $stmt->execute(array(':record_id' => $record_id)); + $stmt->execute([':record_id' => $record_id]); $num_rows = $stmt->rowCount(); $stmt->closeCursor(); @@ -153,7 +153,7 @@ class set_selection extends set_abstract */ public function get_distinct_sbas_ids() { - $ret = array(); + $ret = []; foreach ($this->elements as $record) { $sbas_id = phrasea::sbasFromBas($this->app, $record->get_base_id()); $ret[$sbas_id] = $sbas_id; diff --git a/lib/classes/setup.php b/lib/classes/setup.php index 39c05c3187..083a9357fe 100644 --- a/lib/classes/setup.php +++ b/lib/classes/setup.php @@ -24,11 +24,11 @@ use Symfony\Component\Process\ExecutableFinder; */ class setup { - public static function create_global_values(Application $app, $datas = array()) + public static function create_global_values(Application $app, $datas = []) { $GV = require(__DIR__ . "/../../lib/conf.d/_GV_template.inc"); - $vars = array(); + $vars = []; $error = false; foreach ($GV as $section) { @@ -94,7 +94,7 @@ class setup if ($variable['type'] !== 'integer' && $variable['type'] !== 'boolean') $datas[$variable['name']] = $datas[$variable['name']]; - $vars[$variable['name']] = array('value' => $datas[$variable['name']], 'type' => $type); + $vars[$variable['name']] = ['value' => $datas[$variable['name']], 'type' => $type]; } } @@ -117,55 +117,55 @@ class setup $phpFinder = new PhpExecutableFinder(); $finder = new ExecutableFinder(); - return array( - 'php' => array( + return [ + 'php' => [ 'name' => 'PHP CLI', 'binary' => $phpFinder->find() - ), - 'phraseanet_indexer' => array( + ], + 'phraseanet_indexer' => [ 'name' => 'Indexeur Phrasea', 'binary' => $finder->find('phraseanet_indexer') - ), - 'convert' => array( + ], + 'convert' => [ 'name' => 'ImageMagick (convert)', 'binary' => $finder->find('convert') - ), - 'composite' => array( + ], + 'composite' => [ 'name' => 'ImageMagick (composite)', 'binary' => $finder->find('composite') - ), - 'pdf2swf' => array( + ], + 'pdf2swf' => [ 'name' => 'PDF 2 SWF', 'binary' => $finder->find('pdf2swf') - ), - 'unoconv' => array( + ], + 'unoconv' => [ 'name' => 'Unoconv', 'binary' => $finder->find('unoconv') - ), - 'swfextract' => array( + ], + 'swfextract' => [ 'name' => 'SWFextract', 'binary' => $finder->find('swfextract') - ), - 'swfrender' => array( + ], + 'swfrender' => [ 'name' => 'SWFrender', 'binary' => $finder->find('swfrender') - ), - 'MP4Box' => array( + ], + 'MP4Box' => [ 'name' => 'MP4Box', 'binary' => $finder->find('MP4Box') - ), - 'xpdf' => array( + ], + 'xpdf' => [ 'name' => 'XPDF', 'binary' => $finder->find('xpdf') - ), - 'ffmpeg' => array( + ], + 'ffmpeg' => [ 'name' => 'FFmpeg', 'binary' => $finder->find('ffmpeg') - ), - 'recess' => array( + ], + 'recess' => [ 'name' => 'Recesss', 'binary' => $finder->find('recess') - ), - ); + ], + ]; } } diff --git a/lib/classes/thesaurus.php b/lib/classes/thesaurus.php index 5e1992017f..d32d517753 100644 --- a/lib/classes/thesaurus.php +++ b/lib/classes/thesaurus.php @@ -5,6 +5,6 @@ class thesaurus public static function xquery_escape($s) { - return(str_replace(array("&", "\"", "'"), array("&", """, "'"), $s)); + return(str_replace(["&", "\"", "'"], ["&", """, "'"], $s)); } } diff --git a/lib/classes/thesaurus/xpath.php b/lib/classes/thesaurus/xpath.php index 288af8e015..15c9020985 100644 --- a/lib/classes/thesaurus/xpath.php +++ b/lib/classes/thesaurus/xpath.php @@ -20,7 +20,7 @@ class thesaurus_xpath extends DOMXPath * * @var array */ - protected static $r = array(); + protected static $r = []; /** * diff --git a/lib/classes/unicode.php b/lib/classes/unicode.php index 12e38f1b93..4b53458fb8 100644 --- a/lib/classes/unicode.php +++ b/lib/classes/unicode.php @@ -20,8 +20,8 @@ class unicode const CONVERT_TO_ND = 'nd'; // no-diacritics const CONVERT_TO_LCND = 'lcnd'; // lowercase no-diacritics - protected static $map = array( - self::CONVERT_TO_LC => array( + protected static $map = [ + self::CONVERT_TO_LC => [ "\x41" => "\x61" , /* U+0041: LATIN CAPITAL LETTER A -> U+0061: LATIN SMALL LETTER A */ "\x42" => "\x62" , /* U+0042: LATIN CAPITAL LETTER B -> U+0062: LATIN SMALL LETTER B */ "\x43" => "\x63" , /* U+0043: LATIN CAPITAL LETTER C -> U+0063: LATIN SMALL LETTER C */ @@ -486,9 +486,9 @@ class unicode "\xD5\x94" => "\xD6\x84" , /* U+0554: ARMENIAN CAPITAL LETTER KEH -> U+0584: ARMENIAN SMALL LETTER KEH */ "\xD5\x95" => "\xD6\x85" , /* U+0555: ARMENIAN CAPITAL LETTER OH -> U+0585: ARMENIAN SMALL LETTER OH */ "\xD5\x96" => "\xD6\x86" /* U+0556: ARMENIAN CAPITAL LETTER FEH -> U+0586: ARMENIAN SMALL LETTER FEH */ - ), + ], - self::CONVERT_TO_ND => array( + self::CONVERT_TO_ND => [ "\xC2\xA0" => "\x20" , /* U+00A0: NO-BREAK SPACE -> U+0020: SPACE */ "\xC2\xA8" => "\x20" , /* U+00A8: DIAERESIS -> U+0020: SPACE */ "\xC2\xAA" => "\x61" , /* U+00AA: FEMININE ORDINAL INDICATOR -> U+0061: LATIN SMALL LETTER A */ @@ -864,9 +864,9 @@ class unicode "\xD3\xB5" => "\xD1\x87", /* U+04F5: CYRILLIC SMALL LETTER CHE WITH DIAERESIS -> U+0447: CYRILLIC SMALL LETTER CHE */ "\xD3\xB8" => "\xD0\xAB", /* U+04F8: CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS -> U+042B: CYRILLIC CAPITAL LETTER YERU */ "\xD3\xB9" => "\xD1\x8B" /* U+04F9: CYRILLIC SMALL LETTER YERU WITH DIAERESIS -> U+044B: CYRILLIC SMALL LETTER YERU */ - ), + ], - self::CONVERT_TO_LCND => array( + self::CONVERT_TO_LCND => [ "\x41" => "\x61" , /* U+0041: LATIN CAPITAL LETTER A -> U+0061: LATIN SMALL LETTER A */ "\x42" => "\x62" , /* U+0042: LATIN CAPITAL LETTER B -> U+0062: LATIN SMALL LETTER B */ "\x43" => "\x63" , /* U+0043: LATIN CAPITAL LETTER C -> U+0063: LATIN SMALL LETTER C */ @@ -1543,8 +1543,8 @@ class unicode "\xD5\x94" => "\xD6\x84" , /* U+0554: ARMENIAN CAPITAL LETTER KEH -> U+0584: ARMENIAN SMALL LETTER KEH */ "\xD5\x95" => "\xD6\x85" , /* U+0555: ARMENIAN CAPITAL LETTER OH -> U+0585: ARMENIAN SMALL LETTER OH */ "\xD5\x96" => "\xD6\x86" /* U+0556: ARMENIAN CAPITAL LETTER FEH -> U+0586: ARMENIAN SMALL LETTER FEH */ - ) - ); + ] + ]; protected $endCharacters_utf8 = "\t\r\n !\"#\$%&'()+,-./:;<=>@[\]^_`{|}~£§¨°"; @@ -1719,10 +1719,10 @@ class unicode if (is_null($chars_in)) { - $chars_in = array(); + $chars_in = []; for ($cc = 0; $cc < 32; $cc ++) { - if (in_array($cc, array(9, 10, 13))) { + if (in_array($cc, [9, 10, 13])) { continue; } @@ -1748,7 +1748,7 @@ class unicode */ public function parseDate($date) { - $date = str_replace(array('-', ':', '/', '.'), ' ', $date); + $date = str_replace(['-', ':', '/', '.'], ' ', $date); $date_yyyy = $date_mm = $date_dd = $date_hh = $date_ii = $date_ss = 0; switch (sscanf($date, '%d %d %d %d %d %d', $date_yyyy, $date_mm, $date_dd, $date_hh, $date_ii, $date_ss)) { diff --git a/lib/classes/uuid.php b/lib/classes/uuid.php index 331cfbd8db..0a6796c992 100644 --- a/lib/classes/uuid.php +++ b/lib/classes/uuid.php @@ -22,7 +22,7 @@ class uuid } // Get hexadecimal components of namespace - $nhex = str_replace(array('-', '{', '}'), '', $namespace); + $nhex = str_replace(['-', '{', '}'], '', $namespace); // Binary Value $nstr = ''; @@ -89,7 +89,7 @@ class uuid } // Get hexadecimal components of namespace - $nhex = str_replace(array('-', '{', '}'), '', $namespace); + $nhex = str_replace(['-', '{', '}'], '', $namespace); // Binary Value $nstr = ''; diff --git a/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php index c0276751dc..77df0977cb 100644 --- a/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php +++ b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php @@ -34,12 +34,12 @@ class LoadOneBasketEnv extends \PhraseaFixture\AbstractWZ implements FixtureInte /** * @var Array */ - protected $participants = array(); + protected $participants = []; /** * @var Array */ - protected $basketElements = array(); + protected $basketElements = []; public function addParticipant(\User_Adapter $user) { diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 62c401375a..d4a6b228a5 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -13,19 +13,19 @@ return call_user_func_array(function(Application $app) { $create_api_dailymotion = 'http://www.dailymotion.com/profile/developer'; try { - $youtube_callback = $app->url('prod_bridge_callback', array('api_name' => 'youtube')); + $youtube_callback = $app->url('prod_bridge_callback', ['api_name' => 'youtube']); } catch (RouteNotFoundException $e) { $youtube_callback = null; } try { - $flickr_callback = $app->url('prod_bridge_callback', array('api_name' => 'flickr')); + $flickr_callback = $app->url('prod_bridge_callback', ['api_name' => 'flickr']); } catch (RouteNotFoundException $e) { $flickr_callback = null; } try { - $dailymotion_callback = $app->url('prod_bridge_callback', array('api_name' => 'dailymotion')); + $dailymotion_callback = $app->url('prod_bridge_callback', ['api_name' => 'dailymotion']); } catch (RouteNotFoundException $e) { $dailymotion_callback = null; } @@ -33,638 +33,638 @@ return call_user_func_array(function(Application $app) { $recaptchaDoc = 'http://www.google.com/recaptcha'; $imagineDoc = 'http://imagine.readthedocs.org/en/latest/usage/introduction.html'; - return array( - array( + return [ + [ 'section' => _('HTTP Server'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_default_lng', 'comment' => _('Default language'), 'default' => 'fr_FR', 'available' => $avLanguages, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_STATIC_URL', 'end_slash' => false, 'comment' => _('Static URL'), 'help' => _('optional'), 'default' => '', - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Maintenance state'), 'rolled' => true, - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_TEXT, 'name' => 'GV_message', 'comment' => _('Maintenance message'), 'default' => "May the force be with you" - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_message_on', 'comment' => _('Enable maintenance message broadcast'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_log_errors', 'comment' => _('Log errors'), 'default' => false - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Webservices connectivity'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_google_api', 'comment' => _('Use Google API'), 'default' => true, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_i18n_service', 'comment' => _('Geonames server address'), 'default' => 'https://geonames.alchemyasp.com/', 'end_slash' => true, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_captchas', 'comment' => _('Use recaptcha API'), 'help' => _(sprintf('See documentation at %s', $recaptchaDoc)), 'default' => false, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_captcha_public_key', 'comment' => _('Recaptcha public key'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_captcha_private_key', 'comment' => _('Recaptcha private key'), 'default' => '' - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Youtube connectivity'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_youtube_api', 'comment' => _('Use youtube API'), 'help' => sprintf(_('Create API account at %s, then use %s as callback URL value'), $youtube_console_url, $youtube_callback), 'default' => false, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_youtube_client_id', 'comment' => _('Youtube public key'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_youtube_client_secret', 'comment' => _('Youtube secret key'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_youtube_dev_key', 'comment' => _('Youtube developer key'), 'help' => sprintf(_('See %s'), $dashboard_youtube), 'default' => '' - ) - ) - ), array( + ] + ] + ], [ 'section' => _('FlickR connectivity'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_flickr_api', 'comment' => _('Use Flickr API'), 'help' => sprintf(_('Create API account at %s, then use %s as callback URL value'), $create_api_flickr, $flickr_callback), 'default' => false, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_flickr_client_id', 'comment' => _('Flickr public key'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_flickr_client_secret', 'comment' => _('Flickr secret key'), 'default' => '' - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Dailymotion connectivity'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_dailymotion_api', 'comment' => _('Use Dailymotion API'), 'help' => sprintf(_('Create API account at %s, then use %s as callback URL value'), $create_api_dailymotion, $dailymotion_callback), 'default' => false, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_dailymotion_client_id', 'comment' => _('Dailymotion public key'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_dailymotion_client_secret', 'comment' => _('Dailymotion secret key'), 'default' => '' - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Phraseanet client API'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_client_navigator', 'comment' => _('Authorize *Phraseanet Navigator*'), 'help' => _('*Phraseanet Navigator* is a smartphone application that allow user to connect on this instance'), 'default' => true, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_client_officeplugin', 'comment' => _('Authorize Microsoft Office Plugin to connect.'), 'default' => true, 'required' => true - ), - ) - ), array( + ], + ] + ], [ 'section' => _('Documents storage'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_base_datapath_noweb', 'end_slash' => true, 'comment' => _('Default path for datas'), 'default' => '', 'required' => true - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Executables settings'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_h264_streaming', 'comment' => _('Enable H264 stream mode'), 'help' => _('Use with mod_token. Attention requires the apache modules and mod_h264_streaming mod_auth_token'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_mod_auth_token_directory', 'end_slash' => true, 'comment' => _('Auth_token mount point'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_mod_auth_token_directory_path', 'end_slash' => false, 'comment' => _('Auth_token directory path'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_mod_auth_token_passphrase', 'comment' => _('Auth_token passphrase'), 'help' => _('Defined in Apache configuration'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_PHP_INI', 'comment' => _('php.ini path'), 'help' => _('Empty if not used'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_imagine_driver', 'default' => '', 'comment' => _('Imagine driver'), 'help' => _(sprintf('See documentation at %s', $imagineDoc)), - 'available' => array( + 'available' => [ '' => 'Auto', 'gmagick' => 'GraphicsMagick', 'imagick' => 'ImageMagick', 'gd' => 'GD', - ) - ), - array( + ] + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ffmpeg_threads', 'comment' => _('Number of threads to use for FFMpeg'), 'default' => 2 - ), - array( + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_pdfmaxpages', 'comment' => _('Maximum number of pages to be extracted from PDF'), 'default' => 5 - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Main configuration'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_adminMail', 'comment' => _('Admin email'), 'default' => 'support@alchemy.fr' - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_view_bas_and_coll', 'comment' => _('Display the name of databases and collections'), 'default' => true, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_choose_export_title', 'comment' => _('Choose the title of the document to export'), 'default' => false, 'required' => true - ), - array( + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_default_export_title', 'comment' => _('Default export title'), 'default' => 'title', - 'available' => array( + 'available' => [ 'title' => _('Document title'), 'original' => _('Original name'), - ) - ), - array( + ] + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_social_tools', 'comment' => _('Enable this setting to share on Facebook and Twitter'), - 'available' => array( + 'available' => [ 'none' => _('Disabled'), 'publishers' => _('Publishers'), 'all' => _('Enabled'), - ), + ], 'default' => 'none', 'required' => false - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Homepage'), 'rolled' => true, - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_home_publi', 'comment' => _('Homepage slideshow'), 'default' => 'COOLIRIS', - 'available' => array( + 'available' => [ 'DISPLAYx1' => _('Single image'), 'SCROLL' => _('Slide show'), 'COOLIRIS' => 'Cooliris', 'CAROUSEL' => _('Carousel'), 'GALLERIA' => _('Gallery') - ), + ], 'required' => true - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Search engine'), 'rolled' => true, - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_min_letters_truncation', 'comment' => _('Minimum number of letters before truncation'), 'help' => _('Used in search engine'), 'default' => 1 - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_defaultQuery', 'comment' => _('Default query'), 'default' => 'all' - ), - array( + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_defaultQuery_type', 'comment' => _('Default searched type'), 'help' => _('Used when opening the application'), - 'available' => array( + 'available' => [ '0' => _('Documents'), '1' => _('Stories'), - ), + ], 'default' => '0' - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Report'), 'rolled' => true, - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_anonymousReport', 'comment' => _('Anonymous report'), 'help' => _('Hide information about users'), 'default' => false, 'required' => true - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Additionnal modules'), 'rolled' => true, - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_thesaurus', 'comment' => _('Enable thesaurus'), 'default' => true - ), array( + ], [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_multiAndReport', 'comment' => _('Enable multi-doc mode'), 'default' => true - ), array( + ], [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_seeOngChgDoc', 'comment' => _('Enable HD substitution'), 'default' => false - ), array( + ], [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_seeNewThumb', 'comment' => _('Enable thumbnail substitution'), 'default' => false - ) - ) - ) - , array( + ] + ] + ] + , [ 'section' => _('Emails'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_defaulmailsenderaddr', 'comment' => _('Default mail sender address'), 'default' => 'phraseanet@example.com' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_email_prefix', 'comment' => _('Prefix for notification emails'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_smtp', 'comment' => _('Use a SMTP server'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_smtp_auth', 'comment' => _('Enable SMTP authentication'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_host', 'comment' => _('SMTP host'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_port', 'comment' => _('SMTP port'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_smtp_secure', 'comment' => _('SMTP encryption'), 'default' => 'tls', - 'available' => array( + 'available' => [ 'none' => _('None'), 'ssl' => 'SSL', 'tls' => 'TLS' - ), - ), - array( + ], + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_user', 'comment' => _('SMTP user'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_password', 'comment' => _('SMTP password'), 'default' => '' - ) - ) - ), array( + ] + ] + ], [ 'section' => _('FTP Export'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_activeFTP', 'comment' => _('Enable FTP export'), 'help' => _('Available in multi-export tab'), 'default' => false - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_ftp_for_user', 'comment' => _('Enable FTP for users'), 'help' => _('By default it is available for admins'), 'default' => false - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Client'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_download_max', 'comment' => _('Maximum megabytes allowed for download'), 'help' => _('If request is bigger, then mail is still available'), 'default' => 120 - ), - array( + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_search', 'comment' => _('Search tab position'), 'default' => 1 - ), - array( + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_advsearch', 'comment' => _('Advanced search tab position'), 'default' => 2 - ), - array( + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_topics', 'comment' => _('Topics tab position'), 'default' => 0 - ), - array( + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_actif', 'comment' => _('Active tab position'), 'default' => 1 - ), - array( + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_client_render_topics', 'comment' => _('Topics display mode'), - 'available' => array( + 'available' => [ 'tree' => _('Trees'), 'popups' => _('Drop-down'), - ), + ], 'default' => 'tree' - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_rollover_reg_preview', 'comment' => _('Enable roll-over on stories'), 'default' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_rollover_chu', 'comment' => _('Enable roll-over on basket elements'), 'default' => true - ), - array( + ], + [ 'type' => \registry::TYPE_ENUM, 'name' => 'GV_client_coll_ckbox', 'comment' => _('Collections display mode'), 'default' => 'checkbox', - 'available' => array( + 'available' => [ 'popup' => _('Drop-down'), 'checkbox' => _('Check-box'), - ) - ), - array( + ] + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_viewSizeBaket', 'comment' => _('Display the total size of the document basket'), 'default' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_clientAutoShowProposals', 'comment' => _('Display proposals tab'), 'default' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_needAuth2DL', 'comment' => _('Require authentication to download documents'), 'help' => _('Used for guest account'), 'default' => true - ), - array( + ], + [ 'type' => 'boolean', 'name' => 'GV_requireTOUValidationForExport', 'comment' => _('Users must accept Terms of Use for each export'), 'default' => false - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Registration'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_autoselectDB', 'comment' => _('Auto select databases'), 'help' => _('This option disables the selecting of the databases on which a user can register himself, and registration is made on all granted databases.'), 'default' => true - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_autoregister', 'comment' => _('Enable auto registration'), 'default' => false - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Push configuration'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_validation_reminder', 'comment' => _('Number of days before the end of the validation to send a reminder email'), 'default' => 2 - ), - array( + ], + [ 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_val_expiration', 'comment' => _('Default validation links duration'), 'help' => _('If set to 0, duration is permanent'), 'default' => 10 - ) - ) - ), array( + ] + ] + ], [ 'section' => _('Robot indexing'), - 'vars' => array( - array( + 'vars' => [ + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_homeTitle', 'comment' => _('Application title'), 'default' => 'Phraseanet' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_metaKeywords', 'comment' => _('Keywords used for indexing purposes by search engines robots'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_TEXT, 'name' => 'GV_metaDescription', 'comment' => _('Application description'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_STRING, 'name' => 'GV_googleAnalytics', 'comment' => _('Google Analytics identifier'), 'default' => '' - ), - array( + ], + [ 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_allow_search_engine', 'comment' => _('Allow the website to be indexed by search engines like Google'), 'default' => true - ), - ) - ) - ); -}, array($app)); + ], + ] + ] + ]; +}, [$app]); diff --git a/lib/conf.d/minifyGroupsConfig.php b/lib/conf.d/minifyGroupsConfig.php index 727d5a35be..587e5672da 100644 --- a/lib/conf.d/minifyGroupsConfig.php +++ b/lib/conf.d/minifyGroupsConfig.php @@ -8,19 +8,19 @@ * You may wish to use the Minify URI Builder app to suggest * changes. http://yourdomain/min/builder/ * */ -$groups = array( - 'authentication_css' => array( +$groups = [ + 'authentication_css' => [ '//assets/normalize-css/normalize.css', '//assets/build/login.css', '//assets/font-awesome/css/font-awesome.css', '//assets/jquery.ui/themes/base/jquery.ui.autocomplete.css' - ), - 'authentication' => array( + ], + 'authentication' => [ '//assets/modernizr/modernizr.js', '//assets/requirejs/require.js', '//scripts/apps/login/home/config.js' - ), - 'client' => array( + ], + 'client' => [ '//assets/swfobject/swfobject.js' , '//assets/jquery.ui/i18n/jquery-ui-i18n.js' , '//assets/jquery.cookie/jquery.cookie.js' @@ -33,8 +33,8 @@ $groups = array( , '//include/jquery.tooltip.js' , '//include/jquery.p4.preview.js' , '//include/jquery.image_enhancer.js' - , '//include/jslibs/jquery.contextmenu_scroll.js'), - 'admin' => array( + , '//include/jslibs/jquery.contextmenu_scroll.js'], + 'admin' => [ '//assets/modernizr/modernizr.js' , '//assets/underscore-amd/underscore.js' , '//assets/jquery.cookie/jquery.cookie.js' @@ -51,8 +51,8 @@ $groups = array( , '//assets/blueimp-load-image/load-image.js' , '//assets/jquery-file-upload/jquery.iframe-transport.js' , '//assets/jquery-file-upload/jquery.fileupload.js' - ), - 'report' => array( + ], + 'report' => [ '//assets/jquery.ui/i18n/jquery-ui-i18n.js' , '//assets/jquery.cookie/jquery.cookie.js' , '//include/jquery.common.js' @@ -62,11 +62,11 @@ $groups = array( , '//include/jslibs/jquery.cluetip.js' , '//include/jquery.nicoslider.js' , '//skins/report/report.js' - ), - 'modalBox' => array( + ], + 'modalBox' => [ '//assets/jquery.ui/i18n/jquery-ui-i18n.js' - ), - 'prod' => array( + ], + 'prod' => [ '//assets/swfobject/swfobject.js' , '//assets/underscore-amd/underscore.js' , '//assets/json2/json2.js' @@ -105,8 +105,8 @@ $groups = array( , '//include/jquery.image_enhancer.js' , '//include/jslibs/jquery.contextmenu_scroll.js' , '//include/jslibs/jquery-treeview/jquery.treeview.js' - , '//include/jslibs/jquery-treeview/jquery.treeview.async.js'), - 'thesaurus' => array( + , '//include/jslibs/jquery-treeview/jquery.treeview.async.js'], + 'thesaurus' => [ '//assets/jquery.cookie/jquery.cookie.js' , '//include/jslibs/jquery.contextmenu_scroll.js' , '//include/jquery.common.js' @@ -114,8 +114,8 @@ $groups = array( , '//skins/thesaurus/xmlhttp.js' , '//skins/thesaurus/thesaurus.js' , '//skins/thesaurus/sprintf.js' - ), - 'lightbox' => array( + ], + 'lightbox' => [ '//include/jslibs/jquery.mousewheel.js' , '//include/jquery.tooltip.js' , '//assets/swfobject/swfobject.js' @@ -126,8 +126,8 @@ $groups = array( , '//skins/prod/jquery.Dialog.js' , '//skins/lightbox/jquery.lightbox.js' , '//include/jslibs/flowplayer/flowplayer-3.2.11.min.js' - ), - 'lightboxie6' => array( + ], + 'lightboxie6' => [ '//include/jslibs/jquery.mousewheel.js' , '//include/jquery.tooltip.js' , '//assets/swfobject/swfobject.js' @@ -138,11 +138,11 @@ $groups = array( , '//skins/prod/jquery.Dialog.js' , '//skins/lightbox/jquery.lightbox.ie6.js' , '//include/jslibs/flowplayer/flowplayer-3.2.11.min.js' - ), - 'uploadflash' => array( + ], + 'uploadflash' => [ '//include/jslibs/SWFUpload/swfupload.js' , '//include/jslibs/SWFUpload/plugins/swfupload.queue.js' - ) -); + ] +]; return $groups; diff --git a/lib/conf.d/plugins/twig-paths.php b/lib/conf.d/plugins/twig-paths.php index 76caea049b..1244a18051 100644 --- a/lib/conf.d/plugins/twig-paths.php +++ b/lib/conf.d/plugins/twig-paths.php @@ -3,5 +3,4 @@ // This file is automatically generated, please do not edit it. // To update configuration, use bin/console plugins:* commands. -return array( -); +return []; diff --git a/localesToLaunchPad.php b/localesToLaunchPad.php index d48541ec9d..5d21120950 100755 --- a/localesToLaunchPad.php +++ b/localesToLaunchPad.php @@ -22,9 +22,9 @@ $finder ->files() ->name('phraseanet.po') ->in( - array( + [ __DIR__ . '/locale', - ) + ] ) ; diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php index 0cae88a02f..91102f7e14 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php @@ -49,9 +49,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract * @var \API_OAuth2_Application */ protected static $adminApplication; - protected static $databoxe_ids = array(); + protected static $databoxe_ids = []; - abstract public function getParameters(array $parameters = array()); + abstract public function getParameters(array $parameters = []); abstract public function unserialize($data); @@ -144,7 +144,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract }); $this->setToken(self::$token); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $this->assertEquals(1, $preEvent); } @@ -153,26 +153,26 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract { $this->assertCount(0, self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findAll()); $this->setToken(self::$token); - self::$DI['client']->request('GET', '/api/v1/databoxes/list/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/databoxes/list/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $this->assertCount(0, self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findAll()); } public function provideEventNames() { - return array( - array(PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate', '/api/v1/databoxes/list/', Context::CONTEXT_OAUTH2_TOKEN), - array(PhraseaEvents::API_OAUTH2_START, 'Alchemy\Phrasea\Core\Event\ApiOAuth2StartEvent', '/api/v1/databoxes/list/', null), - array(PhraseaEvents::API_OAUTH2_END, 'Alchemy\Phrasea\Core\Event\ApiOAuth2EndEvent', '/api/v1/databoxes/list/', null), - array(PhraseaEvents::API_RESULT, 'Alchemy\Phrasea\Core\Event\ApiResultEvent', '/api/v1/databoxes/list/', null), - array(PhraseaEvents::API_RESULT, 'Alchemy\Phrasea\Core\Event\ApiResultEvent', '/api/v1/no-route', null), - ); + return [ + [PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate', '/api/v1/databoxes/list/', Context::CONTEXT_OAUTH2_TOKEN], + [PhraseaEvents::API_OAUTH2_START, 'Alchemy\Phrasea\Core\Event\ApiOAuth2StartEvent', '/api/v1/databoxes/list/', null], + [PhraseaEvents::API_OAUTH2_END, 'Alchemy\Phrasea\Core\Event\ApiOAuth2EndEvent', '/api/v1/databoxes/list/', null], + [PhraseaEvents::API_RESULT, 'Alchemy\Phrasea\Core\Event\ApiResultEvent', '/api/v1/databoxes/list/', null], + [PhraseaEvents::API_RESULT, 'Alchemy\Phrasea\Core\Event\ApiResultEvent', '/api/v1/no-route', null], + ]; } public function testRouteNotFound() { $route = '/api/v1/nothinghere'; $this->setToken(self::$token); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseNotFound(self::$DI['client']->getResponse()); @@ -187,7 +187,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract public function testDataboxListRoute() { $this->setToken(self::$token); - self::$DI['client']->request('GET', '/api/v1/databoxes/list/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/databoxes/list/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -223,7 +223,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $account = \API_OAuth2_Account::create(self::$DI['app'], self::$DI['user'], $nativeApp); $token = $account->get_token()->get_value(); $this->setToken($token); - self::$DI['client']->request('GET', '/api/v1/databoxes/list/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/databoxes/list/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); if (403 != $content['meta']['http_code']) { @@ -247,31 +247,31 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract { $this->setToken(self::$token); - self::$DI['client']->request('GET', '/api/v1/monitor/tasks/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/monitor/tasks/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); - self::$DI['client']->request('GET', '/api/v1/monitor/scheduler/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/monitor/scheduler/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); - self::$DI['client']->request('GET', '/api/v1/monitor/task/1/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/monitor/task/1/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); - self::$DI['client']->request('POST', '/api/v1/monitor/task/1/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', '/api/v1/monitor/task/1/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); - self::$DI['client']->request('POST', '/api/v1/monitor/task/1/start/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', '/api/v1/monitor/task/1/start/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); - self::$DI['client']->request('POST', '/api/v1/monitor/task/1/stop/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', '/api/v1/monitor/task/1/stop/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); - self::$DI['client']->request('GET', '/api/v1/monitor/phraseanet/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/monitor/phraseanet/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); } @@ -289,9 +289,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$adminToken); $route = '/api/v1/monitor/tasks/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -318,9 +318,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$adminToken); $route = '/api/v1/monitor/scheduler/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -373,10 +373,10 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertInternalType('integer', $task['pid']); } - $av_states = array( + $av_states = [ Task::STATUS_STARTED, Task::STATUS_STOPPED, - ); + ]; $this->assertContains($task['state'], $av_states); $this->assertInternalType('string', $task['name']); @@ -409,9 +409,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $idTask = $tasks[0]->getId(); $route = '/api/v1/monitor/task/' . $idTask . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -441,11 +441,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $idTask = $tasks[0]->getId(); $route = '/api/v1/monitor/task/' . $idTask . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['PUT', 'DELETE']); $title = 'newTitle' . mt_rand(); - self::$DI['client']->request('POST', $route, $this->getParameters(array('title' => $title)), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(['title' => $title]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -466,7 +466,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } $this->setToken(self::$adminToken); self::$DI['client']->followRedirects(); - self::$DI['client']->request('GET', '/api/v1/monitor/task/0/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/monitor/task/0/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateMetaNotFound($content); } @@ -492,9 +492,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $idTask = $tasks[0]->getId(); $route = '/api/v1/monitor/task/' . $idTask . '/start/'; - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -527,9 +527,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $idTask = $tasks[0]->getId(); $route = '/api/v1/monitor/task/' . $idTask . '/stop/'; - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -556,7 +556,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$adminToken); - self::$DI['client']->request('GET', '/api/v1/monitor/phraseanet/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', '/api/v1/monitor/phraseanet/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -579,8 +579,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -589,11 +589,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->evaluateGoodRecord($content['response']['record']); $route = '/api/v1/records/1234567890/1/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/records/kjslkz84spm/sfsd5qfsd5/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -613,8 +613,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract self::$DI['app']['session']->remove('usr_id'); $route = '/api/v1/stories/' . self::$DI['record_story_1']->get_sbas_id() . '/' . self::$DI['record_story_1']->get_record_id() . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -624,11 +624,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertGreaterThan(0, $content['response']['story']['records']); $route = '/api/v1/stories/1234567890/1/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/stories/kjslkz84spm/sfsd5qfsd5/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -641,9 +641,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); foreach (static::$databoxe_ids as $databox_id) { $route = '/api/v1/databoxes/' . $databox_id . '/collections/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - $crawler = self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -669,11 +669,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } } $route = '/api/v1/databoxes/24892534/collections/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/databoxes/any_bad_id/collections/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -687,9 +687,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $databox = self::$DI['app']['phraseanet.appbox']->get_databox($databox_id); $ref_status = $databox->get_statusbits(); $route = '/api/v1/databoxes/' . $databox_id . '/status/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - $crawler = self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -722,11 +722,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } } $route = '/api/v1/databoxes/24892534/status/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/databoxes/any_bad_id/status/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -749,9 +749,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } $route = '/api/v1/databoxes/' . $databox_id . '/metadatas/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - $crawler = self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -782,14 +782,14 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertTrue((strlen($metadatas['name']) > 0)); $this->assertTrue(is_string($metadatas['separator'])); - $this->assertEquals(array('fr', 'en', 'de', 'nl'), array_keys($metadatas['labels'])); + $this->assertEquals(['fr', 'en', 'de', 'nl'], array_keys($metadatas['labels'])); if ($metadatas['multivalue']) { $this->assertTrue((strlen($metadatas['separator']) > 0)); } $this->assertTrue(is_string($metadatas['thesaurus_branch'])); - $this->assertTrue(in_array($metadatas['type'], array(\databox_field::TYPE_DATE, \databox_field::TYPE_STRING, \databox_field::TYPE_NUMBER, \databox_field::TYPE_TEXT))); + $this->assertTrue(in_array($metadatas['type'], [\databox_field::TYPE_DATE, \databox_field::TYPE_STRING, \databox_field::TYPE_NUMBER, \databox_field::TYPE_TEXT])); $this->assertTrue(is_bool($metadatas['indexable'])); $this->assertTrue(is_bool($metadatas['multivalue'])); $this->assertTrue(is_bool($metadatas['readonly'])); @@ -810,11 +810,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } } $route = '/api/v1/databoxes/24892534/metadatas/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/databoxes/any_bad_id/metadatas/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -827,9 +827,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); foreach (static::$databoxe_ids as $databox_id) { $route = '/api/v1/databoxes/' . $databox_id . '/termsOfUse/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateMeta200($content); @@ -838,16 +838,16 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract foreach ($content['response']['termsOfUse'] as $terms) { $this->assertTrue(is_array($terms), 'Une bloc cgu est un objet'); $this->assertArrayHasKey('locale', $terms); - $this->assertTrue(in_array($terms['locale'], array('fr_FR', 'nl_NL', 'en_GB', 'ar_SA', 'de_DE', 'es_ES'))); + $this->assertTrue(in_array($terms['locale'], ['fr_FR', 'nl_NL', 'en_GB', 'ar_SA', 'de_DE', 'es_ES'])); $this->assertArrayHasKey('terms', $terms); } } $route = '/api/v1/databoxes/24892534/termsOfUse/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/databoxes/any_bad_id/termsOfUse/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -858,7 +858,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract public function testSearchRoute() { $this->setToken(self::$token); - $crawler = self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -894,7 +894,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract self::$DI['record_story_1']; - $crawler = self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(array('search_type' => 1)), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(['search_type' => 1]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -926,7 +926,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract public function testRecordsSearchRoute() { $this->setToken(self::$token); - $crawler = self::$DI['client']->request('POST', '/api/v1/records/search/', $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', '/api/v1/records/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -956,12 +956,12 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract ->disableOriginalConstructor() ->getMock() )); - $crawler = self::$DI['client']->request($method, '/api/v1/records/search/', $this->getParameters(array('query' => 'koala')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request($method, '/api/v1/records/search/', $this->getParameters(['query' => 'koala']), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); } public function provideAvailableSearchMethods() { - return array(array('POST'), array('GET')); + return [['POST'], ['GET']]; } /** @@ -974,9 +974,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->injectMetadatas(self::$DI['record_1']); $route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/caption/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -985,11 +985,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->evaluateRecordsCaptionResponse($content); $route = '/api/v1/records/24892534/51654651553/caption/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/records/any_bad_id/sfsd5qfsd5/caption/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -1001,9 +1001,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/metadatas/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1012,11 +1012,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->evaluateRecordsMetadataResponse($content); $route = '/api/v1/records/24892534/51654651553/metadatas/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/records/any_bad_id/sfsd5qfsd5/metadatas/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -1027,9 +1027,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/status/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1038,11 +1038,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->evaluateRecordsStatusResponse(self::$DI['record_1'], $content); $route = '/api/v1/records/24892534/51654651553/status/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/records/any_bad_id/sfsd5qfsd5/status/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -1057,9 +1057,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $keys = array_keys($this->record->get_subdefs()); $route = '/api/v1/records/' . $this->record->get_sbas_id() . '/' . $this->record->get_record_id() . '/embed/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1071,11 +1071,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->checkEmbed($embed, $this->record); } $route = '/api/v1/records/24892534/51654651553/embed/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/records/any_bad_id/sfsd5qfsd5/embed/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -1095,9 +1095,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $keys = array_keys($story->get_subdefs()); $route = '/api/v1/stories/' . $story->get_sbas_id() . '/' . $story->get_record_id() . '/embed/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1109,11 +1109,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->checkEmbed($embed, $story); } $route = '/api/v1/stories/24892534/51654651553/embed/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/stories/any_bad_id/sfsd5qfsd5/embed/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $story->delete(); } @@ -1126,7 +1126,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/records/' . $this->record->get_sbas_id() . '/' . $this->record->get_record_id() . '/embed/'; - self::$DI['client']->request('GET', $route, $this->getParameters(array('mimes' => array('image/jpg', 'image/jpeg'))), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(['mimes' => ['image/jpg', 'image/jpeg']]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertArrayHasKey('embed', $content['response']); @@ -1145,7 +1145,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/'; - self::$DI['client']->request('GET', $route, $this->getParameters(array('devices' => array('nodevice'))), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(['devices' => ['nodevice']]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertEquals(0, count($content['response']['embed'])); @@ -1159,9 +1159,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/related/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1173,11 +1173,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } $route = '/api/v1/records/24892534/51654651553/related/'; - $this->evaluateNotFoundRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateNotFoundRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); $route = '/api/v1/records/any_bad_id/sfsd5qfsd5/related/'; - $this->evaluateBadRequestRoute($route, array('GET')); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateBadRequestRoute($route, ['GET']); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); } /** @@ -1195,7 +1195,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setmetadatas/'; $caption = $record->get_caption(); - $toupdate = array(); + $toupdate = []; foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) { try { @@ -1206,16 +1206,16 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $meta_id = null; } - $toupdate[$field->get_id()] = array( + $toupdate[$field->get_id()] = [ 'meta_id' => $meta_id , 'meta_struct_id' => $field->get_id() , 'value' => 'podom pom pom ' . $field->get_id() - ); + ]; } - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(array('metadatas' => $toupdate)), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(['metadatas' => $toupdate]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1256,13 +1256,13 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $record_status = strrev(self::$DI['record_1']->get_status()); $status_bits = self::$DI['record_1']->get_databox()->get_statusbits(); - $tochange = array(); + $tochange = []; foreach ($status_bits as $n => $datas) { $tochange[$n] = substr($record_status, ($n - 1), 1) == '0' ? '1' : '0'; } - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(array('status' => $tochange)), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(['status' => $tochange]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); /** @@ -1284,7 +1284,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $tochange[$n] = $value == '0' ? '1' : '0'; } - $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(array('status' => $tochange)), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(['status' => $tochange]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); /** @@ -1326,9 +1326,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->markTestSkipped('No collection'); } - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(array('base_id' => $base_id)), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(['base_id' => $base_id]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1346,13 +1346,13 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract { $this->insertFiveBasket(); $this->insertOneValidationBasket(); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->setToken(self::$adminToken); $route = '/api/v1/baskets/list/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1374,9 +1374,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/baskets/add/'; - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(array('name' => 'un Joli Nom')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(['name' => 'un Joli Nom']), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1402,9 +1402,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/baskets/' . $basket->getId() . '/content/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1441,9 +1441,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/baskets/' . $basket->getId() . '/setname/'; - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(array('name' => 'un Joli Nom')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(['name' => 'un Joli Nom']), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1455,7 +1455,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertEquals($content['response']['basket']['name'], 'un Joli Nom'); - $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(array('name' => 'un Joli Nom')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(['name' => 'un Joli Nom']), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1469,7 +1469,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertEquals($content['response']['basket']['name'], 'un Joli Nom'); - $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(array('name' => 'aéaa')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request('POST', $route, $this->getParameters(['name' => 'aéaa']), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1494,9 +1494,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/baskets/' . $basket->getId() . '/setdescription/'; - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(array('description' => 'une belle desc')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(['description' => 'une belle desc']), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1520,9 +1520,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $route = '/api/v1/baskets/' . $baskets[0]->getId() . '/delete/'; - $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); - self::$DI['client']->request('POST', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1552,7 +1552,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $params = $this->getAddRecordParameters(); $params['status'] = '0b10000'; - self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1575,7 +1575,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $params = $this->getAddRecordParameters(); $params['forceBehavior'] = '0'; - self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1604,7 +1604,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $params = $this->getAddRecordParameters(); $params['forceBehavior'] = '1'; - self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1631,7 +1631,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $params = $this->getAddRecordParameters(); $params['forceBehavior'] = '2'; - self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseBadRequest(self::$DI['client']->getResponse()); @@ -1649,7 +1649,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $params = $this->getAddRecordParameters(); $params['base_id'] = self::$DI['collection_no_access']->get_base_id(); - self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseForbidden(self::$DI['client']->getResponse()); @@ -1667,7 +1667,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $params = $this->getAddRecordParameters(); unset($params['base_id']); - self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($params), $this->getAddRecordFile(), ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseBadRequest(self::$DI['client']->getResponse()); @@ -1682,12 +1682,12 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/records/add/'; - $file = array( + $file = [ new \Symfony\Component\HttpFoundation\File\UploadedFile(__FILE__, 'upload.txt'), new \Symfony\Component\HttpFoundation\File\UploadedFile(__FILE__, 'upload.txt'), - ); + ]; - self::$DI['client']->request('POST', $route, $this->getParameters($this->getAddRecordParameters()), array('file' => $file), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($this->getAddRecordParameters()), ['file' => $file], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseBadRequest(self::$DI['client']->getResponse()); @@ -1699,7 +1699,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/records/add/'; - self::$DI['client']->request('POST', $route, $this->getParameters($this->getAddRecordParameters()), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('POST', $route, $this->getParameters($this->getAddRecordParameters()), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseBadRequest(self::$DI['client']->getResponse()); @@ -1719,9 +1719,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/feeds/list/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1777,9 +1777,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/feeds/content/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1832,9 +1832,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/feeds/entry/' . $created_entry->getId() . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1873,9 +1873,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$adminToken); $route = '/api/v1/feeds/entry/' . $created_entry->getId() . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseForbidden(self::$DI['client']->getResponse()); @@ -1909,9 +1909,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->setToken(self::$token); $route = '/api/v1/feeds/' . $created_feed->getId() . '/content/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponse200(self::$DI['client']->getResponse()); @@ -1950,9 +1950,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $quarantineItemId = $this->getQuarantineItem()->getId(); - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertArrayHasKey('offset_start', $content['response']); @@ -1983,9 +1983,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $quarantineItemId = $this->getQuarantineItem()->getId(); $route = '/api/v1/quarantine/item/' . $quarantineItemId . '/'; - $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']); - self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertArrayHasKey('quarantine_item', $content['response']); @@ -2091,9 +2091,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract protected function getAddRecordParameters() { - return array( + return [ 'base_id' => self::$DI['collection']->get_base_id() - ); + ]; } protected function getAddRecordFile() @@ -2101,9 +2101,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $file = tempnam(sys_get_temp_dir(), 'upload'); copy(__DIR__ . '/../../../../files/iphone_pic.jpg', $file); - return array( + return [ 'file' => new \Symfony\Component\HttpFoundation\File\UploadedFile($file, 'upload.jpg') - ); + ]; } protected function checkLazaretFile($file) @@ -2147,7 +2147,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract protected function evaluateNotFoundRoute($route, $methods) { foreach ($methods as $method) { - $crawler = self::$DI['client']->request($method, $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request($method, $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseNotFound(self::$DI['client']->getResponse()); @@ -2262,7 +2262,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract protected function evaluateMethodNotAllowedRoute($route, $methods) { foreach ($methods as $method) { - $crawler = self::$DI['client']->request($method, $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $crawler = self::$DI['client']->request($method, $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->assertTrue(self::$DI['client']->getResponse()->headers->has('Allow')); $this->evaluateResponseMethodNotAllowed(self::$DI['client']->getResponse()); @@ -2273,7 +2273,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract protected function evaluateBadRequestRoute($route, $methods) { foreach ($methods as $method) { - self::$DI['client']->request($method, $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + self::$DI['client']->request($method, $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $this->evaluateResponseBadRequest(self::$DI['client']->getResponse()); $this->evaluateMetaBadRequest($content); @@ -2408,7 +2408,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertArrayHasKey('technical_informations', $record); $this->assertArrayHasKey('phrasea_type', $record); $this->assertTrue(is_string($record['phrasea_type'])); - $this->assertTrue(in_array($record['phrasea_type'], array('audio', 'document', 'image', 'video', 'flash', 'unknown'))); + $this->assertTrue(in_array($record['phrasea_type'], ['audio', 'document', 'image', 'video', 'flash', 'unknown'])); $this->assertArrayHasKey('uuid', $record); $this->assertTrue(\uuid::is_valid($record['uuid'])); @@ -2538,7 +2538,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertArrayHasKey('labels', $meta); $this->assertTrue(is_array($meta['labels'])); - $this->assertEquals(array('fr', 'en', 'de', 'nl'), array_keys($meta['labels'])); + $this->assertEquals(['fr', 'en', 'de', 'nl'], array_keys($meta['labels'])); if (is_array($meta['value'])) { foreach ($meta['value'] as $val) { @@ -2581,11 +2581,11 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $meta_id = null; } - $toupdate[$field->get_id()] = array( + $toupdate[$field->get_id()] = [ 'meta_id' => $meta_id , 'meta_struct_id' => $field->get_id() , 'value' => 'podom pom pom ' . $field->get_id() - ); + ]; } $record->set_metadatas($toupdate); diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiJSONPTest.php b/tests/Alchemy/Tests/Phrasea/Application/ApiJSONPTest.php index 71fa87ae1b..c3b340f6db 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiJSONPTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiJSONPTest.php @@ -31,7 +31,7 @@ class ApiJSONPApplication extends ApiAbstract $this->assertEquals(200, $response->getStatusCode(), 'Test status code 405 ' . $response->getContent()); } - public function getParameters(array $parameters = array()) + public function getParameters(array $parameters = []) { $parameters['callback'] = 'jsFunction'; diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiJsonTest.php b/tests/Alchemy/Tests/Phrasea/Application/ApiJsonTest.php index a817e84f18..2ebc1eb223 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiJsonTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiJsonTest.php @@ -5,7 +5,7 @@ namespace Alchemy\Tests\Phrasea\Application; class ApiJsonApplication extends ApiAbstract { - public function getParameters(array $parameters = array()) + public function getParameters(array $parameters = []) { return $parameters; } diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiYamlTest.php b/tests/Alchemy/Tests/Phrasea/Application/ApiYamlTest.php index 39ac6a3f2a..fc185682ea 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiYamlTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiYamlTest.php @@ -5,7 +5,7 @@ namespace Alchemy\Tests\Phrasea\Application; class ApiYamlApplication extends ApiAbstract { - public function getParameters(array $parameters = array()) + public function getParameters(array $parameters = []) { return $parameters; } diff --git a/tests/Alchemy/Tests/Phrasea/Application/ConsoleAPITest.php b/tests/Alchemy/Tests/Phrasea/Application/ConsoleAPITest.php index 8451a40646..a3f8d299b1 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ConsoleAPITest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ConsoleAPITest.php @@ -19,10 +19,10 @@ class ConsoleAPITest extends \PHPUnit_Framework_TestCase public function provideConsoleNames() { - return array( - array('console'), - array('setup'), - array('developer'), - ); + return [ + ['console'], + ['setup'], + ['developer'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php b/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php index 1086d272b8..ca2060614e 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php @@ -273,7 +273,7 @@ class LightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $crawler = self::$DI['client']->request( 'POST' , '/lightbox/ajax/SET_NOTE/' . $validationBasketElement->getId() . '/' - , array('note' => 'une jolie note') + , ['note' => 'une jolie note'] ); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId())); @@ -299,7 +299,7 @@ class LightboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $crawler = self::$DI['client']->request( 'POST' , '/lightbox/ajax/SET_ELEMENT_AGREEMENT/' . $validationBasketElement->getId() . '/' - , array('agreement' => 1) + , ['agreement' => 1] ); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode(), sprintf('set note to element %s ', $validationBasketElement->getId())); diff --git a/tests/Alchemy/Tests/Phrasea/Application/OAuth2Test.php b/tests/Alchemy/Tests/Phrasea/Application/OAuth2Test.php index 93cacaa99d..26e71c9daa 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/OAuth2Test.php +++ b/tests/Alchemy/Tests/Phrasea/Application/OAuth2Test.php @@ -51,13 +51,13 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra $environment = 'test'; self::$DI['app'] = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Api.php'; - $this->queryParameters = array( + $this->queryParameters = [ "response_type" => "code", "client_id" => self::$appli->get_client_id(), "redirect_uri" => self::$appli->get_redirect_uri(), "scope" => "", "state" => "valueTest" - ); + ]; } public static function deleteInsertedRow(\appbox $appbox, \API_OAuth2_Application $app) @@ -67,7 +67,7 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra DELETE FROM api_applications WHERE application_id = :id '; - $t = array(':id' => $app->get_id()); + $t = [':id' => $app->get_id()]; $stmt = $conn->prepare($sql); $stmt->execute($t); $sql = ' @@ -75,7 +75,7 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra WHERE api_account_id = :id '; $acc = self::getAccount(); - $t = array(':id' => $acc->get_id()); + $t = [':id' => $acc->get_id()]; $stmt = $conn->prepare($sql); $stmt->execute($t); } @@ -103,18 +103,18 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra public function provideEventNames() { - return array( - array(false, 'POST', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'), - array(true, 'POST', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'), - array(false, 'GET', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'), - array(true, 'GET', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'), - ); + return [ + [false, 'POST', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'], + [true, 'POST', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'], + [false, 'GET', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'], + [true, 'GET', PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate'], + ]; } public static function getApp($rowId) { $sql = "SELECT * FROM api_applications WHERE application_id = :app_id"; - $t = array(":app_id" => $rowId); + $t = [":app_id" => $rowId]; $conn = self::$DI['app']['phraseanet.appbox']->get_connection(); $stmt = $conn->prepare($sql); $stmt->execute($t); @@ -126,7 +126,7 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra public static function getAccount() { $sql = "SELECT api_account_id FROM api_accounts WHERE application_id = :app_id AND usr_id = :usr_id"; - $t = array(":app_id" => self::$appli->get_id(), ":usr_id" => self::$DI['user']->get_id()); + $t = [":app_id" => self::$appli->get_id(), ":usr_id" => self::$DI['user']->get_id()]; $conn = self::$DI['app']['phraseanet.appbox']->get_connection(); $stmt = $conn->prepare($sql); $stmt->execute($t); diff --git a/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php b/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php index 2d9d1d0904..54f06d15e0 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php @@ -83,33 +83,33 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPermalinkAuthenticated() { $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); - $this->get_a_permalinkBCcompatibility(array("Content-Type" => "image/jpeg")); - $this->get_a_permaviewBCcompatibility(array("Content-Type" => "text/html; charset=UTF-8")); - $this->get_a_permalink(array("Content-Type" => "image/jpeg")); - $this->get_a_permaview(array("Content-Type" => "text/html; charset=UTF-8")); + $this->get_a_permalinkBCcompatibility(["Content-Type" => "image/jpeg"]); + $this->get_a_permaviewBCcompatibility(["Content-Type" => "text/html; charset=UTF-8"]); + $this->get_a_permalink(["Content-Type" => "image/jpeg"]); + $this->get_a_permaview(["Content-Type" => "text/html; charset=UTF-8"]); } public function testPermalinkNotAuthenticated() { self::$DI['app']['authentication']->closeAccount(); $this->assertFalse(self::$DI['app']['authentication']->isAuthenticated()); - $this->get_a_permalinkBCcompatibility(array("Content-Type" => "image/jpeg")); - $this->get_a_permaviewBCcompatibility(array("Content-Type" => "text/html; charset=UTF-8")); - $this->get_a_permalink(array("Content-Type" => "image/jpeg")); - $this->get_a_permaview(array("Content-Type" => "text/html; charset=UTF-8")); + $this->get_a_permalinkBCcompatibility(["Content-Type" => "image/jpeg"]); + $this->get_a_permaviewBCcompatibility(["Content-Type" => "text/html; charset=UTF-8"]); + $this->get_a_permalink(["Content-Type" => "image/jpeg"]); + $this->get_a_permaview(["Content-Type" => "text/html; charset=UTF-8"]); } public function testCaptionAuthenticated() { $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); - $this->get_a_caption(array("Content-Type" => "application/json")); + $this->get_a_caption(["Content-Type" => "application/json"]); } public function testCaptionNotAuthenticated() { self::$DI['app']['authentication']->closeAccount(); $this->assertFalse(self::$DI['app']['authentication']->isAuthenticated()); - $this->get_a_caption(array("Content-Type" => "application/json")); + $this->get_a_caption(["Content-Type" => "application/json"]); } public function testCaptionWithaWrongToken() @@ -167,7 +167,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, $response->getStatusCode()); } - protected function get_a_caption(array $headers = array()) + protected function get_a_caption(array $headers = []) { $token = self::$DI['record_1']->get_thumbnail()->get_permalink()->get_token(); $url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . "/" . self::$DI['record_1']->get_record_id() . '/caption/?token='.$token; @@ -184,7 +184,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, $response->getStatusCode()); } - protected function get_a_permalinkBCcompatibility(array $headers = array()) + protected function get_a_permalinkBCcompatibility(array $headers = []) { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $url = '/permalink/v1/whateverIwannt/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/' . $token . '/preview/'; @@ -210,7 +210,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); } - protected function get_a_permaviewBCcompatibility(array $headers = array()) + protected function get_a_permaviewBCcompatibility(array $headers = []) { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $url = '/permalink/v1/whateverIwannt/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/' . $token . '/preview/'; @@ -226,7 +226,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, $response->getStatusCode()); } - protected function get_a_permalink(array $headers = array()) + protected function get_a_permalink(array $headers = []) { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/whateverIwannt.jpg?token=' . $token . ''; @@ -242,7 +242,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, $response->getStatusCode()); } - protected function get_a_permaview(array $headers = array()) + protected function get_a_permaview(array $headers = []) { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/?token=' . $token . ''; diff --git a/tests/Alchemy/Tests/Phrasea/Application/RootApplicationTest.php b/tests/Alchemy/Tests/Phrasea/Application/RootApplicationTest.php index 3dbba0d8ec..3cd426adbc 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/RootApplicationTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/RootApplicationTest.php @@ -17,11 +17,11 @@ class RootApplicationTest extends \PHPUnit_Framework_TestCase public function provideEnvironments() { - return array( - array(Application::ENV_PROD), - array(Application::ENV_TEST), - array(Application::ENV_DEV), - ); + return [ + [Application::ENV_PROD], + [Application::ENV_TEST], + [Application::ENV_DEV], + ]; } public function testWebProfilerDisableInProdEnv() diff --git a/tests/Alchemy/Tests/Phrasea/ApplicationTest.php b/tests/Alchemy/Tests/Phrasea/ApplicationTest.php index 39bc0543b4..7c86b232ac 100644 --- a/tests/Alchemy/Tests/Phrasea/ApplicationTest.php +++ b/tests/Alchemy/Tests/Phrasea/ApplicationTest.php @@ -100,10 +100,10 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract public function provideDisabledRoutes() { - return array( - array(true, '/api/v1/'), - array(false, '/'), - ); + return [ + [true, '/api/v1/'], + [false, '/'], + ]; } /** @@ -111,7 +111,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract */ public function testCookieLocale() { - foreach (array('fr_FR', 'en_GB', 'de_DE') as $locale) { + foreach (['fr_FR', 'en_GB', 'de_DE'] as $locale) { $client = $this->getClientWithCookie( $this->getAppThatReturnLocale(), $locale); $client->request('GET', '/'); @@ -128,7 +128,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $this->mockRegistryAndReturnLocale($app, 'en_USA'); $client = $this->getClientWithCookie($app, null); - $client->request('GET', '/', array(), array(), array('HTTP_ACCEPT_LANGUAGE' => '')); + $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => '']); $this->assertEquals('en_USA', $client->getResponse()->getContent()); } @@ -142,7 +142,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $this->mockRegistryAndReturnLocale($app, 'en_USA'); $client = $this->getClientWithCookie($app, 'de_PL'); - $client->request('GET', '/', array(), array(), array('HTTP_ACCEPT_LANGUAGE' => '')); + $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => '']); $this->assertEquals('en_USA', $client->getResponse()->getContent()); } @@ -160,7 +160,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $client = new Client($app); - $client->request('POST', '/prod/upload/', array('php_session_id'=>'123456'), array(), array('HTTP_USER_AGENT'=>'flash')); + $client->request('POST', '/prod/upload/', ['php_session_id'=>'123456'], [], ['HTTP_USER_AGENT'=>'flash']); $this->assertEquals('123456', $sessionId); } @@ -178,7 +178,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $generator->expects($this->once()) ->method('generate') - ->with($this->equalTo($route), $this->equalTo(array()), $this->equalTo(UrlGenerator::ABSOLUTE_PATH)) + ->with($this->equalTo($route), $this->equalTo([]), $this->equalTo(UrlGenerator::ABSOLUTE_PATH)) ->will($this->returnValue($ret)); $this->assertEquals($ret, $app->path($route)); @@ -198,7 +198,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $generator->expects($this->once()) ->method('generate') - ->with($this->equalTo($route), $this->equalTo(array()), $this->equalTo(UrlGenerator::ABSOLUTE_URL)) + ->with($this->equalTo($route), $this->equalTo([]), $this->equalTo(UrlGenerator::ABSOLUTE_URL)) ->will($this->returnValue($ret)); $this->assertEquals($ret, $app->url($route)); @@ -216,8 +216,8 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract ->getMock(); $type = $this->getMock('Symfony\Component\Form\FormTypeInterface'); - $data = array('some' => 'data'); - $options = array(); + $data = ['some' => 'data']; + $options = []; $parent = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') ->disableOriginalConstructor() @@ -235,11 +235,11 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract { $app = new Application('test'); - $this->assertEquals(array(), $app->getFlash('info')); - $this->assertEquals(array('BOUM'), $app->getFlash('info', array('BOUM'))); + $this->assertEquals([], $app->getFlash('info')); + $this->assertEquals(['BOUM'], $app->getFlash('info', ['BOUM'])); $app->addFlash('success', 'BAMBA'); - $this->assertEquals(array('BAMBA'), $app->getFlash('success')); + $this->assertEquals(['BAMBA'], $app->getFlash('success')); } /** @@ -298,7 +298,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $app['configuration']->expects($this->once()) ->method('offsetGet') ->with('main') - ->will($this->returnValue(array('servername' => 'https://cat.turbocat.com/'))); + ->will($this->returnValue(['servername' => 'https://cat.turbocat.com/'])); $this->assertEquals('https', $app['url_generator']->getContext()->getScheme()); $this->assertEquals('cat.turbocat.com', $app['url_generator']->getContext()->getHost()); @@ -384,7 +384,7 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract $cookieJar->set(new BrowserCookie('locale', $locale)); } - return new Client($app, array(), null, $cookieJar); + return new Client($app, [], null, $cookieJar); } } @@ -400,6 +400,6 @@ class TestExceptionHandlerSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 0)); + return [KernelEvents::EXCEPTION => ['onSilexError', 0]]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php index 19f87aea71..9411f924f5 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php @@ -14,17 +14,17 @@ class AccountCreatorTest extends \PhraseanetPHPUnitAbstract $random = $this->createRandomMock(); $appbox = $this->createAppboxMock(); - $creator = new AccountCreator($random, $appbox, $enabled, array()); + $creator = new AccountCreator($random, $appbox, $enabled, []); $this->assertSame($enabled, $creator->isEnabled()); } public function provideEnabledOptions() { - return array( - array(true), - array(false), - ); + return [ + [true], + [false], + ]; } /** @@ -35,7 +35,7 @@ class AccountCreatorTest extends \PhraseanetPHPUnitAbstract $random = $this->createRandomMock(); $appbox = $this->createAppboxMock(); - $creator = new AccountCreator($random, $appbox, true, array()); + $creator = new AccountCreator($random, $appbox, true, []); $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword(), self::$DI['user']->get_email()); } @@ -47,13 +47,13 @@ class AccountCreatorTest extends \PhraseanetPHPUnitAbstract $random = $this->createRandomMock(); $appbox = $this->createAppboxMock(); - $creator = new AccountCreator($random, $appbox, false, array()); + $creator = new AccountCreator($random, $appbox, false, []); $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword()); } public function testCreateWithoutTemplates() { - $creator = new AccountCreator(self::$DI['app']['tokens'], self::$DI['app']['phraseanet.appbox'], true, array()); + $creator = new AccountCreator(self::$DI['app']['tokens'], self::$DI['app']['phraseanet.appbox'], true, []); $user = $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword()); $this->assertInstanceOf('User_Adapter', $user); @@ -70,8 +70,8 @@ class AccountCreatorTest extends \PhraseanetPHPUnitAbstract $template3 = \User_Adapter::create(self::$DI['app'], 'template' . $random->generatePassword(), $random->generatePassword(), null, false); $template3->set_template(self::$DI['user']); - $templates = array($template1, $template2); - $extra = array($template3); + $templates = [$template1, $template2]; + $extra = [$template3]; $creator = new AccountCreator($random, self::$DI['app']['phraseanet.appbox'], true, $templates); $user = $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword(), null, $extra); @@ -85,7 +85,7 @@ class AccountCreatorTest extends \PhraseanetPHPUnitAbstract public function testCreateWithAlreadyExistingLogin() { - $creator = new AccountCreator(self::$DI['app']['tokens'], self::$DI['app']['phraseanet.appbox'], true, array()); + $creator = new AccountCreator(self::$DI['app']['tokens'], self::$DI['app']['phraseanet.appbox'], true, []); $user = $creator->create(self::$DI['app'], self::$DI['user']->get_login()); $this->assertInstanceOf('User_Adapter', $user); diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php index c58cb1010a..0bc71f39d1 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php @@ -94,7 +94,7 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract ->getMock(); $acl->expects($this->once()) ->method('get_granted_sbas') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider') ->disableOriginalConstructor() @@ -151,7 +151,7 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract $repo->expects($this->once()) ->method('findOneBy') - ->with($this->equalTo(array('id' => $session->getId()))) + ->with($this->equalTo(['id' => $session->getId()])) ->will($this->returnValue($session)); $em->expects($this->once()) @@ -193,7 +193,7 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract $repo->expects($this->once()) ->method('findOneBy') - ->with($this->equalTo(array('id' => $session->getId()))) + ->with($this->equalTo(['id' => $session->getId()])) ->will($this->returnValue(null)); $em->expects($this->once()) diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/ManagerTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/ManagerTest.php index 257c2c0104..5393ca82ce 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/ManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/ManagerTest.php @@ -38,7 +38,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $providers = $this->getProvidersMock(); $providerName = 'roro-provider'; - $parameters = array('key' => 'value'); + $parameters = ['key' => 'value']; $provider = $this->getMock('Alchemy\Phrasea\Authentication\Provider\ProviderInterface'); $providers->expects($this->once()) diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/PersistentCookie/ManagerTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/PersistentCookie/ManagerTest.php index e373c2f98c..ab2255d474 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/PersistentCookie/ManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/PersistentCookie/ManagerTest.php @@ -36,7 +36,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $repo->expects($this->once()) ->method('findOneBy') - ->with($this->equalTo(array('token' => $tokenValue))) + ->with($this->equalTo(['token' => $tokenValue])) ->will($this->returnValue($session)); $em->expects($this->once()) @@ -81,7 +81,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $repo->expects($this->once()) ->method('findOneBy') - ->with($this->equalTo(array('token' => $tokenValue))) + ->with($this->equalTo(['token' => $tokenValue])) ->will($this->returnValue($session)); $em->expects($this->once()) @@ -114,7 +114,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $repo->expects($this->once()) ->method('findOneBy') - ->with($this->equalTo(array('token' => $tokenValue))) + ->with($this->equalTo(['token' => $tokenValue])) ->will($this->returnValue(null)); $em->expects($this->once()) diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/FailureManagerTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/FailureManagerTest.php index ba63bc3553..7177bfcd55 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/FailureManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/FailureManagerTest.php @@ -26,10 +26,10 @@ class FailureManagerTest extends \PhraseanetPHPUnitAbstract ->method('getClientIp') ->will($this->returnValue($ip)); - $oldFailures = array( + $oldFailures = [ $this->getMock('Alchemy\Phrasea\Model\Entities\AuthFailure'), $this->getMock('Alchemy\Phrasea\Model\Entities\AuthFailure') - ); + ]; $repo->expects($this->once()) ->method('findOldFailures') @@ -67,7 +67,7 @@ class FailureManagerTest extends \PhraseanetPHPUnitAbstract $username = 'romainneutron'; - $oldFailures = array(); + $oldFailures = []; $repo->expects($this->once()) ->method('findLockedFailuresMatching') @@ -293,7 +293,7 @@ class FailureManagerTest extends \PhraseanetPHPUnitAbstract private function ArrayIze($failure, $n) { - $failures = array(); + $failures = []; for ($i = 0; $i != $n; $i++) { $failures[] = $failure(); diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/NativeAuthenticationTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/NativeAuthenticationTest.php index 9b3665ba53..931830a766 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/NativeAuthenticationTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/NativeAuthenticationTest.php @@ -25,10 +25,10 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase public function provideReservedUsernames() { - return array( - array('autoregister'), - array('invite'), - ); + return [ + ['autoregister'], + ['invite'], + ]; } public function testNotFoundIsNotValid() @@ -52,13 +52,13 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $encoder = $this->getEncoderMock(); $oldEncoder = $this->getOldEncoderMock(); - $conn = $this->getConnectionMock($username, array( + $conn = $this->getConnectionMock($username, [ 'nonce' => 'dfqsdgqsd', 'salted_password' => '1', 'mail_locked' => '1', 'usr_id' => '1', 'usr_password' => 'qsdfsqdfqsd', - )); + ]); $request = $this->getRequestMock(); $auth = new NativeAuthentication($encoder, $oldEncoder, $conn); @@ -81,13 +81,13 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $encoder = $this->getEncoderMock(); $oldEncoder = $this->getOldEncoderMock(); - $conn = $this->getConnectionMock($username, array( + $conn = $this->getConnectionMock($username, [ 'nonce' => $nonce, 'salted_password' => '1', 'mail_locked' => '0', 'usr_id' => $usr_id, 'usr_password' => $encoded, - )); + ]); $request = $this->getRequestMock(); $oldEncoder->expects($this->never()) @@ -113,13 +113,13 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $encoder = $this->getEncoderMock(); $oldEncoder = $this->getOldEncoderMock(); - $conn = $this->getConnectionMock($username, array( + $conn = $this->getConnectionMock($username, [ 'nonce' => $nonce, 'salted_password' => '1', 'mail_locked' => '0', 'usr_id' => $usr_id, 'usr_password' => $encoded, - )); + ]); $request = $this->getRequestMock(); $oldEncoder->expects($this->never()) @@ -145,13 +145,13 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $encoder = $this->getEncoderMock(); $oldEncoder = $this->getOldEncoderMock(); - $conn = $this->getConnectionMock($username, array( + $conn = $this->getConnectionMock($username, [ 'nonce' => $nonce, 'salted_password' => '0', 'mail_locked' => '0', 'usr_id' => $usr_id, 'usr_password' => $encoded, - )); + ]); $request = $this->getRequestMock(); $oldEncoder->expects($this->once()) @@ -186,17 +186,17 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $statement ->expects($this->once()) ->method('execute') - ->with($this->equalTo(array(':login' => $username))); + ->with($this->equalTo([':login' => $username])); $statement->expects($this->once()) ->method('fetch') ->with($this->equalTo(\PDO::FETCH_ASSOC)) - ->will($this->returnValue(array( + ->will($this->returnValue([ 'nonce' => $nonce, 'salted_password' => '0', 'mail_locked' => '0', 'usr_id' => $usr_id, 'usr_password' => $encoded, - ))); + ])); $catchParameters = $catchTestPassword = null; @@ -228,11 +228,11 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $encoder->expects($this->once()) ->method('isPasswordValid') ->will($this->returnCallback(function ($encoded, $pass, $nonce) use (&$catchTestPassword) { - $catchTestPassword = array( + $catchTestPassword = [ 'encoded' => $encoded, 'pass' => $pass, 'nonce' => $nonce, - ); + ]; return true; })); @@ -255,7 +255,7 @@ class NativeAuthenticationTest extends \PHPUnit_Framework_TestCase $statement ->expects($this->once()) ->method('execute') - ->with($this->equalTo(array(':login' => $username))); + ->with($this->equalTo([':login' => $username])); $statement->expects($this->once()) ->method('fetch') diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/OldPasswordEncoderTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/OldPasswordEncoderTest.php index 921803ee31..1cfb1448bf 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/OldPasswordEncoderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/OldPasswordEncoderTest.php @@ -38,11 +38,11 @@ class OldPasswordEncoderTest extends \PHPUnit_Framework_TestCase public function providePasswords() { - return array( - array('foo', 'bar', '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'), - array('foo', 'bar', '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'), - array('bar', 'foo', 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'), - array('bar', 'baz', 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'), - ); + return [ + ['foo', 'bar', '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'], + ['foo', 'bar', '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'], + ['bar', 'foo', 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'], + ['bar', 'baz', 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/PasswordEncoderTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/PasswordEncoderTest.php index bf1d50d3fd..82ad2e2788 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/PasswordEncoderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Phrasea/PasswordEncoderTest.php @@ -8,25 +8,25 @@ class PasswordEncoderTest extends \PHPUnit_Framework_TestCase { public function providePasswords() { - return array( - array( + return [ + [ 'foo-key', 'foo', 'bar', '116a409f4597bf3ccfe8bc4529c638452c9831d941355f9b49386e6733db31138b228d52fd50409af8960d8059fd03b6c128884efff05055beada86d1ea9a025' - ), - array( + ], + [ 'foo-key', 'baz', 'bar', 'f77b2da9276efd3e4ca66503cf50f4399798968731521c3e71758bb412737d57f2370144fd3adc3a740f87bee9b04b4369018d549c221bc28fcf7967c6712302' - ), - ); + ], + ]; } public function provideInvalidKeys() { - return array( - array(null), - array(''), - array(' '), - ); + return [ + [null], + [''], + [' '], + ]; } /** diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FacebookTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FacebookTest.php index a0a7b97f3b..6049732657 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FacebookTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FacebookTest.php @@ -35,9 +35,9 @@ class FacebookTest extends ProviderTestCase ->method('getUser') ->will($this->returnValue(null)); - return array( - array($provider, $this->getRequestMock()) - ); + return [ + [$provider, $this->getRequestMock()] + ]; } public function getProviderForLogout() @@ -52,9 +52,9 @@ class FacebookTest extends ProviderTestCase ->method('getUser') ->will($this->returnValue('123456')); - return array( - array($provider, $this->getRequestMock()) - ); + return [ + [$provider, $this->getRequestMock()] + ]; } protected function getProvider() @@ -76,7 +76,7 @@ class FacebookTest extends ProviderTestCase $facebook = $this->getMockBuilder('Facebook') ->disableOriginalConstructor() - ->setMethods(array('getLoginUrl', 'api', 'getUser')) + ->setMethods(['getLoginUrl', 'api', 'getUser']) ->getMock(); $facebook->expects($this->any()) @@ -85,13 +85,13 @@ class FacebookTest extends ProviderTestCase $facebook->expects($this->once()) ->method('api') - ->will($this->returnValue(array( + ->will($this->returnValue([ 'id' => self::ID, 'username' => self::FIRSTNAME, 'first_name' => self::FIRSTNAME, 'last_name' => self::LASTNAME, 'email' => self::EMAIL, - ))); + ])); $provider->setFacebook($facebook); @@ -105,21 +105,21 @@ class FacebookTest extends ProviderTestCase protected function getAvailableFieldsForIdentity() { - return array( + return [ Identity::PROPERTY_ID => self::ID, Identity::PROPERTY_USERNAME => self::FIRSTNAME, Identity::PROPERTY_FIRSTNAME => self::FIRSTNAME, Identity::PROPERTY_LASTNAME => self::LASTNAME, Identity::PROPERTY_EMAIL => self::EMAIL, - ); + ]; } protected function getTestOptions() { - return array( + return [ 'app-id' => 'zizi', 'secret' => 's3cr3t', - ); + ]; } protected function getProviderForAuthentication() @@ -131,7 +131,7 @@ class FacebookTest extends ProviderTestCase { $facebook = $this->getMockBuilder('Facebook') ->disableOriginalConstructor() - ->setMethods(array('getLoginUrl', 'api', 'getUser')) + ->setMethods(['getLoginUrl', 'api', 'getUser']) ->getMock(); $facebook->expects($this->any()) @@ -142,9 +142,9 @@ class FacebookTest extends ProviderTestCase ->method('api') ->will($this->returnCallback(function () use ($facebook) { if (!$facebook->getUser()) { - throw new \FacebookApiException(array( + throw new \FacebookApiException([ 'error_msg' => 'Not authenticated' - )); + ]); } })); diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FactoryTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FactoryTest.php index fcdf2264b9..c66b50fe92 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/FactoryTest.php @@ -24,12 +24,12 @@ class FactoryTest extends \PHPUnit_Framework_TestCase public function provideNameAndOptions() { - return array( - array('github', array('client-id' => 'id', 'client-secret' => 'secret'), 'Alchemy\Phrasea\Authentication\Provider\Github'), - array('google-plus', array('client-id' => 'id', 'client-secret' => 'secret'), 'Alchemy\Phrasea\Authentication\Provider\GooglePlus'), - array('linkedin', array('client-id' => 'id', 'client-secret' => 'secret'), 'Alchemy\Phrasea\Authentication\Provider\Linkedin'), - array('twitter', array('consumer-key' => 'id', 'consumer-secret' => 'secret'), 'Alchemy\Phrasea\Authentication\Provider\Twitter'), - array('viadeo', array('client-id' => 'id', 'client-secret' => 'secret'), 'Alchemy\Phrasea\Authentication\Provider\Viadeo'), - ); + return [ + ['github', ['client-id' => 'id', 'client-secret' => 'secret'], 'Alchemy\Phrasea\Authentication\Provider\Github'], + ['google-plus', ['client-id' => 'id', 'client-secret' => 'secret'], 'Alchemy\Phrasea\Authentication\Provider\GooglePlus'], + ['linkedin', ['client-id' => 'id', 'client-secret' => 'secret'], 'Alchemy\Phrasea\Authentication\Provider\Linkedin'], + ['twitter', ['consumer-key' => 'id', 'consumer-secret' => 'secret'], 'Alchemy\Phrasea\Authentication\Provider\Twitter'], + ['viadeo', ['client-id' => 'id', 'client-secret' => 'secret'], 'Alchemy\Phrasea\Authentication\Provider\Viadeo'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GithubTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GithubTest.php index 5d44fd1a10..44ad62cb4c 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GithubTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GithubTest.php @@ -16,12 +16,12 @@ class GithubTest extends ProviderTestCase $provider->getSession()->set('github.provider.state', $state . mt_rand()); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); - return array( - array($this->getProvider(), $this->getRequestMock()), - array($provider, $request), - ); + return [ + [$this->getProvider(), $this->getRequestMock()], + [$provider, $request], + ]; } public function getProviderForLogout() @@ -76,19 +76,19 @@ class GithubTest extends ProviderTestCase $provider->getSession()->set('github.provider.state', $state); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); - return array( - array($provider, $request), - ); + return [ + [$provider, $request], + ]; } public function getTestOptions() { - return array( + return [ 'client-id' => 'github-client-id', 'client-secret' => 'github-client-secret', - ); + ]; } protected function getProviderForAuthentication() @@ -123,12 +123,12 @@ class GithubTest extends ProviderTestCase $response->expects($this->any()) ->method('getBody') ->with($this->equalTo(true)) - ->will($this->returnValue(json_encode(array( + ->will($this->returnValue(json_encode([ 'id' => self::ID, 'name' => self::FIRSTNAME . ' ' . self::LASTNAME, 'email' => self::EMAIL, 'avatar_url' => self::IMAGEURL, - )))); + ]))); $requestGet->expects($this->any()) ->method('send') @@ -188,13 +188,13 @@ class GithubTest extends ProviderTestCase protected function getAvailableFieldsForIdentity() { - return array( + return [ Identity::PROPERTY_ID => self::ID, Identity::PROPERTY_FIRSTNAME => self::FIRSTNAME, Identity::PROPERTY_LASTNAME => self::LASTNAME, Identity::PROPERTY_EMAIL => self::EMAIL, Identity::PROPERTY_IMAGEURL => self::IMAGEURL, - ); + ]; } protected function authenticate(ProviderInterface $provider) diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GooglePlusTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GooglePlusTest.php index be5da60285..25f47f653e 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GooglePlusTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/GooglePlusTest.php @@ -28,12 +28,12 @@ class GooglePlusTest extends ProviderTestCase $provider->getSession()->set('google-plus.provider.state', $state . mt_rand()); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); - return array( - array($this->provideFailingProvider(), $this->getRequestMock()), - array($provider, $request), - ); + return [ + [$this->provideFailingProvider(), $this->getRequestMock()], + [$provider, $request], + ]; } public function getProviderForLogout() @@ -94,9 +94,9 @@ class GooglePlusTest extends ProviderTestCase $provider->getSession()->set('google-plus.provider.state', $state); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array( + $this->addQueryParameter($request, [ 'state' => $state, - )); + ]); $ticket = $this->getMockBuilder('Google_LoginTicket') ->disableOriginalConstructor() @@ -106,17 +106,17 @@ class GooglePlusTest extends ProviderTestCase ->method('verifyIdToken') ->will($this->returnValue($ticket)); - return array( - array($provider, $request), - ); + return [ + [$provider, $request], + ]; } public function getTestOptions() { - return array( + return [ 'client-id' => 'google-plus-client-id', 'client-secret' => 'google-plus-client-secret', - ); + ]; } protected function getProviderForSuccessIdentity() @@ -146,9 +146,9 @@ class GooglePlusTest extends ProviderTestCase $response->expects($this->any()) ->method('getBody') ->with($this->equalTo(true)) - ->will($this->returnValue(json_encode(array( + ->will($this->returnValue(json_encode([ 'email' => self::EMAIL - )))); + ]))); $requestGet->expects($this->any()) ->method('send') @@ -167,16 +167,16 @@ class GooglePlusTest extends ProviderTestCase $people->expects($this->once()) ->method('get') - ->will($this->returnValue(array( - 'name' => array( + ->will($this->returnValue([ + 'name' => [ 'givenName' => self::FIRSTNAME, 'familyName' => self::LASTNAME, - ), + ], 'id' => self::ID, - 'image' => array( + 'image' => [ 'url' => self::IMAGEURL - ) - ))); + ] + ])); $provider->getGooglePlusService()->people = $people; @@ -185,13 +185,13 @@ class GooglePlusTest extends ProviderTestCase protected function getAvailableFieldsForIdentity() { - return array( + return [ Identity::PROPERTY_ID => self::ID, Identity::PROPERTY_FIRSTNAME => self::FIRSTNAME, Identity::PROPERTY_LASTNAME => self::LASTNAME, Identity::PROPERTY_EMAIL => self::EMAIL, Identity::PROPERTY_IMAGEURL => self::IMAGEURL, - ); + ]; } protected function getProviderForFailingIdentity() diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/LinkedinTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/LinkedinTest.php index cf6c73c14a..0cc23a3477 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/LinkedinTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/LinkedinTest.php @@ -13,7 +13,7 @@ class LinkedinTest extends ProviderTestCase $state = md5(mt_rand()); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); $provider1 = $this->getProvider(); $provider1->setGuzzleClient($this->getGuzzleMock(401)); @@ -67,11 +67,11 @@ class LinkedinTest extends ProviderTestCase $provider2->setGuzzleClient($mock); $provider2->getSession()->set('linkedin.provider.state', $state); - return array( - array($this->getProvider(), $this->getRequestMock()), - array($provider1, $request), - array($provider2, $request), - ); + return [ + [$this->getProvider(), $this->getRequestMock()], + [$provider1, $request], + [$provider2, $request], + ]; } public function getProviderForLogout() @@ -130,19 +130,19 @@ class LinkedinTest extends ProviderTestCase $provider->getSession()->set('linkedin.provider.state', $state); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); - return array( - array($provider, $request), - ); + return [ + [$provider, $request], + ]; } public function getTestOptions() { - return array( + return [ 'client-id' => 'linkedin-client-id', 'client-secret' => 'linkedin-client-secret', - ); + ]; } protected function getProviderForSuccessIdentity() @@ -176,23 +176,23 @@ class LinkedinTest extends ProviderTestCase $response->expects($this->any()) ->method('getBody') ->with($this->equalTo(true)) - ->will($this->returnValue(json_encode(array( - 'positions' => array( + ->will($this->returnValue(json_encode([ + 'positions' => [ '_total' => 1, - 'values' => array( - array( - 'company' => array( + 'values' => [ + [ + 'company' => [ 'name' => self::COMPANY - ) - ) - ) - ), + ] + ] + ] + ], 'emailAddress' => self::EMAIL, 'firstName' => self::FIRSTNAME, 'id' => self::ID, 'pictureUrl' => self::IMAGEURL, 'lastName' => self::LASTNAME, - )))); + ]))); $requestGet->expects($this->any()) ->method('send') @@ -210,14 +210,14 @@ class LinkedinTest extends ProviderTestCase protected function getAvailableFieldsForIdentity() { - return array( + return [ Identity::PROPERTY_ID => self::ID, Identity::PROPERTY_FIRSTNAME => self::FIRSTNAME, Identity::PROPERTY_LASTNAME => self::LASTNAME, Identity::PROPERTY_EMAIL => self::EMAIL, Identity::PROPERTY_IMAGEURL => self::IMAGEURL, Identity::PROPERTY_COMPANY => self::COMPANY, - ); + ]; } protected function getProviderForFailingIdentity() diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ProviderTestCase.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ProviderTestCase.php index 734e2c1e1a..951e02d7d7 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ProviderTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ProviderTestCase.php @@ -66,7 +66,7 @@ abstract class ProviderTestCase extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->assertEquals(array(), $provider->getTemplates($identity)); + $this->assertEquals([], $provider->getTemplates($identity)); } public function testGetName() diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/IdentityTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/IdentityTest.php index c1e68e6a08..b6acd72b3a 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/IdentityTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/IdentityTest.php @@ -16,7 +16,7 @@ class IdentityTest extends \PHPUnit_Framework_TestCase public function testThatConstructArgumentAreSet() { - $identity = new Identity(array(Identity::PROPERTY_IMAGEURL => 'image-uri')); + $identity = new Identity([Identity::PROPERTY_IMAGEURL => 'image-uri']); $this->assertNull($identity->get(Identity::PROPERTY_ID)); $this->assertEquals('image-uri', $identity->get(Identity::PROPERTY_IMAGEURL)); @@ -34,7 +34,7 @@ class IdentityTest extends \PHPUnit_Framework_TestCase public function testGetFirstname() { - $identity = new Identity(array( + $identity = new Identity([ Identity::PROPERTY_ID => 'id', Identity::PROPERTY_IMAGEURL => 'image url', Identity::PROPERTY_COMPANY => 'company', @@ -42,7 +42,7 @@ class IdentityTest extends \PHPUnit_Framework_TestCase Identity::PROPERTY_EMAIL => 'email', Identity::PROPERTY_FIRSTNAME => 'first name', Identity::PROPERTY_LASTNAME => 'last name', - )); + ]); $this->assertEquals($identity->getId(), $identity->get($identity::PROPERTY_ID)); $this->assertEquals($identity->getImageURI(), $identity->get($identity::PROPERTY_IMAGEURL)); @@ -58,9 +58,9 @@ class IdentityTest extends \PHPUnit_Framework_TestCase public function testHas() { - $identity = new Identity(array( + $identity = new Identity([ Identity::PROPERTY_IMAGEURL => 'image url', - )); + ]); $this->assertTrue($identity->has(Identity::PROPERTY_IMAGEURL)); @@ -84,10 +84,10 @@ class IdentityTest extends \PHPUnit_Framework_TestCase { $identity = new Identity(); - $this->assertEquals(array(), $identity->all()); + $this->assertEquals([], $identity->all()); $identity->set(Identity::PROPERTY_IMAGEURL, 'image-uri'); - $this->assertEquals(array('image_url' => 'image-uri'), $identity->all()); + $this->assertEquals(['image_url' => 'image-uri'], $identity->all()); return $identity; } diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/TokenTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/TokenTest.php index 18873b3cf8..c0eb711003 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/TokenTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/Token/TokenTest.php @@ -48,7 +48,7 @@ class TokenTest extends \PHPUnit_Framework_TestCase ->method('getIdentity') ->will($this->returnValue($identity)); - $templates = array(25, 42); + $templates = [25, 42]; $provider->expects($this->once()) ->method('getTemplates') diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/TwitterTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/TwitterTest.php index 1cf3619d76..ec36534746 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/TwitterTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/TwitterTest.php @@ -51,11 +51,11 @@ class TwitterTest extends ProviderTestCase $provider->getTwitterClient()->expects($this->once()) ->method('request') ->will($this->returncallback(function () use ($provider) { - $provider->getTwitterClient()->response = array( - 'response' => array( + $provider->getTwitterClient()->response = [ + 'response' => [ 'oauth_token' => 'twitter-oauth-token', - ) - ); + ] + ]; return 200; })); @@ -66,7 +66,7 @@ class TwitterTest extends ProviderTestCase public function provideDataForFailingCallback() { $request = $this->getRequestMock(); - $this->addQueryParameter($request, array()); + $this->addQueryParameter($request, []); $provider1 = $this->getProvider(); $provider1->getTwitterClient()->expects($this->once()) @@ -82,11 +82,11 @@ class TwitterTest extends ProviderTestCase return 401; } else { - $provider2->getTwitterClient()->response = array( - 'response' => array( + $provider2->getTwitterClient()->response = [ + 'response' => [ 'oauth_token' => 'twitter-oauth-token', - ) - ); + ] + ]; $first = false; @@ -94,10 +94,10 @@ class TwitterTest extends ProviderTestCase } })); - return array( - array($provider1, $request), - array($provider2, $request), - ); + return [ + [$provider1, $request], + [$provider2, $request], + ]; } public function provideDataForSuccessCallback() @@ -108,7 +108,7 @@ class TwitterTest extends ProviderTestCase $provider->getSession()->set('twitter.provider.state', $state); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); $phpunit = $this; $provider->getTwitterClient()->expects($this->any()) @@ -116,18 +116,18 @@ class TwitterTest extends ProviderTestCase ->will($this->returnCallback(function ($method) use ($provider, $phpunit) { switch ($method) { case 'POST': - $provider->getTwitterClient()->response = array( - 'response' => array( + $provider->getTwitterClient()->response = [ + 'response' => [ 'oauth_token' => 'twitter-oauth-token', - ) - ); + ] + ]; break; case 'GET': - $provider->getTwitterClient()->response = array( - 'response' => json_encode(array( + $provider->getTwitterClient()->response = [ + 'response' => json_encode([ 'id' => $phpunit::ID, - )) - ); + ]) + ]; break; default: throw new \InvalidArgumentException(sprintf('Invalid method %s', $method)); @@ -139,43 +139,43 @@ class TwitterTest extends ProviderTestCase $provider->getTwitterClient()->expects($this->once()) ->method('extract_params') - ->will($this->returnValue(array( + ->will($this->returnValue([ 'oauth_token_secret' => 'token secret', 'oauth_token' => 'token', - ))); + ])); - return array( - array($provider, $request), - ); + return [ + [$provider, $request], + ]; } public function getTestOptions() { - return array( + return [ 'consumer-key' => 'twitter-consumer-key', 'consumer-secret' => 'twitter-consumer-secret', - ); + ]; } protected function getProviderForSuccessIdentity() { $provider = $this->getProvider(); - $provider->getSession()->set('twitter.provider.access_token', array( + $provider->getSession()->set('twitter.provider.access_token', [ 'oauth_token' => 'twitter token', 'oauth_token_secret' => 'token secret', - )); + ]); $phpunit = $this; $provider->getTwitterClient()->expects($this->once()) ->method('request') ->will($this->returncallback(function () use ($provider, $phpunit) { - $provider->getTwitterClient()->response = array( - 'response' => json_encode(array( + $provider->getTwitterClient()->response = [ + 'response' => json_encode([ 'screen_name' => $phpunit::USERNAME, 'profile_image_url_https' => $phpunit::IMAGEURL, 'id' => $phpunit::ID, - )) - ); + ]) + ]; return 200; })); @@ -185,11 +185,11 @@ class TwitterTest extends ProviderTestCase protected function getAvailableFieldsForIdentity() { - return array( + return [ Identity::PROPERTY_ID => self::ID, Identity::PROPERTY_USERNAME => self::USERNAME, Identity::PROPERTY_IMAGEURL => self::IMAGEURL, - ); + ]; } protected function getProviderForFailingIdentity() diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ViadeoTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ViadeoTest.php index 18778ee067..f937ffbc1d 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ViadeoTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Provider/ViadeoTest.php @@ -16,12 +16,12 @@ class ViadeoTest extends ProviderTestCase $provider->getSession()->set('viadeo.provider.state', $state . mt_rand()); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); - return array( - array($this->getProvider(), $this->getRequestMock()), - array($provider, $request), - ); + return [ + [$this->getProvider(), $this->getRequestMock()], + [$provider, $request], + ]; } public function getProviderForLogout() @@ -111,19 +111,19 @@ class ViadeoTest extends ProviderTestCase $provider->getSession()->set('viadeo.provider.state', $state); $request = $this->getRequestMock(); - $this->addQueryParameter($request, array('state' => $state)); + $this->addQueryParameter($request, ['state' => $state]); - return array( - array($provider, $request), - ); + return [ + [$provider, $request], + ]; } public function getTestOptions() { - return array( + return [ 'client-id' => 'viadeo-client-id', 'client-secret' => 'viadeo-client-secret', - ); + ]; } protected function getProviderForAuthentication() @@ -168,24 +168,24 @@ class ViadeoTest extends ProviderTestCase $response1->expects($this->any()) ->method('getBody') ->with($this->equalTo(true)) - ->will($this->returnValue(json_encode(array( + ->will($this->returnValue(json_encode([ 'id' => self::ID, 'first_name' => self::FIRSTNAME, 'last_name' => self::LASTNAME, 'picture_large' => self::IMAGEURL, 'nickname' => self::USERNAME, - )))); + ]))); $response2->expects($this->any()) ->method('getBody') ->with($this->equalTo(true)) - ->will($this->returnValue(json_encode(array( - 'data' => array( - array( + ->will($this->returnValue(json_encode([ + 'data' => [ + [ 'company_name' => self::COMPANY - ) - ), - )))); + ] + ], + ]))); $requestGet1->expects($this->any()) ->method('send') @@ -252,14 +252,14 @@ class ViadeoTest extends ProviderTestCase protected function getAvailableFieldsForIdentity() { - return array( + return [ Identity::PROPERTY_ID => self::ID, Identity::PROPERTY_FIRSTNAME => self::FIRSTNAME, Identity::PROPERTY_LASTNAME => self::LASTNAME, Identity::PROPERTY_USERNAME => self::USERNAME, Identity::PROPERTY_IMAGEURL => self::IMAGEURL, Identity::PROPERTY_COMPANY => self::COMPANY, - ); + ]; } protected function authenticate(ProviderInterface $provider) diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/ProvidersCollectionTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/ProvidersCollectionTest.php index 4efad8f3ad..a85a3309c2 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/ProvidersCollectionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/ProvidersCollectionTest.php @@ -17,7 +17,7 @@ class ProvidersCollectionTest extends \PHPUnit_Framework_TestCase $providers = new ProvidersCollection(); $providers->register($provider); - $expectedIterator = new \ArrayIterator(array('neutron-provider' => $provider)); + $expectedIterator = new \ArrayIterator(['neutron-provider' => $provider]); $this->assertEquals($expectedIterator, $providers->getIterator()); } diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/SuggestionFinderTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/SuggestionFinderTest.php index 26624c50c1..2d9258ef8d 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/SuggestionFinderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/SuggestionFinderTest.php @@ -30,7 +30,7 @@ class SuggestionFinderTest extends \PhraseanetPHPUnitAbstract protected function getToken($email) { - $identity = new Identity(array(Identity::PROPERTY_EMAIL => $email)); + $identity = new Identity([Identity::PROPERTY_EMAIL => $email]); $token = $this->getMockBuilder('Alchemy\Phrasea\Authentication\Provider\Token\Token') ->disableOriginalConstructor() diff --git a/tests/Alchemy/Tests/Phrasea/Border/Attribute/FactoryTest.php b/tests/Alchemy/Tests/Phrasea/Border/Attribute/FactoryTest.php index be27630f5a..8684f73a98 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Attribute/FactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Attribute/FactoryTest.php @@ -62,7 +62,7 @@ class FactoryTest extends \PhraseanetPHPUnitAbstract $this->markTestSkipped('No databox field found'); } - $metafield = new MetaField($databox_field, array('value')); + $metafield = new MetaField($databox_field, ['value']); $attribute = Factory::getFileAttribute(self::$DI['app'], AttributeInterface::NAME_METAFIELD, $metafield->asString()); diff --git a/tests/Alchemy/Tests/Phrasea/Border/Attribute/MetaFieldTest.php b/tests/Alchemy/Tests/Phrasea/Border/Attribute/MetaFieldTest.php index b9e497ff0d..55529e5c82 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Attribute/MetaFieldTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Attribute/MetaFieldTest.php @@ -29,7 +29,7 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract */ public function setUp() { - $this->value = array("Un éléphant ça trompe"); + $this->value = ["Un éléphant ça trompe"]; foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) { $this->databox_field = $databox_field; break; @@ -58,8 +58,8 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract */ public function testConstruct() { - new MetaField($this->databox_field, array(0.57)); - new MetaField($this->databox_field, array(3)); + new MetaField($this->databox_field, [0.57]); + new MetaField($this->databox_field, [3]); } /** @@ -119,6 +119,6 @@ class MetaFieldTest extends \PhraseanetPHPUnitAbstract { \PHPUnit_Framework_Error_Warning::$enabled = false; \PHPUnit_Framework_Error_Notice::$enabled = false; - MetaField::loadFromString(self::$DI['app'], serialize(array('Elephant', 'sbas_id' => self::$DI['collection']->get_sbas_id(), 'id' => 0))); + MetaField::loadFromString(self::$DI['app'], serialize(['Elephant', 'sbas_id' => self::$DI['collection']->get_sbas_id(), 'id' => 0])); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Attribute/StatusTest.php b/tests/Alchemy/Tests/Phrasea/Border/Attribute/StatusTest.php index 680f452042..105fce23e1 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Attribute/StatusTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Attribute/StatusTest.php @@ -25,14 +25,14 @@ class StatusTest extends \PhraseanetPHPUnitAbstract public function getValidStatuses() { - return array( - array(123, '1111011'), - array('123', '1111011'), - array('0b1111011', '1111011'), - array('1111011', '1111011'), - array('0x7b', '1111011'), - array('7b', '1111011'), - ); + return [ + [123, '1111011'], + ['123', '1111011'], + ['0b1111011', '1111011'], + ['1111011', '1111011'], + ['0x7b', '1111011'], + ['7b', '1111011'], + ]; } /** @@ -47,11 +47,11 @@ class StatusTest extends \PhraseanetPHPUnitAbstract public function getInvalidStatuses() { - return array( - array('0b00z2'), - array('0x00g2'), - array('g2'), - ); + return [ + ['0b00z2'], + ['0x00g2'], + ['g2'], + ]; } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php index 95eb1a8923..12220c6aa2 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/AbstractCheckerTest.php @@ -19,7 +19,7 @@ class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract parent::setUp(); $this->object = new AbstractCheckerTester(self::$DI['app']); - $this->file = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getCollection'), array(), 'CheckerTesterMock' . mt_rand(), false); + $this->file = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getCollection'], [], 'CheckerTesterMock' . mt_rand(), false); } public function tearDown() @@ -66,14 +66,14 @@ class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract } } - $ret = array( - array(array($collection->get_databox()), $collection, true), - array($collection->get_databox(), $collection, true), - array($collection->get_databox(), null, true), - ); + $ret = [ + [[$collection->get_databox()], $collection, true], + [$collection->get_databox(), $collection, true], + [$collection->get_databox(), null, true], + ]; if ($databox) { - $ret[] = array($databox, $collection, false); + $ret[] = [$databox, $collection, false]; } return $ret; @@ -130,13 +130,13 @@ class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract $collection = \collection::create($app, $databox, $app['phraseanet.appbox'], 'other coll'); } - return array( - array(array($collection), $collection, true), - array($collection, $collection, true), - array($collection, null, true), - array($collection, $othercollection, false), - array(array($collection), $othercollection, false), - ); + return [ + [[$collection], $collection, true], + [$collection, $collection, true], + [$collection, null, true], + [$collection, $othercollection, false], + [[$collection], $othercollection, false], + ]; } /** @@ -194,9 +194,9 @@ class AbstractCheckerTest extends \PhraseanetPHPUnitAbstract } } - return array( - array($databox, $collection), - ); + return [ + [$databox, $collection], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php index 914ec57e48..d6722160b7 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/ColorspaceTest.php @@ -19,7 +19,7 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract public function setUp() { parent::setUp(); - $this->object = new Colorspace(self::$DI['app'], array('colorspaces' => array('RGB', 'cmyk'))); + $this->object = new Colorspace(self::$DI['app'], ['colorspaces' => ['RGB', 'cmyk']]); } /** @@ -59,6 +59,6 @@ class ColorspaceTest extends \PhraseanetPHPUnitAbstract */ public function testContructorInvalidArgumentException() { - new Colorspace(self::$DI['app'], array(array('RGB', 'cmyk'))); + new Colorspace(self::$DI['app'], [['RGB', 'cmyk']]); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php index 098c5d0afe..dab2bca660 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/DimensionTest.php @@ -36,32 +36,32 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract $File = new File(self::$DI['app'], $media, self::$DI['collection']); - $object = new Dimension(self::$DI['app'], array('width' => 800)); + $object = new Dimension(self::$DI['app'], ['width' => 800]); $response = $object->check(self::$DI['app']['EM'], $File); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertFalse($response->isOk()); - $object = new Dimension(self::$DI['app'], array('width' => 500)); + $object = new Dimension(self::$DI['app'], ['width' => 500]); $response = $object->check(self::$DI['app']['EM'], $File); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertFalse($response->isOk()); - $object = new Dimension(self::$DI['app'], array('width' => 400)); + $object = new Dimension(self::$DI['app'], ['width' => 400]); $response = $object->check(self::$DI['app']['EM'], $File); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertTrue($response->isOk()); - $object = new Dimension(self::$DI['app'], array('width' => 600, 'height' => 500)); + $object = new Dimension(self::$DI['app'], ['width' => 600, 'height' => 500]); $response = $object->check(self::$DI['app']['EM'], $File); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertFalse($response->isOk()); - $object = new Dimension(self::$DI['app'], array('width' => 600, 'height' => 400)); + $object = new Dimension(self::$DI['app'], ['width' => 600, 'height' => 400]); $response = $object->check(self::$DI['app']['EM'], $File); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertTrue($response->isOk()); - $object = new Dimension(self::$DI['app'], array('width' => 200, 'height' => 200)); + $object = new Dimension(self::$DI['app'], ['width' => 200, 'height' => 200]); $response = $object->check(self::$DI['app']['EM'], $File); $this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Checker\\Response', $response); $this->assertTrue($response->isOk()); @@ -83,7 +83,7 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract $height = $dimensions['height']; } - new Dimension(self::$DI['app'], array('width' => $width,'height' => $height)); + new Dimension(self::$DI['app'], ['width' => $width,'height' => $height]); $this->fail(sprintf('Exception raised with dimensions %s and %s', $width, $height)); } catch (\InvalidArgumentException $e) { @@ -93,17 +93,17 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract public function getWrongDimensions() { - return array( - array('width' => 0), - array('width' => -1), - array('width' => 5, 'height' => -4), - array('width' => 5, 'height' => 'a'), - array('width' => 'a', 'height' => 5), - array('width' => 'a', 'height' => 'b'), - array('width' => 'a'), - array('width' => 0, 'height' => 35), - array('width' => 30, 'height' => 0) - ); + return [ + ['width' => 0], + ['width' => -1], + ['width' => 5, 'height' => -4], + ['width' => 5, 'height' => 'a'], + ['width' => 'a', 'height' => 5], + ['width' => 'a', 'height' => 'b'], + ['width' => 'a'], + ['width' => 0, 'height' => 35], + ['width' => 30, 'height' => 0] + ]; } /** @@ -119,6 +119,6 @@ class DimensionTest extends \PhraseanetPHPUnitAbstract */ public function testContructorInvalidArgumentException() { - new Dimension(self::$DI['app'], array('witdh' => 38)); + new Dimension(self::$DI['app'], ['witdh' => 38]); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php index d597f778ec..5a8e9992d2 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/ExtensionTest.php @@ -19,7 +19,7 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract public function setUp() { parent::setUp(); - $this->object = new Extension(self::$DI['app'], array('extensions' => array('jpg', 'png', 'tiff'))); + $this->object = new Extension(self::$DI['app'], ['extensions' => ['jpg', 'png', 'tiff']]); } /** @@ -27,16 +27,16 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract */ public function testCheck() { - $tests = array( + $tests = [ 'jpg' => true, 'JPG' => true, 'tiff' => true, 'exe' => false, - ); + ]; foreach ($tests as $extension => $result) { - $spl = $this->getMock('\\Symfony\\Component\\HttpFoundation\\File\\File', array('getExtension'), array(__DIR__ . '/../../../../../files/test001.jpg')); + $spl = $this->getMock('\\Symfony\\Component\\HttpFoundation\\File\\File', ['getExtension'], [__DIR__ . '/../../../../../files/test001.jpg']); $spl->expects($this->any()) ->method('getExtension') @@ -71,6 +71,6 @@ class ExtensionTest extends \PhraseanetPHPUnitAbstract */ public function testContructorInvalidArgumentException() { - new Extension(self::$DI['app'], array(array('jpg', 'png', 'tiff'))); + new Extension(self::$DI['app'], [['jpg', 'png', 'tiff']]); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php index 39af3df279..8cf56ff7fc 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/FilenameTest.php @@ -55,7 +55,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract */ public function testCheckNoFile() { - $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getOriginalName'), array(self::$DI['app'], $this->media, self::$DI['collection'])); + $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getOriginalName'], [self::$DI['app'], $this->media, self::$DI['collection']]); $mock ->expects($this->once()) @@ -78,7 +78,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract */ public function testCheckSensitive() { - $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getOriginalName'), array(self::$DI['app'], $this->media, self::$DI['collection'])); + $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getOriginalName'], [self::$DI['app'], $this->media, self::$DI['collection']]); $mock ->expects($this->any()) @@ -92,7 +92,7 @@ class FilenameTest extends \PhraseanetPHPUnitAbstract $this->assertFalse($response->isOk()); - $objectSensitive = new Filename(self::$DI['app'], array('sensitive' => true)); + $objectSensitive = new Filename(self::$DI['app'], ['sensitive' => true]); $responseSensitive = $objectSensitive->check(self::$DI['app']['EM'], $mock); $this->assertTrue($responseSensitive->isOk()); diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php index 42d64c6820..809f7effb6 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/MediaTypeTest.php @@ -19,7 +19,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract public function setUp() { parent::setUp(); - $this->object = new MediaType(self::$DI['app'], array('mediatypes' => array(MediaType::TYPE_IMAGE))); + $this->object = new MediaType(self::$DI['app'], ['mediatypes' => [MediaType::TYPE_IMAGE]]); } /** @@ -33,7 +33,7 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract $this->assertTrue($response->isOk()); - $object = new MediaType(self::$DI['app'], array('mediatypes' => array(MediaType::TYPE_VIDEO, MediaType::TYPE_AUDIO))); + $object = new MediaType(self::$DI['app'], ['mediatypes' => [MediaType::TYPE_VIDEO, MediaType::TYPE_AUDIO]]); $media = self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/test001.jpg'); $file = new File(self::$DI['app'], $media, self::$DI['collection']); @@ -55,6 +55,6 @@ class MediaTypeTest extends \PhraseanetPHPUnitAbstract */ public function testContructorInvalidArgumentException() { - new MediaType(self::$DI['app'], array(array(MediaType::TYPE_IMAGE))); + new MediaType(self::$DI['app'], [[MediaType::TYPE_IMAGE]]); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php index 35de04f622..0a88ca669e 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/ResponseTest.php @@ -15,7 +15,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase public function setUp() { parent::setUp(); - $this->mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\Checker\\CheckerInterface', array('getMessage', 'check', 'isApplicable')); + $this->mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\Checker\\CheckerInterface', ['getMessage', 'check', 'isApplicable']); $this->object = new Response(true, $this->mock); } diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php index 4bcef887dc..f77e5b91af 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/Sha256Test.php @@ -43,7 +43,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract self::$DI['app']['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$DI['collection'], self::$DI['app']), null, Manager::FORCE_RECORD); - $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getSha256'), array(self::$DI['app'], $this->media, self::$DI['collection'])); + $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getSha256'], [self::$DI['app'], $this->media, self::$DI['collection']]); $mock ->expects($this->once()) @@ -63,7 +63,7 @@ class Sha256Test extends \PhraseanetPHPUnitAbstract */ public function testCheckNoFile() { - $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getSha256'), array(self::$DI['app'], $this->media, self::$DI['collection'])); + $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getSha256'], [self::$DI['app'], $this->media, self::$DI['collection']]); $mock ->expects($this->once()) diff --git a/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php b/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php index 553b2eb60d..95ec65168c 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/Checker/UUIDTest.php @@ -49,7 +49,7 @@ class UUIDTest extends \PhraseanetPHPUnitAbstract */ public function testCheckNoFile() { - $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', array('getUUID'), array(self::$DI['app'], $this->media, self::$DI['collection'])); + $mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getUUID'], [self::$DI['app'], $this->media, self::$DI['collection']]); $mock ->expects($this->once()) diff --git a/tests/Alchemy/Tests/Phrasea/Border/FileTest.php b/tests/Alchemy/Tests/Phrasea/Border/FileTest.php index 40e124da51..ee3135cbe9 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/FileTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/FileTest.php @@ -160,7 +160,7 @@ class FileTest extends \PhraseanetPHPUnitAbstract */ public function testGetAttributes() { - $this->assertSame(array(), $this->object->getAttributes()); + $this->assertSame([], $this->object->getAttributes()); } /** @@ -175,16 +175,16 @@ class FileTest extends \PhraseanetPHPUnitAbstract $attribute1 = new Metadata($metadata1); $this->object->addAttribute($attribute1); - $this->assertSame(array($attribute1), $this->object->getAttributes()); + $this->assertSame([$attribute1], $this->object->getAttributes()); $tag = new Keywords(); - $value = new Multi(array('Later', 'Alligator')); + $value = new Multi(['Later', 'Alligator']); $metadata2 = new PHPExiftoolMetadata($tag, $value); $attribute2 = new Metadata($metadata2); $this->object->addAttribute($attribute2); - $this->assertSame(array($attribute1, $attribute2), $this->object->getAttributes()); + $this->assertSame([$attribute1, $attribute2], $this->object->getAttributes()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/ManagerTest.php b/tests/Alchemy/Tests/Phrasea/Border/ManagerTest.php index 1e82ca3bc2..2b7a52c373 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/ManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/ManagerTest.php @@ -75,7 +75,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testProcess() { - $records = array(); + $records = []; $postProcessRecord = function ($record) use (&$records) { $records[] = $record; @@ -117,7 +117,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testProcessForceLazaret() { - $records = array(); + $records = []; $postProcessRecord = function ($record) use (&$records) { $records[] = $record; @@ -137,7 +137,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testCreateRecord() { - $records = array(); + $records = []; $postProcessRecord = function ($record) use (&$records) { $records[] = $record; @@ -145,7 +145,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']); $first = $odd = false; - $tofetch = array(); + $tofetch = []; foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) { if ($databox_field->is_readonly()) { continue; @@ -157,7 +157,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract if ($databox_field->is_multi()) { - $data = array('a', 'Hello Multi ' . $databox_field->get_tag()->getTagname()); + $data = ['a', 'Hello Multi ' . $databox_field->get_tag()->getTagname()]; $tofetch [$databox_field->get_name()] = $data; $data[] = null; @@ -166,7 +166,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $file->addAttribute(new Metadata(new \PHPExiftool\Driver\Metadata\Metadata($databox_field->get_tag(), $value))); } else { - $data = array('Hello Mono ' . $databox_field->get_tag()->getTagname()); + $data = ['Hello Mono ' . $databox_field->get_tag()->getTagname()]; if (!$first) { if ($odd) { @@ -178,7 +178,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $value = new \PHPExiftool\Driver\Value\Mono(current($data)); $tofetch [$databox_field->get_name()] = $data; - $file->addAttribute(new MetaField($databox_field, array(current($data)))); + $file->addAttribute(new MetaField($databox_field, [current($data)])); } } if ($first) { @@ -230,7 +230,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract foreach ($tofetch as $name => $values) { - $found = array(); + $found = []; foreach ($record->get_caption()->get_field($name)->get_values() as $value) { $found[] = $value->getValue(); } @@ -258,7 +258,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $file = File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']); $odd = false; - $tofetchMeta = $tofetchField = array(); + $tofetchMeta = $tofetchField = []; foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $databox_field) { if ($databox_field->is_readonly()) { continue; @@ -270,7 +270,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract if ($databox_field->is_multi()) { - $data = array('a', 'Hello Multi ' . $databox_field->get_tag()->getTagname()); + $data = ['a', 'Hello Multi ' . $databox_field->get_tag()->getTagname()]; $tofetchMeta [$databox_field->get_tag()->getTagname()] = $data; $value = new \PHPExiftool\Driver\Value\Multi($data); @@ -278,7 +278,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $file->addAttribute(new Metadata(new \PHPExiftool\Driver\Metadata\Metadata($databox_field->get_tag(), $value))); } else { - $data = array('Hello Mono ' . $databox_field->get_tag()->getTagname()); + $data = ['Hello Mono ' . $databox_field->get_tag()->getTagname()]; if ($odd) { $value = new \PHPExiftool\Driver\Value\Mono(current($data)); @@ -288,7 +288,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } else { $tofetchField [$databox_field->get_name()] = $data; - $file->addAttribute(new MetaField($databox_field, array(current($data)))); + $file->addAttribute(new MetaField($databox_field, [current($data)])); } } @@ -308,7 +308,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $story_found = $status_found = false; - $foundMeta = $foundField = array(); + $foundMeta = $foundField = []; /* @var $lazaret \Alchemy\Phrasea\Model\Entities\LazaretFile */ foreach ($lazaret->getAttributes() as $attr) { @@ -323,7 +323,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $tagname = $attribute->getValue()->getTag()->getTagname(); if (!isset($foundMeta[$tagname])) { - $foundMeta[$tagname] = array(); + $foundMeta[$tagname] = []; } $foundMeta[$tagname] = array_merge($foundMeta[$tagname], $attribute->getValue()->getValue()->asArray()); @@ -332,7 +332,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $fieldname = $attribute->getField()->get_name(); if (!isset($foundField[$fieldname])) { - $foundField[$fieldname] = array(); + $foundField[$fieldname] = []; } $foundField[$fieldname] = array_merge($foundField[$fieldname], (array) $attribute->getValue()); @@ -375,7 +375,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $monoData = new \PHPExiftool\Driver\Metadata\Metadata($objectNameTag, $monoValue); $personInImageTag = new \PHPExiftool\Driver\Tag\XMPIptcExt\PersonInImage(); - $multiValue = new \PHPExiftool\Driver\Value\Multi(array('Babar', 'Celeste')); + $multiValue = new \PHPExiftool\Driver\Value\Multi(['Babar', 'Celeste']); $multiData = new \PHPExiftool\Driver\Metadata\Metadata($personInImageTag, $multiValue); $file->addAttribute(new Metadata($monoData)); @@ -418,7 +418,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $file = File::buildFromPathfile(__DIR__ . '/../../../../files/HelloWorld.pdf', self::$DI['collection'], self::$DI['app']); $manager->addMediaAttributesTester($file); - $toFound = array( + $toFound = [ 'Phraseanet:tf-width', 'Phraseanet:tf-height', 'Phraseanet:tf-bits', @@ -430,14 +430,14 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'Phraseanet:tf-basename', 'Phraseanet:tf-extension', 'Phraseanet:tf-size', - ); + ]; foreach ($file->getAttributes() as $attribute) { if ($attribute->getName() == AttributeInterface::NAME_METADATA) { $tagname = $attribute->getValue()->getTag()->getTagname(); if (in_array($tagname, $toFound)) { $previousC = count($toFound); - $tmp = array(); + $tmp = []; foreach ($toFound as $val) { if ($tagname != $val) { $tmp[] = $val; @@ -449,7 +449,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } } - $this->assertEquals(array('Phraseanet:tf-duration'), $toFound); + $this->assertEquals(['Phraseanet:tf-duration'], $toFound); } /** @@ -466,7 +466,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $count = count($file->getAttributes()); - $toFound = array( + $toFound = [ 'Phraseanet:tf-width', 'Phraseanet:tf-height', 'Phraseanet:tf-bits', @@ -477,14 +477,14 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'Phraseanet:tf-basename', 'Phraseanet:tf-extension', 'Phraseanet:tf-size', - ); + ]; foreach ($file->getAttributes() as $attribute) { if ($attribute->getName() == AttributeInterface::NAME_METADATA) { $tagname = $attribute->getValue()->getTag()->getTagname(); if (in_array($tagname, $toFound)) { $previousC = count($toFound); - $tmp = array(); + $tmp = []; foreach ($toFound as $val) { if ($tagname != $val) { $tmp[] = $val; @@ -496,7 +496,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } } - $this->assertEquals(array('Phraseanet:tf-width', 'Phraseanet:tf-height', 'Phraseanet:tf-bits', 'Phraseanet:tf-channels'), $toFound); + $this->assertEquals(['Phraseanet:tf-width', 'Phraseanet:tf-height', 'Phraseanet:tf-bits', 'Phraseanet:tf-channels'], $toFound); } /** @@ -513,7 +513,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $count = count($file->getAttributes()); - $toFound = array( + $toFound = [ 'Phraseanet:tf-width', 'Phraseanet:tf-height', 'Phraseanet:tf-bits', @@ -524,14 +524,14 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'Phraseanet:tf-basename', 'Phraseanet:tf-extension', 'Phraseanet:tf-size', - ); + ]; foreach ($file->getAttributes() as $attribute) { if ($attribute->getName() == AttributeInterface::NAME_METADATA) { $tagname = $attribute->getValue()->getTag()->getTagname(); if (in_array($tagname, $toFound)) { $previousC = count($toFound); - $tmp = array(); + $tmp = []; foreach ($toFound as $val) { if ($tagname != $val) { $tmp[] = $val; @@ -543,7 +543,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } } - $this->assertEquals(array('Phraseanet:tf-duration'), $toFound); + $this->assertEquals(['Phraseanet:tf-duration'], $toFound); } /** @@ -551,7 +551,7 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testGetVisa() { - $records = array(); + $records = []; $postProcessRecord = function ($record) use (&$records) { $records[] = $record; @@ -592,14 +592,14 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRegisterChecker() { - $this->assertEquals(array(), $this->object->getCheckers()); + $this->assertEquals([], $this->object->getCheckers()); $shaChecker = new Sha256(self::$DI['app']); $this->object->registerChecker($shaChecker); $uuidChecker = new UUID(self::$DI['app']); $this->object->registerChecker($uuidChecker); - $this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers()); + $this->assertEquals([$shaChecker, $uuidChecker], $this->object->getCheckers()); } /** @@ -608,13 +608,13 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRegisterCheckers() { - $this->assertEquals(array(), $this->object->getCheckers()); + $this->assertEquals([], $this->object->getCheckers()); $shaChecker = new Sha256(self::$DI['app']); $uuidChecker = new UUID(self::$DI['app']); - $this->object->registerCheckers(array($shaChecker, $uuidChecker)); + $this->object->registerCheckers([$shaChecker, $uuidChecker]); - $this->assertEquals(array($shaChecker, $uuidChecker), $this->object->getCheckers()); + $this->assertEquals([$shaChecker, $uuidChecker], $this->object->getCheckers()); } /** @@ -622,17 +622,17 @@ class ManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUnregisterChecker() { - $this->assertEquals(array(), $this->object->getCheckers()); + $this->assertEquals([], $this->object->getCheckers()); $shaChecker = new Sha256(self::$DI['app']); $uuidChecker = new UUID(self::$DI['app']); $filenameChecker = new Filename(self::$DI['app']); - $this->object->registerCheckers(array($shaChecker, $uuidChecker, $filenameChecker)); + $this->object->registerCheckers([$shaChecker, $uuidChecker, $filenameChecker]); - $this->assertEquals(array($shaChecker, $uuidChecker, $filenameChecker), $this->object->getCheckers()); + $this->assertEquals([$shaChecker, $uuidChecker, $filenameChecker], $this->object->getCheckers()); $this->object->unregisterChecker($uuidChecker); - $this->assertEquals(array($shaChecker, $filenameChecker), $this->object->getCheckers()); + $this->assertEquals([$shaChecker, $filenameChecker], $this->object->getCheckers()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Border/MetaFieldsBagTest.php b/tests/Alchemy/Tests/Phrasea/Border/MetaFieldsBagTest.php index dc3dd6240d..a5dae53959 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/MetaFieldsBagTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/MetaFieldsBagTest.php @@ -38,11 +38,11 @@ class MetaFieldsBagTest extends \PhraseanetPHPUnitAbstract foreach ($structure as $databox_field) { if (!$monoAdded) { - $this->object->set($databox_field->get_name(), new MetaField($databox_field, array('mono value'))); + $this->object->set($databox_field->get_name(), new MetaField($databox_field, ['mono value'])); $monoAdded = $databox_field->get_id(); } elseif (!$multiAdded) { if ($databox_field->is_multi()) { - $this->object->set($databox_field->get_name(), new MetaField($databox_field, array('multi', 'value'))); + $this->object->set($databox_field->get_name(), new MetaField($databox_field, ['multi', 'value'])); $multiAdded = $databox_field->get_id(); } } else { @@ -54,22 +54,22 @@ class MetaFieldsBagTest extends \PhraseanetPHPUnitAbstract $this->markTestSkipped('Unable to find multi value field'); } - $this->assertEquals(array( - array( + $this->assertEquals([ + [ 'meta_struct_id' => $monoAdded, 'value' => 'mono value', 'meta_id' => null - ), - array( + ], + [ 'meta_struct_id' => $multiAdded, 'value' => 'multi', 'meta_id' => null - ), - array( + ], + [ 'meta_struct_id' => $multiAdded, 'value' => 'value', 'meta_id' => null - ), - ), $this->object->toMetadataArray($structure)); + ], + ], $this->object->toMetadataArray($structure)); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/MetadataBagTest.php b/tests/Alchemy/Tests/Phrasea/Border/MetadataBagTest.php index fcfc20fd12..8361b97914 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/MetadataBagTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/MetadataBagTest.php @@ -37,7 +37,7 @@ class MetadataBagTest extends \PhraseanetPHPUnitAbstract $structure = self::$DI['collection']->get_databox()->get_meta_structure(); $valueMono = new Mono('mono value'); - $valueMulti = new Multi(array('multi', 'value')); + $valueMulti = new Multi(['multi', 'value']); $monoAdded = $multiAdded = false; @@ -59,22 +59,22 @@ class MetadataBagTest extends \PhraseanetPHPUnitAbstract $this->markTestSkipped('Unable to find multi value field'); } - $this->assertEquals(array( - array( + $this->assertEquals([ + [ 'meta_struct_id' => $monoAdded, 'value' => 'mono value', 'meta_id' => null - ), - array( + ], + [ 'meta_struct_id' => $multiAdded, 'value' => 'multi', 'meta_id' => null - ), - array( + ], + [ 'meta_struct_id' => $multiAdded, 'value' => 'value', 'meta_id' => null - ), - ), $this->object->toMetadataArray($structure)); + ], + ], $this->object->toMetadataArray($structure)); } } diff --git a/tests/Alchemy/Tests/Phrasea/Border/VisaTest.php b/tests/Alchemy/Tests/Phrasea/Border/VisaTest.php index a449d0fd85..e4743a2ff6 100644 --- a/tests/Alchemy/Tests/Phrasea/Border/VisaTest.php +++ b/tests/Alchemy/Tests/Phrasea/Border/VisaTest.php @@ -27,14 +27,14 @@ class VisaTest extends \PhraseanetPHPUnitAbstract { $visa = new Visa(); - $this->assertEquals(array(), $visa->getResponses()); + $this->assertEquals([], $visa->getResponses()); $response = new Response(true, new Filename(self::$DI['app'])); $visa->addResponse($response); $response2 = new Response(false, new Filename(self::$DI['app'])); $visa->addResponse($response2); - $this->assertSame(array($response, $response2), $visa->getResponses()); + $this->assertSame([$response, $response2], $visa->getResponses()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Cache/ConnectionFactoryTest.php b/tests/Alchemy/Tests/Phrasea/Cache/ConnectionFactoryTest.php index 5e6166e7c1..ef7c0bab52 100644 --- a/tests/Alchemy/Tests/Phrasea/Cache/ConnectionFactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Cache/ConnectionFactoryTest.php @@ -31,7 +31,7 @@ class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase } $factory = new ConnectionFactory(); - $redis = $factory->getRedisConnection(array('host' => 'unknown-host', 'port' => 666)); + $redis = $factory->getRedisConnection(['host' => 'unknown-host', 'port' => 666]); $this->assertInstanceOf('Redis', $redis); $this->assertSame($redis, $factory->getRedisConnection()); @@ -61,7 +61,7 @@ class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase } $factory = new ConnectionFactory(); - $memcached = $factory->getMemcachedConnection(array('host' => 'unknown-host', 'port' => 666)); + $memcached = $factory->getMemcachedConnection(['host' => 'unknown-host', 'port' => 666]); $this->assertInstanceOf('Memcached', $memcached); $this->assertSame($memcached, $factory->getMemcachedConnection()); @@ -91,7 +91,7 @@ class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase } $factory = new ConnectionFactory(); - $memcache = $factory->getMemcacheConnection(array('host' => 'unknown-host', 'port' => 666)); + $memcache = $factory->getMemcacheConnection(['host' => 'unknown-host', 'port' => 666]); $this->assertInstanceOf('Memcache', $memcache); $this->assertSame($memcache, $factory->getMemcacheConnection()); diff --git a/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php b/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php index a65287cd8d..e43fc97717 100644 --- a/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php @@ -17,26 +17,26 @@ class FactoryTest extends \PHPUnit_Framework_TestCase } $factory = new Factory(new ConnectionFactory()); - $this->assertInstanceOf($expected, $factory->create($name, array())); + $this->assertInstanceOf($expected, $factory->create($name, [])); } public function provideCacheTypes() { - return array( - array('apc', 'apc', 'Alchemy\Phrasea\Cache\ApcCache'), - array('apccache', 'apc', 'Alchemy\Phrasea\Cache\ApcCache'), - array('array', null, 'Alchemy\Phrasea\Cache\ArrayCache'), - array('arraycache', null, 'Alchemy\Phrasea\Cache\ArrayCache'), - array('memcache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'), - array('memcachecache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'), - array('memcached', 'memcached', 'Alchemy\Phrasea\Cache\MemcachedCache'), - array('memcachecached', 'memcached', 'Alchemy\Phrasea\Cache\MemcachedCache'), - array('redis', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'), - array('rediscache', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'), - array('wincache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'), - array('wincachecache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'), - array('xcache', 'xcache', 'Alchemy\Phrasea\Cache\XcacheCache'), - array('xcachecache', 'xcache', 'Alchemy\Phrasea\Cache\XcacheCache'), - ); + return [ + ['apc', 'apc', 'Alchemy\Phrasea\Cache\ApcCache'], + ['apccache', 'apc', 'Alchemy\Phrasea\Cache\ApcCache'], + ['array', null, 'Alchemy\Phrasea\Cache\ArrayCache'], + ['arraycache', null, 'Alchemy\Phrasea\Cache\ArrayCache'], + ['memcache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'], + ['memcachecache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'], + ['memcached', 'memcached', 'Alchemy\Phrasea\Cache\MemcachedCache'], + ['memcachecached', 'memcached', 'Alchemy\Phrasea\Cache\MemcachedCache'], + ['redis', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'], + ['rediscache', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'], + ['wincache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'], + ['wincachecache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'], + ['xcache', 'xcache', 'Alchemy\Phrasea\Cache\XcacheCache'], + ['xcachecache', 'xcache', 'Alchemy\Phrasea\Cache\XcacheCache'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Cache/ManagerTest.php b/tests/Alchemy/Tests/Phrasea/Cache/ManagerTest.php index a5f39f66ce..32e3311406 100644 --- a/tests/Alchemy/Tests/Phrasea/Cache/ManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Cache/ManagerTest.php @@ -33,7 +33,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase private function createEmptyRegistry() { - file_put_contents($this->file, $this->compiler->compile(array())); + file_put_contents($this->file, $this->compiler->compile([])); } public function testFactoryCreateOne() @@ -54,7 +54,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $cache = $this->getMock('Alchemy\Phrasea\Cache\Cache'); $name = 'array'; - $values = array('option', 'value'); + $values = ['option', 'value']; $factory->expects($this->once()) ->method('create') @@ -72,7 +72,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testNoCompilationIfNoChange() { - file_put_contents($this->file, $this->compiler->compile(array("custom-type" => "array"))); + file_put_contents($this->file, $this->compiler->compile(["custom-type" => "array"])); $compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler') ->disableOriginalConstructor() @@ -90,7 +90,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $cache = $this->getMock('Alchemy\Phrasea\Cache\Cache'); $name = 'array'; - $values = array('option', 'value'); + $values = ['option', 'value']; $factory->expects($this->once()) ->method('create') @@ -103,11 +103,11 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testNoCompilationIfNoChangeWithMultiple() { - file_put_contents($this->file, $this->compiler->compile(array( + file_put_contents($this->file, $this->compiler->compile([ "custom-type" => "array", "another-type" => "array", "yet-another-type" => "array", - ))); + ])); $compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler') ->disableOriginalConstructor() @@ -125,7 +125,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $cache = $this->getMock('Alchemy\Phrasea\Cache\Cache'); $name = 'array'; - $values = array('option', 'value'); + $values = ['option', 'value']; $factory->expects($this->exactly(3)) ->method('create') @@ -146,9 +146,9 @@ class ManagerTest extends \PHPUnit_Framework_TestCase public function testUnknownCacheReturnsArrayCacheAndLogs() { - file_put_contents($this->file, $this->compiler->compile(array( + file_put_contents($this->file, $this->compiler->compile([ "custom-type" => "unknown", - ))); + ])); $compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler') ->disableOriginalConstructor() @@ -169,7 +169,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $cache = $this->getMock('Alchemy\Phrasea\Cache\Cache'); $name = 'unknown'; - $values = array('option', 'value'); + $values = ['option', 'value']; $factory->expects($this->at(0)) ->method('create') @@ -178,7 +178,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase $factory->expects($this->at(1)) ->method('create') - ->with('array', array()) + ->with('array', []) ->will($this->returnValue($cache)); $manager = new Manager($compiler, $this->file, $logger, $factory); diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/BowerInstallTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/BowerInstallTest.php index 430f811031..da626abb8f 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/BowerInstallTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/BowerInstallTest.php @@ -24,7 +24,7 @@ class BowerInstallTest extends \PhraseanetPHPUnitAbstract ->getMock(); $mockedCommand = $this->getMockBuilder('Symfony\Component\Console\Command\Command') - ->setMethods(array('execute')) + ->setMethods(['execute']) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php index bc6c04b95e..0637e6a616 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/ComposerInstallTest.php @@ -21,7 +21,7 @@ class ComposerInstallTest extends \PhraseanetPHPUnitAbstract self::$DI['cli']['driver.composer']->expects($this->at(1)) ->method('command') - ->with(array('install', '--optimize-autoloader', '--quiet', '--no-interaction', '--dev')); + ->with(['install', '--optimize-autoloader', '--quiet', '--no-interaction', '--dev']); $command = new ComposerInstall(); $command->setContainer(self::$DI['cli']); diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/InstallAllTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/InstallAllTest.php index fffc011946..ae82cbe3ca 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/InstallAllTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/InstallAllTest.php @@ -16,12 +16,12 @@ class InstallAllTest extends \PhraseanetPHPUnitAbstract ->getMock(); $n = 0; - foreach (array( + foreach ([ 'dependencies:composer', 'dependencies:bower' - ) as $name) { + ] as $name) { $command = $this->getMockBuilder('Symfony\Component\Console\Command\Command') - ->setMethods(array('execute')) + ->setMethods(['execute']) ->disableOriginalConstructor() ->getMock(); $command->expects($this->once()) diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/BowerDriverTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/BowerDriverTest.php index 3759fae184..4d7fb73975 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/BowerDriverTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/BowerDriverTest.php @@ -19,7 +19,7 @@ class BowerDriverTest extends \PHPUnit_Framework_TestCase $finder = new PhpExecutableFinder(); $php = $finder->find(); - $driver = BowerDriver::create(array('bower.binaries' => $php)); + $driver = BowerDriver::create(['bower.binaries' => $php]); $this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\BowerDriver', $driver); $this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary()); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/ComposerDriverTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/ComposerDriverTest.php index 9f9c1c2082..966f8bd515 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/ComposerDriverTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/ComposerDriverTest.php @@ -19,7 +19,7 @@ class ComposerDriverTest extends \PHPUnit_Framework_TestCase $finder = new PhpExecutableFinder(); $php = $finder->find(); - $driver = ComposerDriver::create(array('composer.binaries' => $php)); + $driver = ComposerDriver::create(['composer.binaries' => $php]); $this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\ComposerDriver', $driver); $this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary()); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/GruntDriverTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/GruntDriverTest.php index ba1bfa01d5..945b4cb4d7 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/GruntDriverTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/GruntDriverTest.php @@ -19,7 +19,7 @@ class GruntDriverTest extends \PHPUnit_Framework_TestCase $finder = new PhpExecutableFinder(); $php = $finder->find(); - $driver = GruntDriver::create(array('grunt.binaries' => $php)); + $driver = GruntDriver::create(['grunt.binaries' => $php]); $this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\GruntDriver', $driver); $this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary()); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/UglifyJsDriverTest.php b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/UglifyJsDriverTest.php index bb68073093..a07503c74e 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/UglifyJsDriverTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Developper/Utils/UglifyJsDriverTest.php @@ -19,7 +19,7 @@ class UglifyJsDriverTest extends \PHPUnit_Framework_TestCase $finder = new PhpExecutableFinder(); $php = $finder->find(); - $driver = UglifyJsDriver::create(array('uglifyjs.binaries' => $php)); + $driver = UglifyJsDriver::create(['uglifyjs.binaries' => $php]); $this->assertInstanceOf('Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver', $driver); $this->assertEquals($php, $driver->getProcessBuilderFactory()->getBinary()); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php b/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php index 9aabf2f3b0..b42a15c2f4 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php @@ -28,7 +28,7 @@ class AddPluginTest extends PluginCommandTestCase self::$DI['cli']['temporary-filesystem'] = $this->createTemporaryFilesystemMock(); self::$DI['cli']['plugins.autoloader-generator'] = $this->createPluginsAutoloaderGeneratorMock(); - self::$DI['cli']['plugins.explorer'] = array(self::$DI['cli']['plugins.directory'].'/TestPlugin'); + self::$DI['cli']['plugins.explorer'] = [self::$DI['cli']['plugins.directory'].'/TestPlugin']; self::$DI['cli']['plugins.plugins-validator'] = $this->createPluginsValidatorMock(); self::$DI['cli']['filesystem'] = $this->createFilesystemMock(); self::$DI['cli']['plugins.composer-installer'] = $this->createComposerInstallerMock(); @@ -71,7 +71,7 @@ class AddPluginTest extends PluginCommandTestCase self::$DI['cli']['plugins.autoloader-generator']->expects($this->once()) ->method('write') - ->with(array($manifest)); + ->with([$manifest]); $result = $command->execute($input, $output); diff --git a/tests/Alchemy/Tests/Phrasea/Command/Setup/XSendFileMappingGeneratorTest.php b/tests/Alchemy/Tests/Phrasea/Command/Setup/XSendFileMappingGeneratorTest.php index a1f5921dcc..c09b628ba2 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Setup/XSendFileMappingGeneratorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Setup/XSendFileMappingGeneratorTest.php @@ -62,9 +62,9 @@ class XSendFileMappingGeneratorTest extends \PhraseanetPHPUnitAbstract public function provideVariousOptions() { - return array( - array(true), - array(false), - ); + return [ + [true], + [false], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Command/UpgradeDBDatasTest.php b/tests/Alchemy/Tests/Phrasea/Command/UpgradeDBDatasTest.php index 0b7d84720b..687113974f 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/UpgradeDBDatasTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/UpgradeDBDatasTest.php @@ -29,12 +29,12 @@ class UpgradeDBDatasTest extends \PHPUnit_Framework_TestCase */ public function testSetUpgrades() { - $this->object->setUpgrades(array()); - $this->assertEquals(array(), $this->object->getUpgrades()); + $this->object->setUpgrades([]); + $this->assertEquals([], $this->object->getUpgrades()); - $upgrades = array( + $upgrades = [ new Step31(new Application('test')) - ); + ]; $this->object->setUpgrades($upgrades); $this->assertEquals($upgrades, $this->object->getUpgrades()); } @@ -44,17 +44,17 @@ class UpgradeDBDatasTest extends \PHPUnit_Framework_TestCase */ public function testAddUpgrade() { - $this->assertEquals(array(), $this->object->getUpgrades()); + $this->assertEquals([], $this->object->getUpgrades()); $step31 = new Step31(new Application('test')); $this->object->addUpgrade($step31); - $this->assertEquals(array($step31), $this->object->getUpgrades()); + $this->assertEquals([$step31], $this->object->getUpgrades()); $step35 = new Step35(new Application('test')); $this->object->addUpgrade($step35); - $this->assertEquals(array($step31, $step35), $this->object->getUpgrades()); + $this->assertEquals([$step31, $step35], $this->object->getUpgrades()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php index 9e236791a6..52077d2fb3 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php @@ -9,7 +9,7 @@ use Alchemy\Phrasea\Border\File; class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { protected $client; - public static $createdCollections = array(); + public static $createdCollections = []; public function tearDown() { @@ -28,7 +28,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } } - self::$createdCollections = array(); + self::$createdCollections = []; // /!\ re enable collection self::$DI['collection']->enable(self::$DI['app']['phraseanet.appbox']); @@ -40,7 +40,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app'] = new Application('test'); self::giveRightsToUser(self::$DI['app'], self::$DI['user']); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); parent::tearDownAfterClass(); @@ -144,9 +144,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $prefs = ' 0 my_new_value '; - $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', array( + $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', [ 'str' => $prefs - )); + ]); $json = $this->getJson(self::$DI['client']->getResponse()); $this->assertTrue($json->success); @@ -165,9 +165,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $prefs = ' '; - $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', array( + $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', [ 'str' => $prefs - )); + ]); $json = $this->getJson(self::$DI['client']->getResponse()); $this->assertFalse($json->success); @@ -273,9 +273,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/order/admins/', array( - 'admins' => array(self::$DI['user_alt1']->get_id()) - )); + self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/order/admins/', [ + 'admins' => [self::$DI['user_alt1']->get_id()] + ]); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/collection/' . self::$DI['collection']->get_base_id() . '/?success=1'); @@ -289,9 +289,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/', array( + self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/', [ 'pub_wm' => 'wm', - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -326,9 +326,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/', array( + $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/', [ 'pub_wm' => 'wm', - )); + ]); $json = $this->getJson(self::$DI['client']->getResponse()); $this->assertTrue($json->success); @@ -346,9 +346,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOneCollection(); - self::$DI['client']->request('POST', '/admin/collection/' . $collection->get_base_id() . '/rename/', array( + self::$DI['client']->request('POST', '/admin/collection/' . $collection->get_base_id() . '/rename/', [ 'name' => 'test_rename_coll' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertEquals('/admin/collection/' . $collection->get_base_id() . '/?success=1&reload-tree=1', self::$DI['client']->getResponse()->headers->get('location')); @@ -363,13 +363,13 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOneCollection(); - self::$DI['client']->request('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', array( - 'labels' => array( + self::$DI['client']->request('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', [ + 'labels' => [ 'en' => 'english label', 'fr' => 'french label', 'ru' => 'russian label', - ) - )); + ] + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertContains('/admin/collection/'.$collection->get_base_id().'/', self::$DI['client']->getResponse()->headers->get('location')); @@ -430,9 +430,9 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOneCollection(); - $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/rename/', array( + $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/rename/', [ 'name' => 'test_rename_coll' - )); + ]); $json = $this->getJson(self::$DI['client']->getResponse()); $this->assertTrue($json->success); @@ -450,15 +450,15 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOneCollection(); - $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', array( - 'labels' => array( + $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', [ + 'labels' => [ 'nl' => 'netherlands label', 'de' => 'german label', 'fr' => 'label français', 'en' => 'label à l\'anglaise', 'ru' => 'label à la russe', - ) - )); + ] + ]); $json = $this->getJson(self::$DI['client']->getResponse()); $this->assertTrue($json->success); @@ -540,7 +540,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $stmt = $databox->get_connection()->prepare($sql); $i = 0; while ($i < 502) { - $stmt->execute(array( + $stmt->execute([ ':coll_id' => $collection->get_coll_id(), ':parent_record_id' => 0, ':type' => 'unknown', @@ -548,7 +548,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ':uuid' => \uuid::generate_v4(), ':originalname' => null, ':mime' => null, - )); + ]); $i ++; } @@ -623,10 +623,10 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; self::$DI['app']['filesystem']->copy(__DIR__ . '/../../../../../files/p4logo.jpg', $target); - $files = array( + $files = [ 'newLogo' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') - ); - self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/', array(), $files); + ]; + self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/', [], $files); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/collection/' . self::$DI['collection']->get_base_id() . '/?success=1'); $this->assertEquals(1, count(\collection::getLogo(self::$DI['collection']->get_base_id(), self::$DI['app']))); } @@ -670,10 +670,10 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; self::$DI['app']['filesystem']->copy(__DIR__ . '/../../../../../files/p4logo.jpg', $target); - $files = array( + $files = [ 'newWm' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') - ); - self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/', array(), $files); + ]; + self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/', [], $files); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/collection/' . self::$DI['collection']->get_base_id() . '/?success=1'); $this->assertEquals(1, count(\collection::getWatermark(self::$DI['collection']->get_base_id()))); } @@ -717,10 +717,10 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; self::$DI['app']['filesystem']->copy(__DIR__ . '/../../../../../files/p4logo.jpg', $target); - $files = array( + $files = [ 'newStamp' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') - ); - self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/stamp-logo/', array(), $files); + ]; + self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/stamp-logo/', [], $files); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/collection/' . self::$DI['collection']->get_base_id() . '/?success=1'); $this->assertEquals(1, count(\collection::getStamp(self::$DI['collection']->get_base_id()))); } @@ -765,10 +765,10 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; self::$DI['app']['filesystem']->copy(__DIR__ . '/../../../../../files/p4logo.jpg', $target); - $files = array( + $files = [ 'newBanner' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') - ); - self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/banner/', array(), $files); + ]; + self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/banner/', [], $files); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/collection/' . self::$DI['collection']->get_base_id() . '/?success=1'); $this->assertEquals(1, count(\collection::getPresentation(self::$DI['collection']->get_base_id()))); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php index 6512fac74b..a07101b91f 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php @@ -26,10 +26,10 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); self::$DI['app']['phraseanet.configuration-tester']->getRequirements(); - self::$DI['client']->request('GET', '/admin/dashboard/', array( + self::$DI['client']->request('GET', '/admin/dashboard/', [ 'flush_cache' => 'ok', 'email' => 'sent' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -56,9 +56,9 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailTest'); - self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', array( + self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', [ 'email' => 'user-test@phraseanet.com' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegexp('/email=/', self::$DI['client']->getResponse()->headers->get('location')); @@ -71,9 +71,9 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', array( + self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/', [ 'email' => 'user-test-phraseanet.com' - )); + ]); $this->assertEquals(400, self::$DI['client']->getResponse()->getStatusCode()); } @@ -114,9 +114,9 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $admins[] = $user->get_id(); - self::$DI['client']->request('POST', '/admin/dashboard/add-admins/', array( + self::$DI['client']->request('POST', '/admin/dashboard/add-admins/', [ 'admins' => $admins - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php index b50b41aa10..8f98fd0f50 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php @@ -9,7 +9,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { protected $client; - protected static $createdCollections = array(); + protected static $createdCollections = []; public function setUp() { @@ -109,10 +109,10 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = \collection::create(self::$DI['app'], $databox, self::$DI['app']['phraseanet.appbox'], 'TESTTODELETE'); - $this->XMLHTTPRequest('POST', '/admin/databox/' . $databox->get_sbas_id() . '/collections/order/', array( - 'order' => array( + $this->XMLHTTPRequest('POST', '/admin/databox/' . $databox->get_sbas_id() . '/collections/order/', [ + 'order' => [ 2 => $collection->get_base_id() - ))); + ]]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); @@ -165,9 +165,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOneCollection(); - self::$DI['client']->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/cgus/', array( - 'TOU' => array('fr_FR' => 'Test update CGUS') - )); + self::$DI['client']->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/cgus/', [ + 'TOU' => ['fr_FR' => 'Test update CGUS'] + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -186,9 +186,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $cgusUpdate = 'Test update CGUS'; - $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/', array( - 'TOU' => array('fr_FR' => $cgusUpdate) - )); + $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/', [ + 'TOU' => ['fr_FR' => $cgusUpdate] + ]); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/?success=1'); @@ -373,9 +373,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/indexable/', array( + $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/indexable/', [ 'indexable' => 1 - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -427,9 +427,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOnecollection(); - self::$DI['client']->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/view-name/', array( + self::$DI['client']->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/view-name/', [ 'viewname' => 'hello' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -457,9 +457,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals('old_databox_name', $databox->get_viewname()); - $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/view-name/', array( + $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/view-name/', [ 'viewname' => 'new_databox_name' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -506,9 +506,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $collection = $this->createOneCollection(); $collection->unmount_collection(self::$DI['app']); - self::$DI['client']->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/collection/' . $collection->get_coll_id() . '/mount/', array( + self::$DI['client']->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/collection/' . $collection->get_coll_id() . '/mount/', [ 'othcollsel' => self::$DI['collection']->get_base_id() - )); + ]); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/databox/' . $collection->get_sbas_id() . '/?mount=ok'); } @@ -522,10 +522,10 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; self::$DI['app']['filesystem']->copy(__DIR__ . '/../../../../../files/p4logo.jpg', $target); - $files = array( + $files = [ 'newLogoPdf' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') - ); - self::$DI['client']->request('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/logo/', array(), $files); + ]; + self::$DI['client']->request('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/logo/', [], $files); $this->checkRedirection(self::$DI['client']->getResponse(), '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/?success=1'); $this->assertNotEmpty(\databox::getPrintLogo(self::$DI['collection']->get_sbas_id())); } @@ -614,14 +614,14 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); $base = self::$DI['record_1']->get_databox(); - $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/labels/', array( - 'labels' => array( + $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/labels/', [ + 'labels' => [ 'fr' => 'frenchy label', 'en' => '', 'de' => 'Jaja label', 'nl' => 'dutch label', - ) - )); + ] + ]); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('content-type')); @@ -657,7 +657,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $stmt = $base->get_connection()->prepare($sql); $i = 0; while ($i < 502) { - $stmt->execute(array( + $stmt->execute([ ':coll_id' => $collection->get_coll_id(), ':parent_record_id' => 0, ':type' => 'unknown', @@ -665,7 +665,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ':uuid' => \uuid::generate_v4(), ':originalname' => null, ':mime' => null, - )); + ]); $i++; } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php index 27134aa9ae..fbec227efc 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php @@ -15,28 +15,28 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testGetSlash($type, $errorMsgId) { - self::$DI['client']->request('GET', '/admin/databoxes/', array( + self::$DI['client']->request('GET', '/admin/databoxes/', [ $type => $errorMsgId - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } public function msgProvider() { - return array( - array('error', 'already-started'), - array('error', 'scheduler-started'), - array('error', 'unknow'), - array('error', 'bad-email'), - array('error', 'special-chars'), - array('error', 'base-failed'), - array('error', 'database-failed'), - array('error', 'no-empty'), - array('success', 'restart'), - array('success', 'mount-ok'), - array('success', 'database-ok'), - ); + return [ + ['error', 'already-started'], + ['error', 'scheduler-started'], + ['error', 'unknow'], + ['error', 'bad-email'], + ['error', 'special-chars'], + ['error', 'base-failed'], + ['error', 'database-failed'], + ['error', 'no-empty'], + ['success', 'restart'], + ['success', 'mount-ok'], + ['success', 'database-ok'], + ]; } /** @@ -73,9 +73,9 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $base = $this->createDatabox(); $base->unmount_databox(); - self::$DI['client']->request('POST', '/admin/databoxes/mount/', array( + self::$DI['client']->request('POST', '/admin/databoxes/mount/', [ 'new_dbname' => 'unit_test_db' - )); + ]); $response = self::$DI['client']->getResponse(); @@ -104,9 +104,9 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - self::$DI['client']->request('POST', '/admin/databoxes/', array( + self::$DI['client']->request('POST', '/admin/databoxes/', [ 'new_dbname' => '' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -120,9 +120,9 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(true); - self::$DI['client']->request('POST', '/admin/databoxes/', array( + self::$DI['client']->request('POST', '/admin/databoxes/', [ 'new_dbname' => 'ééààèè' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -138,10 +138,10 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->createDatabase(); - self::$DI['client']->request('POST', '/admin/databoxes/', array( + self::$DI['client']->request('POST', '/admin/databoxes/', [ 'new_dbname' => 'unit_test_db', 'new_data_template' => 'fr-simple', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php index 1f0576507e..89a2882e92 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php @@ -123,10 +123,10 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); $databox = array_shift($databoxes); - $fieldObjects = array(); + $fieldObjects = []; // create two fields - $fields = array( - array( + $fields = [ + [ 'sbas-id' => $databox->get_sbas_id(), 'name' => 'testfield' . mt_rand(), 'multi' => true, @@ -143,7 +143,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'dces-element' => null, 'vocabulary-type' => null, 'vocabulary-restricted' => false, - ), array( + ], [ 'sbas-id' => $databox->get_sbas_id(), 'name' => 'testfield' . mt_rand(), 'multi' => true, @@ -160,7 +160,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'dces-element' => null, 'vocabulary-type' => null, 'vocabulary-restricted' => false, - )); + ]]; foreach ($fields as $fieldData) { $field = \databox_field::create(self::$DI['app'], $databox, $fieldData['name'], $fieldData['multi']); @@ -190,7 +190,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $body[count($body) - 1]['readonly'] = true; $body[count($body) - 1]['required'] = false; - self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), array(), array(), array(), json_encode($body)); + self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], [], json_encode($body)); $response = self::$DI['client']->getResponse()->getContent(); @@ -214,7 +214,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); $databox = array_shift($databoxes); - $body = json_encode(array( + $body = json_encode([ 'sbas-id' => $databox->get_sbas_id(), 'name' => 'testfield' . mt_rand(), 'multi' => true, @@ -223,12 +223,12 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'business' => false, 'indexable' => true, 'required' => true, - 'labels' => array( + 'labels' => [ 'en' => 'Label', 'fr' => 'Libellé', 'de' => null, 'nl' => null, - ), + ], 'separator' => '=;', 'readonly' => false, 'type' => 'string', @@ -237,9 +237,9 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'dces-element' => null, 'vocabulary-type' => 'User', 'vocabulary-restricted' => true, - )); + ]); - self::$DI['client']->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), array(), array(), array(), $body); + self::$DI['client']->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], [], $body); $response = self::$DI['client']->getResponse()->getContent(); $this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type")); @@ -308,7 +308,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $data['business'] = true; $data['vocabulary-type'] = 'User'; - self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), array(), array(), array(), json_encode($data)); + self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], [], json_encode($data)); $response = self::$DI['client']->getResponse()->getContent(); $this->assertEquals($data, json_decode($response, true)); @@ -329,7 +329,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $data['business'] = true; $data['vocabulary-type'] = 'User'; - self::$DI['client']->request("DELETE", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), array(), array(), array(), json_encode($data)); + self::$DI['client']->request("DELETE", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], [], json_encode($data)); $response = self::$DI['client']->getResponse()->getContent(); $this->assertEquals('', $response); @@ -345,7 +345,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract private function assertField($field) { - $properties = array( + $properties = [ 'name', 'multi', 'thumbtitle', @@ -361,7 +361,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'dces-element', 'vocabulary-type', 'vocabulary-restricted' - ); + ]; foreach ($properties as $property) { $this->assertArrayHasKey($property, $field); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php index daf51e7126..7c067f7f18 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php @@ -31,7 +31,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic $feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser(self::$DI['app']['acl']->get(self::$DI['user'])); $count = sizeof($feeds); - $crawler = self::$DI['client']->request('POST', '/admin/publications/create/', array("title" => "hello", "subtitle" => "coucou", "base_id" => self::$DI['collection']->get_base_id())); + $crawler = self::$DI['client']->request('POST', '/admin/publications/create/', ["title" => "hello", "subtitle" => "coucou", "base_id" => self::$DI['collection']->get_base_id()]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect('/admin/publications/list/')); @@ -54,11 +54,11 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic $feed = $this->insertOneFeed(self::$DI['user']); - self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/update/", array( + self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/update/", [ 'title' => 'test' , 'subtitle' => 'test' , 'public' => '1' - )); + ]); $feed = self::$DI['app']['EM']->find('Alchemy\Phrasea\Model\Entities\Feed', $feed->getId()); @@ -78,12 +78,12 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic { $feed = $this->insertOneFeed(self::$DI['user']); - self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/update/", array( + self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/update/", [ 'title' => 'test' , 'subtitle' => 'test' , 'public' => '1' , 'base_id' => self::$DI['collection']->get_base_id() - )); + ]); $this->assertTrue( strpos( @@ -111,7 +111,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic { $feed = $this->insertOneFeed(self::$DI['user_alt1']); - self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/iconupload/", array(), array(), array('HTTP_ACCEPT' => 'application/json')); + self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/iconupload/", [], [], ['HTTP_ACCEPT' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -125,8 +125,8 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic self::$DI['client']->request( "POST" , "/admin/publications/feed/" . $feed->getId() . "/iconupload/" - , array() - , array('Filedata' => array('error' => 1)) + , [] + , ['Filedata' => ['error' => 1]] ); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -143,8 +143,8 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic self::$DI['client']->request( "POST" , "/admin/publications/feed/" . $feed->getId() . "/iconupload/" - , array() - , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../../files/test007.ppt')) + , [] + , ['Filedata' => ['error' => 0, 'tmp_name' => __DIR__ . '/../../../../../files/test007.ppt']] ); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -158,18 +158,18 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic { $feed = $this->insertOneFeed(self::$DI['user']); - $files = array( - 'files' => array( + $files = [ + 'files' => [ new \Symfony\Component\HttpFoundation\File\UploadedFile( __DIR__ . '/../../../../../files/logocoll.gif', 'logocoll.gif' ) - ) - ); + ] + ]; self::$DI['client']->request( "POST" , "/admin/publications/feed/" . $feed->getId() . "/iconupload/" - , array() + , [] , $files ); @@ -186,9 +186,9 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic { $feed = $this->insertOneFeed(self::$DI['user']); - self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/addpublisher/", array( + self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/addpublisher/", [ 'usr_id' => self::$DI['user_alt1']->get_id() - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -224,9 +224,9 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic { $feed = $this->insertOneFeed(self::$DI['user']); - self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/removepublisher/", array( + self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/removepublisher/", [ 'usr_id' => self::$DI['user_alt1']->get_id() - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php index 93df91f20a..fc16a533ee 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php @@ -13,7 +13,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->authenticate(self::$DI['app']); - self::$DI['client']->request('GET', '/admin/', array('section' => 'base:featured')); + self::$DI['client']->request('GET', '/admin/', ['section' => 'base:featured']); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); self::$DI['client']->request('GET', '/admin/'); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SearchEngineTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SearchEngineTest.php index d0c29d6853..860908dfc5 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SearchEngineTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SearchEngineTest.php @@ -37,10 +37,10 @@ class SearchEngineTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $app = new Application('test'); - return array( - array(new PhraseaEngine($app)), - array(new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)), - ); + return [ + [new PhraseaEngine($app)], + [new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php index 9574fbd3c4..b916b52e50 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SubdefsTest.php @@ -34,11 +34,11 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPostRouteAddSubdef() { $name = $this->getSubdefName(); - self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", array('add_subdef' => array( + self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", ['add_subdef' => [ 'class' => 'thumbnail', 'name' => $name, 'group' => 'image' - ))); + ]]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $subdefs = new \databox_subdefsStructure(new \databox(self::$DI['app'], $this->databox->get_sbas_id())); @@ -51,7 +51,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $subdefs = $this->databox->get_subdef_structure(); $name = $this->getSubdefName(); $subdefs->add_subdef("image", $name, "thumbnail"); - self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", array('delete_subdef' => 'image_' . $name)); + self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", ['delete_subdef' => 'image_' . $name]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); try { $subdefs->get_subdef("image", $name); @@ -67,18 +67,18 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $name = $this->getSubdefName(); $subdefs->add_subdef("image", $name, "thumbnail"); self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/" - , array('subdefs' => array( + , ['subdefs' => [ 'image_' . $name - ) + ] , 'image_' . $name . '_class' => 'thumbnail' , 'image_' . $name . '_downloadable' => 0 , 'image_' . $name . '_mediatype' => 'image' - , 'image_' . $name . '_image' => array( + , 'image_' . $name . '_image' => [ 'size' => 400, 'resolution' => 83, 'strip' => 0, 'quality' => 90, - )) + ]] ); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/TaskManagerTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/TaskManagerTest.php index cda670d294..7bbc95d8a5 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/TaskManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/TaskManagerTest.php @@ -30,10 +30,10 @@ class TaskManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRootPostCreateTask() { - $parameters = array( + $parameters = [ 'job-name' => 'Alchemy\Phrasea\TaskManager\Job\NullJob', '_token' => 'token', - ); + ]; self::$DI['client']->request('POST', '/admin/task-manager/tasks/create', $parameters); $this->assertEquals(302, self::$DI['client']->getResponse()->getStatusCode()); @@ -42,10 +42,10 @@ class TaskManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPostCreateTaskWithWrongName() { - $parameters = array( + $parameters = [ 'job-name' => 'NoJob', '_token' => 'token', - ); + ]; self::$DI['client']->request('POST', '/admin/task-manager/tasks/create', $parameters); $this->assertFalse(self::$DI['client']->getResponse()->isOk()); @@ -177,13 +177,13 @@ class TaskManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $status = Task::STATUS_STOPPED; $settings = ''; - $parameters = array( + $parameters = [ '_token' => 'token', 'name' => $name, 'period' => $period, 'status' => $status, 'settings' => $settings, - ); + ]; self::$DI['client']->request('POST', '/admin/task-manager/task/'.$task->getId().'/save', $parameters); @@ -217,19 +217,19 @@ class TaskManagerTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testValidateInvalidXML() { - self::$DI['client']->request('POST', '/admin/task-manager/task/validate-xml', array(), array(), array(), 'Invalid XML'); + self::$DI['client']->request('POST', '/admin/task-manager/task/validate-xml', [], [], [], 'Invalid XML'); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('content-type')); - $this->assertEquals(array('success' => false), json_decode(self::$DI['client']->getResponse()->getContent(), true)); + $this->assertEquals(['success' => false], json_decode(self::$DI['client']->getResponse()->getContent(), true)); } public function testValidateXML() { - self::$DI['client']->request('POST', '/admin/task-manager/task/validate-xml', array(), array(), array(), + self::$DI['client']->request('POST', '/admin/task-manager/task/validate-xml', [], [], [], ''); $this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); $this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('content-type')); - $this->assertEquals(array('success' => true), json_decode(self::$DI['client']->getResponse()->getContent(), true)); + $this->assertEquals(['success' => true], json_decode(self::$DI['client']->getResponse()->getContent(), true)); } public function testPostTaskFacility() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php index 1e76be3770..852bc89a92 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php @@ -10,7 +10,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function setUp() { parent::setUp(); - $this->usersParameters = array("users" => implode(';', array(self::$DI['user']->get_id(), self::$DI['user_alt1']->get_id()))); + $this->usersParameters = ["users" => implode(';', [self::$DI['user']->get_id(), self::$DI['user_alt1']->get_id()])]; } public function testRouteRightsPost() @@ -34,7 +34,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $user = \User_Adapter::create(self::$DI['app'], $username, "test", $username . "@email.com", false); $id = $user->get_id(); - self::$DI['client']->request('POST', '/admin/users/delete/', array('users' => $id)); + self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => $id]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); try { @@ -48,7 +48,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteDeleteCurrentUserDoesNothing() { - self::$DI['client']->request('POST', '/admin/users/delete/', array('users' => self::$DI['user']->get_id())); + self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => self::$DI['user']->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -64,11 +64,11 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $base_id = self::$DI['collection']->get_base_id(); - self::$DI['client']->request('POST', '/admin/users/rights/apply/', array( + self::$DI['client']->request('POST', '/admin/users/rights/apply/', [ 'users' => $user->get_id(), 'values' => 'canreport_' . $base_id . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1', 'user_infos' => "user_infos[email]=" . $user->get_email(), - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $this->assertEquals("application/json", $response->headers->get("content-type")); @@ -85,15 +85,15 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteRightsApplyException() { $this->markTestIncomplete(); - $_GET = array(); + $_GET = []; $username = uniqid('user_'); $user = \User_Adapter::create(self::$DI['app'], $username, "test", $username . "@email.com", false); $base_id = self::$DI['collection']->get_base_id(); - self::$DI['client']->request('POST', '/admin/users/rights/apply/', array( + self::$DI['client']->request('POST', '/admin/users/rights/apply/', [ 'users' => $user->get_id(), 'values' => 'canreport_' . $base_id . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1', 'user_infos' => "user_infos[email]=" . $user->get_email(), - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $this->assertEquals("application/json", $response->headers->get("content-type")); @@ -107,7 +107,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $keys = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base()); $base_id = array_pop($keys); - $params = array('base_id' => $base_id, 'users' => self::$DI['user']->get_id()); + $params = ['base_id' => $base_id, 'users' => self::$DI['user']->get_id()]; self::$DI['client']->request('POST', '/admin/users/rights/quotas/', $params); $response = self::$DI['client']->getResponse(); @@ -116,9 +116,9 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteQuotaAdd() { - $params = array( + $params = [ 'base_id' => self::$DI['collection']->get_base_id() - , 'quota' => '1', 'droits' => 38, 'restes' => 15); + , 'quota' => '1', 'droits' => 38, 'restes' => 15]; self::$DI['client']->request('POST', '/admin/users/rights/quotas/apply/', $params); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); @@ -128,7 +128,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $keys = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base()); $base_id = array_pop($keys); - $params = array('base_id' => $base_id, 'users' => self::$DI['user']->get_id()); + $params = ['base_id' => $base_id, 'users' => self::$DI['user']->get_id()]; self::$DI['client']->request('POST', '/admin/users/rights/quotas/apply/', $params); $response = self::$DI['client']->getResponse(); @@ -139,7 +139,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $keys = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base()); $base_id = array_pop($keys); - $params = array('base_id' => $base_id, 'users' => self::$DI['user']->get_id()); + $params = ['base_id' => $base_id, 'users' => self::$DI['user']->get_id()]; self::$DI['client']->request('POST', '/admin/users/rights/time/', $params); $response = self::$DI['client']->getResponse(); @@ -149,7 +149,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteRightTimeSbas() { $sbas_id = self::$DI['record_1']->get_databox()->get_sbas_id(); - $params = array('sbas_id' => $sbas_id, 'users' => self::$DI['user']->get_id()); + $params = ['sbas_id' => $sbas_id, 'users' => self::$DI['user']->get_id()]; self::$DI['client']->request('POST', '/admin/users/rights/time/sbas/', $params); $response = self::$DI['client']->getResponse(); @@ -166,7 +166,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $dmin = $date->format(DATE_ATOM); $date->modify("+30 days"); $dmax = $date->format(DATE_ATOM); - self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', array('base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id())); + self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', ['base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $user->delete(); @@ -182,7 +182,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $dmin = $date->format(DATE_ATOM); $date->modify("+30 days"); $dmax = $date->format(DATE_ATOM); - self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', array('sbas_id' => $sbas_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id())); + self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', ['sbas_id' => $sbas_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $user->delete(); @@ -197,7 +197,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $dmin = $date->format(DATE_ATOM); $date->modify("+30 days"); $dmax = $date->format(DATE_ATOM); - self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', array('dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id())); + self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', ['dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertEquals(400, $response->getStatusCode()); $user->delete(); @@ -207,7 +207,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $keys = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base()); $base_id = array_pop($keys); - $params = array('base_id' => $base_id, 'users' => self::$DI['user']->get_id()); + $params = ['base_id' => $base_id, 'users' => self::$DI['user']->get_id()]; self::$DI['client']->request('POST', '/admin/users/rights/masks/', $params); $response = self::$DI['client']->getResponse(); @@ -220,9 +220,9 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $base_id = self::$DI['collection']->get_base_id(); $username = uniqid('user_'); $user = \User_Adapter::create(self::$DI['app'], $username, "test", $username . "@email.com", false); - self::$DI['client']->request('POST', '/admin/users/rights/masks/apply/', array( + self::$DI['client']->request('POST', '/admin/users/rights/masks/apply/', [ 'base_id' => $base_id, 'vand_and', 'vand_or', 'vxor_or', 'vxor_and' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $user->delete(); @@ -246,7 +246,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteThSearch() { - self::$DI['client']->request('GET', '/admin/users/typeahead/search/', array('term' => 'admin')); + self::$DI['client']->request('GET', '/admin/users/typeahead/search/', ['term' => 'admin']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $this->assertEquals("application/json", $response->headers->get("content-type")); @@ -262,9 +262,9 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $username = uniqid('user_'); $user = \User_Adapter::create(self::$DI['app'], $username, "test", $username . "@email.com", false); - self::$DI['client']->request('POST', '/admin/users/apply_template/', array( + self::$DI['client']->request('POST', '/admin/users/apply_template/', [ 'template' => $template->get_id() - , 'users' => $user->get_id()) + , 'users' => $user->get_id()] ); $response = self::$DI['client']->getResponse(); @@ -276,7 +276,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteCreateException() { - self::$DI['client']->request('POST', '/admin/users/create/', array('value' => '', 'template' => '1')); + self::$DI['client']->request('POST', '/admin/users/create/', ['value' => '', 'template' => '1']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $this->assertEquals("application/json", $response->headers->get("content-type")); @@ -287,7 +287,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteCreateExceptionUser() { - self::$DI['client']->request('POST', '/admin/users/create/', array('value' => '', 'template' => '0')); + self::$DI['client']->request('POST', '/admin/users/create/', ['value' => '', 'template' => '0']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $this->assertEquals("application/json", $response->headers->get("content-type")); @@ -301,11 +301,11 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation'); $username = uniqid('user_'); - self::$DI['client']->request('POST', '/admin/users/create/', array( + self::$DI['client']->request('POST', '/admin/users/create/', [ 'value' => $username . "@email.com", 'template' => '0', 'validate_mail' => true, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -328,11 +328,11 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestPasswordSetup'); $username = uniqid('user_'); - self::$DI['client']->request('POST', '/admin/users/create/', array( + self::$DI['client']->request('POST', '/admin/users/create/', [ 'value' => $username . "@email.com", 'template' => '0', 'send_credentials' => true, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -369,32 +369,32 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { - $rights = array( + $rights = [ 'bas_manage' => '1' , 'bas_modify_struct' => '1' , 'bas_modif_th' => '1' , 'bas_chupub' => '1' - ); + ]; self::$DI['app']['acl']->get($user)->update_rights_to_sbas($databox->get_sbas_id(), $rights); foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - self::$DI['app']['acl']->get($user)->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get($user)->give_access_to_base([$base_id]); - $rights = array( + $rights = [ 'canputinalbum' => '1' , 'candwnldhd' => '1' , 'candwnldsubdef' => '1' , 'nowatermark' => '1' - ); + ]; self::$DI['app']['acl']->get($user)->update_rights_to_base($collection->get_base_id(), $rights); break; } } - self::$DI['client']->request('POST', '/admin/users/rights/reset/', array('users' => $user->get_id())); + self::$DI['client']->request('POST', '/admin/users/rights/reset/', ['users' => $user->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); $this->assertEquals("application/json", $response->headers->get("content-type")); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Client/BasketsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Client/BasketsTest.php index 7a6d3271a1..fc63c90dbb 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Client/BasketsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Client/BasketsTest.php @@ -32,7 +32,7 @@ class BasketsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testCreateBasket() { $nbBasketsBefore = self::$DI['app']['EM']->createQuery('SELECT COUNT(b.id) FROM \Alchemy\Phrasea\Model\Entities\Basket b')->getSingleScalarResult(); - self::$DI['client']->request("POST", "/client/baskets/new/", array('p0' => 'hello')); + self::$DI['client']->request("POST", "/client/baskets/new/", ['p0' => 'hello']); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $nbBasketsAfter = self::$DI['app']['EM']->createQuery('SELECT COUNT(b.id) FROM \Alchemy\Phrasea\Model\Entities\Basket b')->getSingleScalarResult(); $this->assertGreaterThan($nbBasketsBefore,$nbBasketsAfter); @@ -44,11 +44,11 @@ class BasketsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testAddElementToBasket() { $basket = $this->insertOneBasket(); - self::$DI['client']->request("POST", "/client/baskets/add-element/", array( + self::$DI['client']->request("POST", "/client/baskets/add-element/", [ 'courChuId' => $basket->getId(), 'sbas' => self::$DI['record_1']->get_sbas_id(), 'p0' => self::$DI['record_1']->get_record_id() - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $basket = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket')->find($basket->getId()); $this->assertGreaterThan(0, $basket->getElements()->count()); @@ -60,9 +60,9 @@ class BasketsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDeleteBasket() { $basket = $this->insertOneBasket(); - self::$DI['client']->request("POST", "/client/baskets/delete/", array( + self::$DI['client']->request("POST", "/client/baskets/delete/", [ 'courChuId' => $basket->getId() - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); try { $basket = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket')->find($basket->getId()); @@ -91,9 +91,9 @@ class BasketsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['EM']->persist($basket); self::$DI['app']['EM']->flush(); - self::$DI['client']->request("POST", "/client/baskets/delete-element/", array( + self::$DI['client']->request("POST", "/client/baskets/delete-element/", [ 'p0' => $basketElement->getId() - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertEquals(0, $basket->getElements()->count()); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php index e97dedb975..5455938e56 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php @@ -61,18 +61,18 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testExecuteQuery() { - $queryParameters = array(); + $queryParameters = []; $queryParameters["mod"] = self::$DI['user']->getPrefs('client_view') ? : '3X6'; $queryParameters["bas"] = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base()); $queryParameters["qry"] = self::$DI['user']->getPrefs('start_page_query') ? : 'all'; $queryParameters["pag"] = 0; $queryParameters["search_type"] = SearchEngineOptions::RECORD_RECORD; $queryParameters["qryAdv"] = ''; - $queryParameters["opAdv"] = array(); - $queryParameters["status"] = array(); + $queryParameters["opAdv"] = []; + $queryParameters["status"] = []; $queryParameters["recordtype"] = SearchEngineOptions::TYPE_ALL; $queryParameters["sort"] = self::$DI['app']['phraseanet.registry']->get('GV_phrasea_sort', ''); - $queryParameters["infield"] = array(); + $queryParameters["infield"] = []; $queryParameters["ord"] = SearchEngineOptions::SORT_MODE_DESC; self::$DI['client']->request("POST", "/client/query/", $queryParameters); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/MinifierTest.php b/tests/Alchemy/Tests/Phrasea/Controller/MinifierTest.php index e43da532cf..c3a2574919 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/MinifierTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/MinifierTest.php @@ -18,7 +18,7 @@ class MinifierTest extends \PhraseanetPHPUnitAbstract private function clearGlobals() { - $_GET = array(); + $_GET = []; } /** @@ -35,7 +35,7 @@ class MinifierTest extends \PhraseanetPHPUnitAbstract { $groups = require __DIR__ . '/../../../../../lib/conf.d/minifyGroupsConfig.php'; - return array_map(function ($group) {return array($group);}, array_keys($groups)); + return array_map(function ($group) {return [$group];}, array_keys($groups)); } /** @@ -50,7 +50,7 @@ class MinifierTest extends \PhraseanetPHPUnitAbstract public function provideFilesToMinify() { - $files = array(); + $files = []; $groups = require __DIR__ . '/../../../../../lib/conf.d/minifyGroupsConfig.php'; @@ -60,7 +60,7 @@ class MinifierTest extends \PhraseanetPHPUnitAbstract } } - return array_map(function ($file) {return array($file);}, array_unique($files)); + return array_map(function ($file) {return [$file];}, array_unique($files)); } public function testFileMinificationWithoutParamsShouldReturnA400() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BasketTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BasketTest.php index 9b87a491f9..498edb9672 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BasketTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BasketTest.php @@ -17,7 +17,7 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app'] = new Application('test'); self::giveRightsToUser(self::$DI['app'], self::$DI['user']); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); } @@ -27,21 +27,21 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['record_2']; $route = '/prod/baskets/'; - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), ' ', '42', self::$DI['record_no_access']->get_serialize_key() - ); + ]; $lst = implode(';', $records); self::$DI['client']->request( - 'POST', $route, array( + 'POST', $route, [ 'name' => 'panier', 'desc' => 'mon beau panier', - 'lst' => $lst) + 'lst' => $lst] ); $response = self::$DI['client']->getResponse(); @@ -69,14 +69,14 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->request( 'POST' , $route - , array( + , [ 'name' => 'panier', 'desc' => 'mon beau panier', - ) - , array() - , array( + ] + , [] + , [ "HTTP_ACCEPT" => "application/json" - ) + ] ); $response = self::$DI['client']->getResponse(); @@ -165,8 +165,8 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ); self::$DI['client']->request( - 'POST', $route, array(), array(), array( - "HTTP_ACCEPT" => "application/json") + 'POST', $route, [], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); @@ -204,7 +204,7 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $basket = $this->insertOneBasket(); $route = sprintf('/prod/baskets/%s/delete/', $basket->getId()); - self::$DI['client']->request('POST', $route, array(), array(), array("HTTP_ACCEPT" => "application/json")); + self::$DI['client']->request('POST', $route, [], [], ["HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); $query = self::$DI['app']['EM']->createQuery('SELECT COUNT(b.id) FROM \Alchemy\Phrasea\Model\Entities\Basket b'); $count = $query->getSingleScalarResult(); @@ -219,9 +219,9 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/update/', $basket->getId()); self::$DI['client']->request( - 'POST', $route, array( + 'POST', $route, [ 'name' => 'new_name', - 'description' => 'new_desc') + 'description' => 'new_desc'] ); $response = self::$DI['client']->getResponse(); @@ -236,11 +236,11 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/update/', $basket->getId()); self::$DI['client']->request( - 'POST', $route, array( + 'POST', $route, [ 'name' => 'new_name', 'description' => 'new_desc' - ), array(), array( - "HTTP_ACCEPT" => "application/json") + ], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); @@ -272,9 +272,9 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/update/', $basket->getId()); $crawler = self::$DI['client']->request( - 'GET', $route, array( + 'GET', $route, [ 'name' => 'new_name', - 'description' => 'new_desc') + 'description' => 'new_desc'] ); $response = self::$DI['client']->getResponse(); @@ -309,18 +309,18 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/archive/?archive=1', $basket->getId()); self::$DI['client']->request( - 'POST', $route, array(), array(), array( + 'POST', $route, [], [], [ "HTTP_ACCEPT" => "application/json" - ) + ] ); $this->assertTrue($basket->getArchived()); $route = sprintf('/prod/baskets/%s/archive/?archive=0', $basket->getId()); self::$DI['client']->request( - 'POST', $route, array(), array(), array( + 'POST', $route, [], [], [ "HTTP_ACCEPT" => "application/json" - ) + ] ); $response = self::$DI['client']->getResponse(); @@ -335,18 +335,18 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/addElements/', $basket->getId()); - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), ' ', '42', 'abhak', self::$DI['record_no_access']->get_serialize_key(), - ); + ]; $lst = implode(';', $records); - self::$DI['client']->request('POST', $route, array('lst' => $lst)); + self::$DI['client']->request('POST', $route, ['lst' => $lst]); $response = self::$DI['client']->getResponse(); @@ -387,18 +387,18 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/addElements/', $basket->getId()); - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), ' ', '42', 'abhak', self::$DI['record_no_access']->get_serialize_key(), - ); + ]; $lst = implode(';', $records); - self::$DI['client']->request('POST', $route, array('lst' => $lst)); + self::$DI['client']->request('POST', $route, ['lst' => $lst]); $response = self::$DI['client']->getResponse(); @@ -414,19 +414,19 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/addElements/', $basket->getId()); - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key() - ); + ]; $lst = implode(';', $records); self::$DI['client']->request( - 'POST', $route, array( + 'POST', $route, [ 'lst' => $lst - ), array(), array( + ], [], [ "HTTP_ACCEPT" => "application/json" - ) + ] ); $response = self::$DI['client']->getResponse(); @@ -447,9 +447,9 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/stealElements/', $Basket_2->getId()); self::$DI['client']->request( - 'POST', $route, array( - 'elements' => array($BasketElement->getId(), 'ufdsd') - ), array() + 'POST', $route, [ + 'elements' => [$BasketElement->getId(), 'ufdsd'] + ], [] ); $response = self::$DI['client']->getResponse(); @@ -471,12 +471,12 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf('/prod/baskets/%s/stealElements/', $Basket_2->getId()); self::$DI['client']->request( - 'POST', $route, array( - 'elements' => array($BasketElement->getId()) - ), array() - , array( + 'POST', $route, [ + 'elements' => [$BasketElement->getId()] + ], [] + , [ "HTTP_ACCEPT" => "application/json" - ) + ] ); $response = self::$DI['client']->getResponse(); @@ -498,7 +498,7 @@ class ControllerBasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $basket = $this->insertOneBasketEnv(); $route = sprintf('/prod/baskets/%s/delete/', $basket->getId()); - self::$DI['client']->request('POST', $route, array(), array(), array("HTTP_ACCEPT" => "application/json")); + self::$DI['client']->request('POST', $route, [], [], ["HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php index 80351c9789..000b6bccc4 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php @@ -47,7 +47,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract $basket = $this->insertOneBasket(); - $crawler = self::$DI['client']->request('POST', '/prod/bridge/manager/', array('ssel' => $basket->getId())); + $crawler = self::$DI['client']->request('POST', '/prod/bridge/manager/', ['ssel' => $basket->getId()]); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -139,7 +139,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $account = new \Bridge_Account(self::$DI['app'], self::$api, self::$account->get_id()); - $crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); + $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); } @@ -148,7 +148,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/adapter/%s/load-records/", self::$account->get_id()); - $crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); + $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]); $elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertEquals(sizeof($elements), $crawler->filterXPath("//table/tr")->count()); @@ -160,7 +160,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->followRedirects(); self::$account->get_settings()->set("auth_token", null); //deconnected $url = sprintf("/prod/bridge/adapter/%s/load-records/", self::$account->get_id()); - $crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); + $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertContains($url, $pageContent); $this->deconnected($crawler, $pageContent); @@ -170,7 +170,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); - $crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); + $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]); $elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); @@ -181,7 +181,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->followRedirects(); self::$account->get_settings()->set("auth_token", null); //deconnected $url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); - $crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); + $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertContains($url, $pageContent); $this->deconnected($crawler, $pageContent); @@ -192,7 +192,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->followRedirects(); self::$account->get_settings()->set("auth_token", null); //deconnected $url = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - $crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); + $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertContains($url, $pageContent); @@ -226,14 +226,14 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/action/%s/ajjfhfjozqd/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); try { - $crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "1;2;3")); + $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "1;2;3"]); $this->fail("expected Exception here"); } catch (\Exception $e) { } try { - $crawler = self::$DI['client']->request('POST', $url, array("elements_list" => "1;2;3")); + $crawler = self::$DI['client']->request('POST', $url, ["elements_list" => "1;2;3"]); $this->fail("expected Exception here"); } catch (\Exception $e) { @@ -244,14 +244,14 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - $crawler = self::$DI['client']->request('GET', $url, array("element_list" => "1_2;1_3;1_4")); + $crawler = self::$DI['client']->request('GET', $url, ["element_list" => "1_2;1_3;1_4"]); $redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertContains($redirect, self::$DI['client']->getResponse()->headers->get("location")); $this->assertContains("error=", self::$DI['client']->getResponse()->headers->get("location")); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); - self::$DI['client']->request('POST', $url, array("element_list" => "1_2;1_3;1_4")); + self::$DI['client']->request('POST', $url, ["element_list" => "1_2;1_3;1_4"]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -259,11 +259,11 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - $crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "element123qcs789")); + $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); - self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); + self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -272,7 +272,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$account->get_settings()->set("auth_token", "somethingNotNull"); \Bridge_Api_Apitest::$hasError = true; $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); + self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -281,7 +281,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$account->get_settings()->set("auth_token", "somethingNotNull"); \Bridge_Api_Apitest::$hasException = true; $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); + self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); } @@ -290,17 +290,17 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); $url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - self::$DI['client']->request('GET', $url, array("elements_list" => "element123qcs789")); + self::$DI['client']->request('GET', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); \Bridge_Api_Apitest::$hasException = true; $url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); + self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); + self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -319,7 +319,7 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $url = sprintf("/prod/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); - self::$DI['client']->request('POST', $url, array('title' => 'test', 'description' => 'description')); + self::$DI['client']->request('POST', $url, ['title' => 'test', 'description' => 'description']); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegexp('/success/', self::$DI['client']->getResponse()->headers->get('location')); } @@ -332,12 +332,12 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->markTestSkipped("No templates declared for modify a container in any apis"); self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); - $crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "containerudt456shn")); + $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "containerudt456shn"]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); - self::$DI['client']->request('POST', $url, array("elements_list" => "containerudt456shn")); + self::$DI['client']->request('POST', $url, ["elements_list" => "containerudt456shn"]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -345,16 +345,16 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected $url = sprintf("/prod/bridge/action/%s/moveinto/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); - $crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); + $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()]); $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", self::$DI['client']->getResponse()->getContent()); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); - self::$DI['client']->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); + self::$DI['client']->request('POST', $url, ["elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()]); $this->assertRegexp('/success/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); \Bridge_Api_Apitest::$hasException = true; - self::$DI['client']->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); + self::$DI['client']->request('POST', $url, ["elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()]); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -369,22 +369,22 @@ class BridgeApplication extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$account->get_settings()->set("auth_token", "somethingNotNull"); $url = "/prod/bridge/upload/"; - self::$DI['client']->request('GET', $url, array("account_id" => self::$account->get_id())); + self::$DI['client']->request('GET', $url, ["account_id" => self::$account->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key() - ); + ]; \Bridge_Api_Apitest::$hasError = true; $lst = implode(';', $records); - self::$DI['client']->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst)); + self::$DI['client']->request('POST', $url, ["account_id" => self::$account->get_id(), 'lst' => $lst]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); - self::$DI['client']->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst)); + self::$DI['client']->request('POST', $url, ["account_id" => self::$account->get_id(), 'lst' => $lst]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php index b2323ec89b..34f9e46b4b 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php @@ -13,17 +13,17 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testPrepareDownload() { - $token = $this->getToken(array( + $token = $this->getToken([ 'export_name' => 'Export_2012-10-23_621.zip', 'count' => 1, - 'files' => array( - array( + 'files' => [ + [ 'base_id' => 1, 'record_id' => 1, 'export_name' => 'my_downloads', 'original_name' => '0470', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => 'my_base/documents/2012/10/23/00000', 'file' => '1_document.jpg', @@ -32,11 +32,11 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => 'image/jpeg', 'folder' => '', 'exportExt' => 'jpg' - ) - ) - ) - ) - )); + ] + ] + ] + ] + ]); $url = sprintf('/download/%s/prepare/', $token); self::$DI['client']->request('GET', $url); $response = self::$DI['client']->getResponse(); @@ -60,7 +60,7 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testPrepareDownloadInvalidData() { - $token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail'))))); + $token = $this->getToken(['bad_string' => base64_decode(serialize(['fail']))]); self::$DI['client']->request('GET', sprintf('/download/%s/prepare/', $token)); $response = self::$DI['client']->getResponse(); @@ -76,17 +76,17 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $nbRowLogsBefore = $this->getNbRowLogs(self::$DI['record_1']->get_databox()); $thumbnail = self::$DI['record_1']->get_thumbnail(); - $token = $this->getToken(array( + $token = $this->getToken([ 'export_name' => 'Export_2012-10-23_621.zip', 'count' => 1, - 'files' => array( - array( + 'files' => [ + [ 'base_id' => self::$DI['record_1']->get_base_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'export_name' => 'my_downloads', 'original_name' => '0470', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => $thumbnail->get_path(), 'file' => $thumbnail->get_file(), @@ -95,11 +95,11 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => $thumbnail->get_mime(), 'folder' => '', 'exportExt' => pathinfo($thumbnail->get_file(), PATHINFO_EXTENSION) - ) - ) - ) - ) - )); + ] + ] + ] + ] + ]); $url = sprintf('/download/%s/get/', $token); self::$DI['client']->request('POST', $url); @@ -121,17 +121,17 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $thumbnail = self::$DI['record_1']->get_thumbnail(); $thumbnail2 = self::$DI['record_2']->get_thumbnail(); - $list = array( + $list = [ 'export_name' => 'Export_2012-10-23_617.zip', 'count' => 2, - 'files' => array( - array( + 'files' => [ + [ 'base_id' => self::$DI['record_1']->get_base_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'export_name' => 'my_downloads', 'original_name' => '0470', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => $thumbnail->get_path(), 'file' => $thumbnail->get_file(), @@ -140,16 +140,16 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => $thumbnail->get_mime(), 'folder' => '', 'exportExt' => pathinfo($thumbnail->get_file(), PATHINFO_EXTENSION) - ) - ) - ), - array( + ] + ] + ], + [ 'base_id' => self::$DI['record_2']->get_base_id(), 'record_id' => self::$DI['record_2']->get_record_id(), 'export_name' => 'my_downloads2', 'original_name' => '0471', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => $thumbnail2->get_path(), 'file' => $thumbnail2->get_file(), @@ -158,11 +158,11 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => $thumbnail2->get_mime(), 'folder' => '', 'exportExt' => pathinfo($thumbnail2->get_file(), PATHINFO_EXTENSION) - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $token = $this->getToken($list); // Get token @@ -192,17 +192,17 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testDocumentsDownloadNotFound() { - $token = $this->getToken(array( + $token = $this->getToken([ 'export_name' => 'Export_2012-10-23_621.zip', 'count' => 1, - 'files' => array( - array( + 'files' => [ + [ 'base_id' => 1, 'record_id' => 1, 'export_name' => 'my_downloads', 'original_name' => '0470', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => 'my_base/documents/2012/10/23/00000', 'file' => '1_document.jpg', @@ -211,11 +211,11 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => 'image/jpeg', 'folder' => '', 'exportExt' => 'jpg' - ) - ) - ) - ) - )); + ] + ] + ] + ] + ]); $url = sprintf('/download/%s/get/', $token); self::$DI['client']->request('POST', $url); @@ -238,7 +238,7 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testDocumentsDownloadInvalidData() { - $token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail'))))); + $token = $this->getToken(['bad_string' => base64_decode(serialize(['fail']))]); self::$DI['client']->request('POST', sprintf('/download/%s/get/', $token)); $response = self::$DI['client']->getResponse(); @@ -251,7 +251,7 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testExecuteDownloadInvalidData() { - $token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail'))))); + $token = $this->getToken(['bad_string' => base64_decode(serialize(['fail']))]); $url = sprintf('/download/%s/execute/', $token); self::$DI['client']->request('POST', $url); $response = self::$DI['client']->getResponse(); @@ -284,17 +284,17 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $thumbnail = self::$DI['record_1']->get_thumbnail(); $thumbnail2 = self::$DI['record_2']->get_thumbnail(); - $list = array( + $list = [ 'export_name' => 'Export_2012-10-23_617.zip', 'count' => 2, - 'files' => array( - array( + 'files' => [ + [ 'base_id' => 1, 'record_id' => 1, 'export_name' => 'my_downloads', 'original_name' => '0470', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => $thumbnail->get_path(), 'file' => $thumbnail->get_file(), @@ -303,16 +303,16 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => $thumbnail->get_mime(), 'folder' => '', 'exportExt' => pathinfo($thumbnail->get_file(), PATHINFO_EXTENSION) - ) - ) - ), - array( + ] + ] + ], + [ 'base_id' => 1, 'record_id' => 1, 'export_name' => 'my_downloads2', 'original_name' => '0471', - 'subdefs' => array( - 'document' => array ( + 'subdefs' => [ + 'document' => [ 'ajout' => '', 'path' => $thumbnail2->get_path(), 'file' => $thumbnail2->get_file(), @@ -321,11 +321,11 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'mime' => $thumbnail2->get_mime(), 'folder' => '', 'exportExt' => pathinfo($thumbnail2->get_file(), PATHINFO_EXTENSION) - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $token = $this->getToken($list); @@ -338,7 +338,7 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract unset($response); } - private function getToken($datas = array()) + private function getToken($datas = []) { return self::$DI['app']['tokens']->getUrlToken( \random::TYPE_DOWNLOAD, diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DownloadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DownloadTest.php index 6b517b5c14..6be874d3d4 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DownloadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DownloadTest.php @@ -22,13 +22,13 @@ class DownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['events-manager'] = $eventManagerStub; - self::$DI['client']->request('POST', '/prod/download/', array( + self::$DI['client']->request('POST', '/prod/download/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'ssttid' => '', - 'obj' => array('preview', 'document'), + 'obj' => ['preview', 'document'], 'title' => 'export_title_test', 'businessfields' => '1' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -53,7 +53,7 @@ class DownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['events-manager'] = $eventManagerStub; self::$DI['app']['authentication']->setUser($this->getMockBuilder('\User_Adapter') - ->setMethods(array('ACL')) + ->setMethods(['ACL']) ->disableOriginalConstructor() ->getMock()); @@ -85,13 +85,13 @@ class DownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['acl'] = $aclProvider; - self::$DI['client']->request('POST', '/prod/download/', array( + self::$DI['client']->request('POST', '/prod/download/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'ssttid' => '', - 'obj' => array('preview', 'document'), + 'obj' => ['preview', 'document'], 'title' => 'export_title_test', 'businessfields' => '1' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -117,13 +117,13 @@ class DownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['events-manager'] = $eventManagerStub; - self::$DI['client']->request('POST', '/prod/download/', array( + self::$DI['client']->request('POST', '/prod/download/', [ 'lst' => '', 'ssttid' => $basket->getId(), - 'obj' => array('preview', 'document'), + 'obj' => ['preview', 'document'], 'title' => 'export_title_test', 'businessfields' => '1' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -149,13 +149,13 @@ class DownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['events-manager'] = $eventManagerStub; - self::$DI['client']->request('POST', '/prod/download/', array( + self::$DI['client']->request('POST', '/prod/download/', [ 'lst' => '', 'ssttid' => $basket->getId(), - 'obj' => array('preview', 'document'), + 'obj' => ['preview', 'document'], 'title' => 'export_title_test', 'businessfields' => '1' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/EditTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/EditTest.php index 2a3d82dfb1..049c90a025 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/EditTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/EditTest.php @@ -11,7 +11,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRouteSlash() { - self::$DI['client']->request('POST', '/prod/records/edit/', array('lst' => self::$DI['record_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/records/edit/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); @@ -20,7 +20,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteSlashWithStory() { - self::$DI['client']->request('POST', '/prod/records/edit/', array('lst' => self::$DI['record_story_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/records/edit/', ['lst' => self::$DI['record_story_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); @@ -29,7 +29,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testApply() { - self::$DI['client']->request('POST', '/prod/records/edit/apply/', array('lst' => self::$DI['record_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/records/edit/apply/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); @@ -52,7 +52,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $datas = json_decode($response->getContent()); $this->assertFalse($datas->success); - $params = array('sbas_id' => self::$DI['collection']->get_sbas_id()); + $params = ['sbas_id' => self::$DI['collection']->get_sbas_id()]; self::$DI['client']->request('GET', '/prod/records/edit/vocabulary/Zanzibar/', $params); $response = self::$DI['client']->getResponse(); @@ -60,7 +60,7 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $datas = json_decode($response->getContent()); $this->assertFalse($datas->success); - $params = array('sbas_id' => self::$DI['collection']->get_sbas_id()); + $params = ['sbas_id' => self::$DI['collection']->get_sbas_id()]; self::$DI['client']->request('GET', '/prod/records/edit/vocabulary/User/', $params); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php index 2ac18721f0..3bc543eabc 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php @@ -25,7 +25,7 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testDisplayMultiExport() { - self::$DI['client']->request('POST', '/prod/export/multi-export/', array('lst' => self::$DI['record_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/export/multi-export/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); unset($response); @@ -39,12 +39,12 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $framework = $this; self::$DI['app']['phraseanet.ftp.client'] = self::$DI['app']->protect(function ($host, $port = 21, $timeout = 90, $ssl = false, $proxy = false, $proxyport = false) use ($framework) { return $framework->getMockBuilder('\ftpclient') - ->setMethods(array('login', 'close')) + ->setMethods(['login', 'close']) ->disableOriginalConstructor() ->getMock(); }); - $this->XMLHTTPRequest('POST', '/prod/export/ftp/test/', array('lst' => self::$DI['record_1']->get_serialize_key())); + $this->XMLHTTPRequest('POST', '/prod/export/ftp/test/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); $this->assertArrayHasKey('success', $datas); @@ -61,7 +61,7 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $framework = $this; self::$DI['app']['phraseanet.ftp.client'] = self::$DI['app']->protect(function ($host, $port = 21, $timeout = 90, $ssl = false, $proxy = false, $proxyport = false) use ($framework) { $ftpStub = $framework->getMockBuilder('\ftpclient') - ->setMethods(array('login', 'close')) + ->setMethods(['login', 'close']) ->disableOriginalConstructor() ->getMock(); @@ -72,7 +72,7 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract return $ftpStub; }); - self::$DI['client']->request('POST', '/prod/export/ftp/test/', array('lst' => self::$DI['record_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/export/ftp/test/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); @@ -84,13 +84,13 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testExportFtpNoDocs() { - self::$DI['client']->request('POST', '/prod/export/ftp/', array( + self::$DI['client']->request('POST', '/prod/export/ftp/', [ 'address' => 'test.ftp', 'login' => 'login', 'dest_folder' => 'documents', 'prefix_folder' => 'documents', - 'obj' => array('preview') - )); + 'obj' => ['preview'] + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); @@ -113,13 +113,13 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function getMissingArguments() { - return array( - array(array()), - array(array('address' => '')), - array(array('address' => '', 'login' => '')), - array(array('address' => '', 'login' => '', 'dest_folder' => '')), - array(array('address' => '', 'login' => '', 'dest_folder' => '', 'prefix_folder' => '')), - ); + return [ + [[]], + [['address' => '']], + [['address' => '', 'login' => '']], + [['address' => '', 'login' => '', 'dest_folder' => '']], + [['address' => '', 'login' => '', 'dest_folder' => '', 'prefix_folder' => '']], + ]; } /** @@ -132,15 +132,15 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$GV_activeFTP = true; } //inserted rows from this function are deleted in tearDownAfterClass - self::$DI['client']->request('POST', '/prod/export/ftp/', array( + self::$DI['client']->request('POST', '/prod/export/ftp/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'user_dest' => self::$DI['user']->get_id(), 'address' => 'local.phrasea.test', 'login' => self::$DI['user']->get_email(), 'dest_folder' => '/home/test/', 'prefix_folder' => 'test2/', - 'obj' => array('preview') - )); + 'obj' => ['preview'] + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -158,11 +158,11 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport'); - self::$DI['client']->request('POST', '/prod/export/mail/', array( + self::$DI['client']->request('POST', '/prod/export/mail/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'destmail' => 'user@example.com', - 'obj' => array('preview'), - )); + 'obj' => ['preview'], + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/FeedTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/FeedTest.php index 035848f91b..b9f8d7213b 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/FeedTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/FeedTest.php @@ -15,7 +15,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app'] = new Application('test'); self::giveRightsToUser(self::$DI['app'], self::$DI['user']); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); } @@ -44,7 +44,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->with($this->isInstanceOf('Alchemy\Phrasea\Notification\Mail\MailInfoNewPublication'), $this->equalTo(null)); $feed = $this->insertOneFeed(self::$DI['user']); - $params = array( + $params = [ "feed_id" => $feed->getId() , "notify" => 1 , "title" => "salut" @@ -52,7 +52,7 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract , "author_name" => "robert" , "author_mail" => "robert@kikoo.mail" , 'lst' => self::$DI['record_1']->get_serialize_key() - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/create/', $params); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); @@ -65,14 +65,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testEntryCreateError() { - $params = array( + $params = [ "feed_id" => 'unknow' , "title" => "salut" , "subtitle" => "coucou" , "author_name" => "robert" , "author_mail" => "robert@kikoo.mail" , 'lst' => self::$DI['record_1']->get_serialize_key() - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/create/', $params); $this->assertFalse(self::$DI['client']->getResponse()->isOk()); $this->assertEquals(404, self::$DI['client']->getResponse()->getStatusCode()); @@ -89,14 +89,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['notification.deliverer']->expects($this->never()) ->method('deliver'); - $params = array( + $params = [ "feed_id" => $feed->getId() , "title" => "salut" , "subtitle" => "coucou" , "author_name" => "robert" , "author_mail" => "robert@kikoo.mail" , 'lst' => self::$DI['record_1']->get_serialize_key() - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/create/', $params); $this->assertEquals(403, self::$DI['client']->getResponse()->getStatusCode()); @@ -132,13 +132,13 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $entry = $this->insertOneFeedEntry(self::$DI['user']); - $params = array( + $params = [ "title" => "dog", "subtitle" => "cat", "author_name" => "bird", "author_mail" => "mouse", 'lst' => self::$DI['record_1']->get_serialize_key(), - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); @@ -156,14 +156,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $entry = $this->insertOneFeedEntry(self::$DI['user']); $newfeed = $this->insertOneFeed(self::$DI['user'], "test2"); - $params = array( + $params = [ "feed_id" => $newfeed->getId(), "title" => "dog", "subtitle" => "cat", "author_name" => "bird", "author_mail" => "mouse", 'lst' => self::$DI['record_1']->get_serialize_key(), - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type")); @@ -186,14 +186,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['EM']->persist($newfeed); self::$DI['app']['EM']->flush(); - $params = array( + $params = [ "feed_id" => $newfeed->getId(), "title" => "dog", "subtitle" => "cat", "author_name" => "bird", "author_mail" => "mouse", 'lst' => self::$DI['record_1']->get_serialize_key(), - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); $this->assertEquals(403, self::$DI['client']->getResponse()->getStatusCode()); @@ -203,14 +203,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $entry = $this->insertOneFeedEntry(self::$DI['user']); - $params = array( + $params = [ "feed_id" => 0, "title" => "dog", "subtitle" => "cat", "author_name" => "bird", "author_mail" => "mouse", 'lst' => self::$DI['record_1']->get_serialize_key(), - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); $this->assertEquals(404, self::$DI['client']->getResponse()->getStatusCode()); @@ -219,14 +219,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testEntryUpdateNotFound() { - $params = array( + $params = [ "feed_id" => 9999999 , "title" => "dog" , "subtitle" => "cat" , "author_name" => "bird" , "author_mail" => "mouse" , 'lst' => self::$DI['record_1']->get_serialize_key() - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/99999999/update/', $params); @@ -241,14 +241,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $entry = $this->insertOneFeedEntry(self::$DI['user']); - $params = array( + $params = [ "feed_id" => 9999999 , "title" => "dog" , "subtitle" => "cat" , "author_name" => "bird" , "author_mail" => "mouse" , 'sorted_lst' => self::$DI['record_1']->get_serialize_key() . ";" . self::$DI['record_2']->get_serialize_key() . ";12345;" . "unknow_unknow" - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); @@ -265,14 +265,14 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $entry = $this->insertOneFeedEntry(self::$DI['user_alt1']); - $params = array( + $params = [ "feed_id" => $entry->getFeed()->getId() , "title" => "dog" , "subtitle" => "cat" , "author_name" => "bird" , "author_mail" => "mouse" , 'lst' => self::$DI['record_1']->get_serialize_key() - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); @@ -298,13 +298,13 @@ class FeedTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $ord1 = $item1->getOrd(); $ord2 = $item2->getOrd(); - $params = array( + $params = [ "title" => $entry->getTitle(), "author_name" => $entry->getAuthorName(), "author_mail" => $entry->getAuthorEmail(), 'sorted_lst' => $item1->getId() . '_' . $item2->getOrd() . ';' . $item2->getId() . '_' . $item1->getOrd() - ); + ]; $crawler = self::$DI['client']->request('POST', '/prod/feeds/entry/' . $entry->getId() . '/update/', $params); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php index dc00f91777..88b7aafc79 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/LazaretTest.php @@ -29,12 +29,12 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $originalEm = self::$DI['app']['EM']; - $fileLazaret = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretFile', array('getRecordsToSubstitute', 'getSession', 'getCollection'), array(), '', false); + $fileLazaret = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretFile', ['getRecordsToSubstitute', 'getSession', 'getCollection'], [], '', false); $fileLazaret ->expects($this->any()) ->method('getRecordsToSubstitute') - ->will($this->returnValue(array(self::$DI['record_1']))); + ->will($this->returnValue([self::$DI['record_1']])); $fileLazaret ->expects($this->any()) @@ -47,14 +47,14 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue(self::$DI['collection'])); //mock one Alchemy\Phrasea\Model\Repositories\LazaretFile::getFiles - $repo = $this->getMock('Alchemy\Phrasea\Model\Repositories\LazaretFile', array('findPerPage'), array(), '', false); + $repo = $this->getMock('Alchemy\Phrasea\Model\Repositories\LazaretFile', ['findPerPage'], [], '', false); $repo->expects($this->once()) ->method('findPerPage') - ->will($this->returnValue(array($fileLazaret))); + ->will($this->returnValue([$fileLazaret])); //mock Doctrine\ORM\EntityManager::getRepository - $em = $this->getMock('Doctrine\ORM\EntityManager', array('getRepository'), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', ['getRepository'], [], '', false); $em->expects($this->once()) ->method('getRepository') @@ -64,7 +64,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lazaret/'; self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $crawler = self::$DI['client']->request( 'GET', $route @@ -73,7 +73,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertResponseOk(self::$DI['client']->getResponse()); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertEquals(1, $crawler->filter('.records-subititution')->count()); @@ -87,7 +87,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $originalEm = self::$DI['app']['EM']; - $em = $this->getMock('Doctrine\ORM\EntityManager', array('find'), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', ['find'], [], '', false); $lazaretFile = $this->getOneLazaretFile(); @@ -99,7 +99,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue($lazaretFile)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); self::$DI['client']->request('GET', '/prod/lazaret/' . $id . '/'); @@ -108,7 +108,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertResponseOk($response); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $content = json_decode($response->getContent()); @@ -133,7 +133,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $originalEm = self::$DI['app']['EM']; - $em = $this->getMock('Doctrine\ORM\EntityManager', array('find'), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', ['find'], [], '', false); $id = 1; @@ -143,14 +143,14 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue(null)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); self::$DI['client']->request('GET', '/prod/lazaret/' . $id . '/'); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); $this->assertBadJsonContent(json_decode($response->getContent())); @@ -166,7 +166,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $originalEm = self::$DI['app']['EM']; //mock Doctrine\ORM\EntityManager - $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', [], [], '', false); $lazaretFile = $this->getOneLazaretFile(); @@ -177,7 +177,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract copy(__DIR__ . '/../../../../../files/cestlafete.jpg', $lazaretThumbFileName); //mock lazaret Attribute - $lazaretAttribute = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretAttribute', array(), array(), '', false); + $lazaretAttribute = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretAttribute', [], [], '', false); //Expect to be called 3 times since we add 5 attribute to lazaretFile //and each one is called to verify if it is an attribute to keep @@ -222,18 +222,18 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->method('flush'); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); - self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/force-add/', array( + self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/force-add/', [ 'bas_id' => $lazaretFile->getBaseId(), 'keep_attributes' => 1, - 'attributes' => array(1, 2, 3, 4) //Check only the four first attributes - )); + 'attributes' => [1, 2, 3, 4] //Check only the four first attributes + ]); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); $this->assertGoodJsonContent(json_decode($response->getContent())); @@ -251,7 +251,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $originalEm = self::$DI['app']['EM']; //mock Doctrine\ORM\EntityManager - $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', [], [], '', false); $lazaretFile = $this->getOneLazaretFile(); @@ -264,18 +264,18 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue($lazaretFile)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); //Ommit base_id mandatory param - self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/force-add/', array( + self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/force-add/', [ 'keep_attributes' => 1, - 'attributes' => array(1, 2, 3, 4) //Check only the four first attributes - )); + 'attributes' => [1, 2, 3, 4] //Check only the four first attributes + ]); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); $this->assertBadJsonContent(json_decode($response->getContent())); @@ -289,18 +289,18 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testAddElementException() { $originalEm = self::$DI['app']['EM']; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); - self::$DI['client']->request('POST', '/prod/lazaret/99999/force-add/', array( + self::$DI['client']->request('POST', '/prod/lazaret/99999/force-add/', [ 'bas_id' => 1, 'keep_attributes' => 1, - 'attributes' => array(1, 2, 3, 4) //Check only the four first attributes - )); + 'attributes' => [1, 2, 3, 4] //Check only the four first attributes + ]); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); $this->assertBadJsonContent(json_decode($response->getContent())); @@ -380,16 +380,16 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $originalEm = self::$DI['app']['EM']; //mock Doctrine\ORM\EntityManager - $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', [], [], '', false); - $record = $this->getMock('record_adapter', array('substitute_subdef'), array(), '', false); + $record = $this->getMock('record_adapter', ['substitute_subdef'], [], '', false); //expect one call to substitute the documents $record->expects($this->once()) ->method('substitute_subdef') ->with($this->equalTo('document')); - $databox = $this->getMock('databox', array(), array(), '', false); + $databox = $this->getMock('databox', [], [], '', false); //expect to fetch record $databox->expects($this->once()) @@ -397,19 +397,19 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->with($this->equalTo(self::$DI['record_1']->get_record_id())) ->will($this->returnValue($record)); - $collection = $this->getMock('collection', array(), array(), '', false); + $collection = $this->getMock('collection', [], [], '', false); //expect to fetch databox $collection->expects($this->once()) ->method('get_databox') ->will($this->returnValue($databox)); - $lazaretFile = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretFile', array(), array(), '', false); + $lazaretFile = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretFile', [], [], '', false); //expect to fetch possible records to subtitute $lazaretFile->expects($this->once()) ->method('getRecordsToSubstitute') - ->will($this->returnValue(array(self::$DI['record_2'], self::$DI['record_1']))); + ->will($this->returnValue([self::$DI['record_2'], self::$DI['record_1']])); copy(__DIR__ . '/../../../../../files/cestlafete.jpg', __DIR__ . '/../../../../../../tmp/lazaret/cestlafete.jpg'); @@ -453,17 +453,17 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract }); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); - self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/accept/', array( + self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/accept/', [ 'record_id' => self::$DI['record_1']->get_record_id() - )); + ]); $this->assertTrue($called); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $content = json_decode($response->getContent()); $this->assertResponseOk($response); @@ -480,7 +480,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $originalEm = self::$DI['app']['EM']; //mock Doctrine\ORM\EntityManager - $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', [], [], '', false); $lazaretFile = $this->getMockBuilder('Alchemy\Phrasea\Model\Entities\LazaretFile') ->disableOriginalConstructor() @@ -490,7 +490,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract //no records to subsitute $lazaretFile->expects($this->once()) ->method('getRecordsToSubstitute') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $id = 1; @@ -503,16 +503,16 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $id = 1; self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); - self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/accept/', array( + self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/accept/', [ 'record_id' => self::$DI['record_1']->get_record_id() - )); + ]); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); $this->assertBadJsonContent(json_decode($response->getContent())); @@ -527,7 +527,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $route = sprintf('/prod/lazaret/%s/accept/', '99999'); - self::$DI['client']->request('POST', $route, array('record_id' => 1)); + self::$DI['client']->request('POST', $route, ['record_id' => 1]); $response = self::$DI['client']->getResponse(); @@ -543,7 +543,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $originalEm = self::$DI['app']['EM']; //mock Doctrine\ORM\EntityManager - $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', [], [], '', false); $lazaretFile = $this->getOneLazaretFile(); @@ -556,7 +556,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue($lazaretFile)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); //Ommit record_id mandatory param self::$DI['client']->request('POST', '/prod/lazaret/' . $id . '/accept/'); @@ -564,7 +564,7 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); $this->assertBadJsonContent(json_decode($response->getContent())); @@ -580,9 +580,9 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $originalEm = self::$DI['app']['EM']; //mock Doctrine\ORM\EntityManager - $em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false); + $em = $this->getMock('Doctrine\ORM\EntityManager', [], [], '', false); - $lazaretFile = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretFile', array(), array(), '', false); + $lazaretFile = $this->getMock('Alchemy\Phrasea\Model\Entities\LazaretFile', [], [], '', false); copy(__DIR__ . '/../../../../../files/cestlafete.jpg', __DIR__ . '/../../../../../../tmp/lazaret/cestlafete.jpg'); @@ -603,14 +603,14 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue($lazaretFile)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); self::$DI['client']->request('GET', '/prod/lazaret/' . $id . '/thumbnail/'); $response = self::$DI['client']->getResponse(); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->assertResponseOk($response); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/MoveCollectionTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/MoveCollectionTest.php index bdc94005c9..026613135e 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/MoveCollectionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/MoveCollectionTest.php @@ -11,7 +11,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb */ public function testRouteSlash() { - self::$DI['client']->request('POST', '/prod/records/movecollection/', array('lst' => self::$DI['record_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/records/movecollection/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); @@ -21,7 +21,7 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb public function testApply() { - self::$DI['client']->request('POST', '/prod/records/movecollection/apply/', array('lst' => self::$DI['record_1']->get_serialize_key(), 'base_id' => self::$DI['collection']->get_base_id())); + self::$DI['client']->request('POST', '/prod/records/movecollection/apply/', ['lst' => self::$DI['record_1']->get_serialize_key(), 'base_id' => self::$DI['collection']->get_base_id()]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php index a1f0dacbd2..a2d91c2745 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/OrderTest.php @@ -30,10 +30,10 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue(null)); self::$DI['app']['events-manager'] = $eventManagerStub; - self::$DI['client']->request('POST', '/prod/order/', array( + self::$DI['client']->request('POST', '/prod/order/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'deadline' => '+10 minutes' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); } @@ -54,10 +54,10 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['events-manager'] = $eventManagerStub; - $this->XMLHTTPRequest('POST', '/prod/order/', array( + $this->XMLHTTPRequest('POST', '/prod/order/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'deadline' => '+10 minutes' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -74,13 +74,13 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testDisplayOrders() { - $this->XMLHTTPRequest('POST', '/prod/order/', array( + $this->XMLHTTPRequest('POST', '/prod/order/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'deadline' => '+10 minutes' - )); - self::$DI['client']->request('GET', '/prod/order/', array( + ]); + self::$DI['client']->request('GET', '/prod/order/', [ 'sort' => 'usage' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -103,11 +103,11 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered'); - $parameters = array(); + $parameters = []; foreach ($order->getElements() as $element) { $parameters[] = $element->getId(); } - self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/send/', array('elements' => $parameters)); + self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/send/', ['elements' => $parameters]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $url = parse_url(self::$DI['client']->getResponse()->headers->get('location')); parse_str($url['query']); @@ -123,11 +123,11 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered'); - $parameters = array(); + $parameters = []; foreach ($order->getElements() as $element) { $parameters[] = $element->getId(); } - $this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/send/', array('elements' => $parameters)); + $this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/send/', ['elements' => $parameters]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -149,11 +149,11 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled'); - $parameters = array(); + $parameters = []; foreach ($order->getElements() as $element) { $parameters[] = $element->getId(); } - self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/deny/', array('elements' => $parameters)); + self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $url = parse_url(self::$DI['client']->getResponse()->headers->get('location')); parse_str($url['query']); @@ -169,11 +169,11 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled'); - $parameters = array(); + $parameters = []; foreach ($order->getElements() as $element) { $parameters[] = $element->getId(); } - $this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/deny/', array('elements' => $parameters)); + $this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $this->assertEquals('application/json', $response->headers->get('Content-Type')); @@ -191,11 +191,11 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoOrderDelivered'); - $parameters = array(); + $parameters = []; foreach ($order->getElements() as $element) { $parameters[] = $element->getId(); } - self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/send/', array('elements' => $parameters)); + self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/send/', ['elements' => $parameters]); $testOrder = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->find($order->getId()); $this->assertEquals(0, $testOrder->getTodo()); @@ -216,13 +216,13 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['EM']->persist($orderElement); self::$DI['app']['EM']->flush(); - $parameters = array($order->getElements()->first()->getId()); - self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/send/', array('elements' => $parameters)); + $parameters = [$order->getElements()->first()->getId()]; + self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/send/', ['elements' => $parameters]); $testOrder = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->find($order->getId()); $this->assertEquals(1, $testOrder->getTodo()); - $parameters = array($orderElement->getId()); - self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/deny/', array('elements' => $parameters)); + $parameters = [$orderElement->getId()]; + self::$DI['client']->request('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]); $testOrder = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->find($order->getId()); $this->assertEquals(0, $testOrder->getTodo()); @@ -234,7 +234,7 @@ class OrderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->disableOriginalConstructor() ->getMock(); - $receveid = array(self::$DI['record_1']->get_serialize_key() => self::$DI['record_1']); + $receveid = [self::$DI['record_1']->get_serialize_key() => self::$DI['record_1']]; $order = new Order(); $order->setOrderUsage($usage); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PrinterTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PrinterTest.php index 64455f6790..f745da3c9c 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PrinterTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PrinterTest.php @@ -11,14 +11,14 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRouteSlash() { - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key() - ); + ]; $lst = implode(';', $records); - self::$DI['client']->request('POST', '/prod/printer/', array('lst' => $lst)); + self::$DI['client']->request('POST', '/prod/printer/', ['lst' => $lst]); $response = self::$DI['client']->getResponse(); @@ -27,28 +27,28 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRoutePrintPdf() { - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), self::$DI['record_3']->get_serialize_key(), self::$DI['record_4']->get_serialize_key(), - ); + ]; $lst = implode(';', $records); - $layouts = array( + $layouts = [ \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEW, \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTION, \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_PREVIEWCAPTIONTDM, \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILLIST, \Alchemy\Phrasea\Out\Module\PDF::LAYOUT_THUMBNAILGRID - ); + ]; foreach ($layouts as $layout) { - self::$DI['client']->request('POST', '/prod/printer/print.pdf', array( + self::$DI['client']->request('POST', '/prod/printer/print.pdf', [ 'lst' => $lst, 'lay' => $layout - ) + ] ); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php index 8e3e1a4807..1d75f64e3a 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php @@ -13,7 +13,7 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testDisplayStatusProperty() { - $this->XMLHTTPRequest('GET', '/prod/records/property/', array('lst' => implode(';', array(self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_1']->get_serialize_key(), self::$DI['record_4']->get_serialize_key())))); + $this->XMLHTTPRequest('GET', '/prod/records/property/', ['lst' => implode(';', [self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_1']->get_serialize_key(), self::$DI['record_4']->get_serialize_key()])]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); unset($response); @@ -34,7 +34,7 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testDisplayTypeProperty() { - $this->XMLHTTPRequest('GET', '/prod/records/property/type/',array('lst' => implode(';', array(self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_1']->get_serialize_key(), self::$DI['record_4']->get_serialize_key())))); + $this->XMLHTTPRequest('GET', '/prod/records/property/type/',['lst' => implode(';', [self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_1']->get_serialize_key(), self::$DI['record_4']->get_serialize_key()])]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); unset($response); @@ -61,15 +61,15 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']); $story->appendChild($record2); - self::$DI['client']->request('POST', '/prod/records/property/status/', array( - 'apply_to_children' => array($story->get_sbas_id() => true), - 'status' => array( - $record->get_sbas_id() => array(6 => true, 8 => true, 11 => true) - ), - 'lst' => implode(';', array( + self::$DI['client']->request('POST', '/prod/records/property/status/', [ + 'apply_to_children' => [$story->get_sbas_id() => true], + 'status' => [ + $record->get_sbas_id() => [6 => true, 8 => true, 11 => true] + ], + 'lst' => implode(';', [ $record->get_serialize_key(),$story->get_serialize_key() - )) - )); + ]) + ]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); $this->assertArrayHasKey('success', $datas); @@ -113,15 +113,15 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $record = \record_adapter::createFromFile($file, self::$DI['app']); $record2 = \record_adapter::createFromFile($file, self::$DI['app']); - self::$DI['client']->request('POST', '/prod/records/property/type/', array( - 'lst' => implode(';', array( + self::$DI['client']->request('POST', '/prod/records/property/type/', [ + 'lst' => implode(';', [ $record->get_serialize_key(), $record2->get_serialize_key() - )), - 'types' => array( + ]), + 'types' => [ $record->get_serialize_key() => 'document', $record2->get_serialize_key() => 'flash', - ) - )); + ] + ]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); $this->assertArrayHasKey('success', $datas); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PushTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PushTest.php index 97ebc09f73..aa76eaedf7 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PushTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PushTest.php @@ -39,20 +39,20 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/push/send/'; - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), - ); + ]; - $receivers = array( - array('usr_id' => self::$DI['user_alt1']->get_id(), 'HD' => 1) - , array('usr_id' => self::$DI['user_alt2']->get_id(), 'HD' => 0) - ); + $receivers = [ + ['usr_id' => self::$DI['user_alt1']->get_id(), 'HD' => 1] + , ['usr_id' => self::$DI['user_alt2']->get_id(), 'HD' => 0] + ]; - $params = array( + $params = [ 'lst' => implode(';', $records) , 'participants' => $receivers - ); + ]; self::$DI['client']->request('POST', $route, $params); @@ -75,30 +75,30 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/push/validate/'; - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), - ); + ]; - $participants = array( - array( + $participants = [ + [ 'usr_id' => self::$DI['user_alt1']->get_id(), 'agree' => 0, 'see_others' => 1, 'HD' => 0, - ) - , array( + ] + , [ 'usr_id' => self::$DI['user_alt2']->get_id(), 'agree' => 1, 'see_others' => 0, 'HD' => 1, - ) - ); + ] + ]; - $params = array( + $params = [ 'lst' => implode(';', $records) , 'participants' => $participants - ); + ]; self::$DI['client']->request('POST', $route, $params); @@ -119,9 +119,9 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $route = '/prod/push/search-user/'; - $params = array( + $params = [ 'query' => '' - ); + ]; self::$DI['client']->request('GET', $route, $params); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php index 2adb35997d..6d1f038dba 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php @@ -37,11 +37,11 @@ class QueryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $options->onCollections(self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())->get_granted_base()); $serializedOptions = $options->serialize(); - self::$DI['client']->request('POST', '/prod/query/answer-train/', array( + self::$DI['client']->request('POST', '/prod/query/answer-train/', [ 'options_serial' => $serializedOptions, 'pos' => 0, 'query' => '' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); @@ -54,10 +54,10 @@ class QueryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testQueryRegTrain() { - self::$DI['client']->request('POST', '/prod/query/reg-train/', array( + self::$DI['client']->request('POST', '/prod/query/reg-train/', [ 'pos' => 1, 'cont' => self::$DI['record_story_1']->get_serialize_key() - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); unset($response); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php index 6f28f6bade..2b9480b3cd 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php @@ -22,7 +22,7 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testWhatCanIDelete() { - self::$DI['client']->request('POST', '/prod/records/delete/what/', array('lst' => self::$DI['record_1']->get_serialize_key())); + self::$DI['client']->request('POST', '/prod/records/delete/what/', ['lst' => self::$DI['record_1']->get_serialize_key()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); unset($response); @@ -35,7 +35,7 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']); $record = \record_adapter::createFromFile($file, self::$DI['app']); - $this->XMLHTTPRequest('POST', '/prod/records/delete/', array('lst' => $record->get_serialize_key())); + $this->XMLHTTPRequest('POST', '/prod/records/delete/', ['lst' => $record->get_serialize_key()]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); $this->assertContains($record->get_serialize_key(), $datas); @@ -55,7 +55,7 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']); $record = \record_adapter::createFromFile($file, self::$DI['app']); - $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', array('lst' => $record->get_serialize_key())); + $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->get_serialize_key()]); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); $this->assertTrue(count($datas) > 0); @@ -86,12 +86,12 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $options->onCollections($acl->get_granted_base()); $serializedOptions = $options->serialize(); - $this->XMLHTTPRequest('POST', '/prod/records/', array( + $this->XMLHTTPRequest('POST', '/prod/records/', [ 'env' => 'RESULT', 'options_serial' => $serializedOptions, 'pos' => 0, 'query' => '' - )); + ]); $response = self::$DI['client']->getResponse(); $data = json_decode($response->getContent(), true); @@ -117,12 +117,12 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->authenticate(self::$DI['app']); self::$DI['record_story_1']; - $this->XMLHTTPRequest('POST', '/prod/records/', array( + $this->XMLHTTPRequest('POST', '/prod/records/', [ 'env' => 'REG', 'pos' => 0, 'query' => '', 'cont' => self::$DI['record_story_1']->get_serialize_key() - )); + ]); $response = self::$DI['client']->getResponse(); $data = json_decode($response->getContent()); @@ -158,12 +158,12 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['EM']->persist($basket); self::$DI['app']['EM']->flush(); - $this->XMLHTTPRequest('POST', '/prod/records/', array( + $this->XMLHTTPRequest('POST', '/prod/records/', [ 'env' => 'BASK', 'pos' => 0, 'query' => '', 'cont' => $basket->getId() - )); + ]); $response = self::$DI['client']->getResponse(); $data = json_decode($response->getContent()); @@ -195,12 +195,12 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $item = $this->insertOneFeedItem(self::$DI['user']); $feedEntry = $item->getEntry(); - $this->XMLHTTPRequest('POST', '/prod/records/', array( + $this->XMLHTTPRequest('POST', '/prod/records/', [ 'env' => 'FEED', 'pos' => 0, 'query' => '', 'cont' => $feedEntry->getId() - )); + ]); $response = self::$DI['client']->getResponse(); $data = json_decode($response->getContent()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/StoryTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/StoryTest.php index 649b365a39..b42fceb256 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/StoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/StoryTest.php @@ -11,15 +11,15 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = "/prod/story/"; $collections = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser()) - ->get_granted_base(array('canaddrecord')); + ->get_granted_base(['canaddrecord']); $collection = array_shift($collections); $crawler = self::$DI['client']->request( - 'POST', $route, array( + 'POST', $route, [ 'base_id' => $collection->get_base_id(), 'name' => 'test story' - ) + ] ); $response = self::$DI['client']->getResponse(); @@ -40,15 +40,15 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = "/prod/story/"; $collections = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser()) - ->get_granted_base(array('canaddrecord')); + ->get_granted_base(['canaddrecord']); $collection = array_shift($collections); $crawler = self::$DI['client']->request( - 'POST', $route, array( + 'POST', $route, [ 'base_id' => $collection->get_base_id(), - 'name' => 'test story'), array(), array( - "HTTP_ACCEPT" => "application/json") + 'name' => 'test story'], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); @@ -95,14 +95,14 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf("/prod/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id()); - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key() - ); + ]; $lst = implode(';', $records); - $crawler = self::$DI['client']->request('POST', $route, array('lst' => $lst)); + $crawler = self::$DI['client']->request('POST', $route, ['lst' => $lst]); $response = self::$DI['client']->getResponse(); @@ -118,16 +118,16 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf("/prod/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id()); - $records = array( + $records = [ self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key() - ); + ]; $lst = implode(';', $records); - $crawler = self::$DI['client']->request('POST', $route, array('lst' => $lst) - , array(), array( - "HTTP_ACCEPT" => "application/json")); + $crawler = self::$DI['client']->request('POST', $route, ['lst' => $lst] + , [], [ + "HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); @@ -141,10 +141,10 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']); - $records = array( + $records = [ self::$DI['record_1'], self::$DI['record_2'] - ); + ]; foreach ($records as $record) { $story->appendChild($record); @@ -162,7 +162,7 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract , $record->get_record_id() ); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); if (($n % 2) === 0) { $crawler = self::$DI['client']->request('POST', $route); @@ -172,8 +172,8 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(302, $response->getStatusCode()); } else { $crawler = self::$DI['client']->request( - 'POST', $route, array(), array(), array( - "HTTP_ACCEPT" => "application/json") + 'POST', $route, [], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/TOUTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/TOUTest.php index d80f2d536f..6a4b41046e 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/TOUTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/TOUTest.php @@ -12,7 +12,7 @@ class TOUTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $application = new Application('test'); self::giveRightsToUser($application, self::$DI['user_alt2']); - self::$DI['app']['acl']->get(self::$DI['user_alt2'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user_alt2'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user_alt2'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); parent::tearDownAfterClass(); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php index d822d24046..e1ae51053e 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ToolsTest.php @@ -28,14 +28,14 @@ class ControllerToolsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $record = self::$DI['record_1']; - $crawler = self::$DI['client']->request('POST', '/prod/tools/hddoc/', array( + $crawler = self::$DI['client']->request('POST', '/prod/tools/hddoc/', [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), - ), array( + ], [ 'newHD' => new UploadedFile( $this->tmpFile, 'KIKOO.JPG', 'image/jpg', 2000 ) - )); + ]); $response = self::$DI['client']->getResponse(); $message = trim($crawler->filterXPath('//div')->text()); @@ -47,14 +47,14 @@ class ControllerToolsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $record = self::$DI['record_1']; - $crawler = self::$DI['client']->request('POST', '/prod/tools/chgthumb/', array( + $crawler = self::$DI['client']->request('POST', '/prod/tools/chgthumb/', [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), - ), array( + ], [ 'newThumb' => new UploadedFile( $this->tmpFile, 'KIKOO.JPG', 'image/jpg', 2000 ) - )); + ]); $response = self::$DI['client']->getResponse(); $message = trim($crawler->filterXPath('//div')->text()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php index 600f61c683..69c666ff1e 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php @@ -52,13 +52,13 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route_base = '/prod/tooltip/caption/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/%s/'; - $routes = array( + $routes = [ sprintf($route_base, 'answer') , sprintf($route_base, 'lazaret') , sprintf($route_base, 'preview') , sprintf($route_base, 'basket') , sprintf($route_base, 'overview') - ); + ]; foreach ($routes as $route) { $crawler = self::$DI['client']->request('POST', $route); @@ -72,17 +72,17 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route_base = '/prod/tooltip/caption/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/%s/'; - $routes = array( + $routes = [ sprintf($route_base, 'answer') , sprintf($route_base, 'lazaret') , sprintf($route_base, 'preview') , sprintf($route_base, 'basket') , sprintf($route_base, 'overview') - ); + ]; foreach ($routes as $route) { $option = new SearchEngineOptions(); - $crawler = self::$DI['client']->request('POST', $route, array('options_serial' => $option->serialize())); + $crawler = self::$DI['client']->request('POST', $route, ['options_serial' => $option->serialize()]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -115,12 +115,12 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteMetasDCESInfos() { $databox = self::$DI['record_1']->get_databox(); - $dces = array( + $dces = [ \databox_field::DCES_CONTRIBUTOR => new \databox_Field_DCES_Contributor() , \databox_field::DCES_COVERAGE => new \databox_Field_DCES_Coverage() , \databox_field::DCES_CREATOR => new \databox_Field_DCES_Creator() , \databox_field::DCES_DESCRIPTION => new \databox_Field_DCES_Description() - ); + ]; foreach ($databox->get_meta_structure() as $field) { $dces_element = array_shift($dces); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php index 46e78d0781..6ee84a7f2d 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php @@ -40,7 +40,7 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app'] = new Application('test'); self::giveRightsToUser(self::$DI['app'], self::$DI['user']); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); } @@ -78,19 +78,19 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->getMock(); $data = DataURI\Data::buildFromFile(__DIR__ . '/../../../../../files/cestlafete.jpg'); - $params = array( + $params = [ 'base_id' => self::$DI['collection']->get_base_id(), 'b64_image' => DataURI\Dumper::dump($data) - ); + ]; - $files = array( - 'files' => array( + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -118,18 +118,18 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->disableOriginalConstructor() ->getMock(); - $params = array( + $params = [ 'base_id' => self::$DI['collection']->get_base_id() - ); + ]; - $files = array( - 'files' => array( + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -156,18 +156,18 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailInfoRecordQuarantined'); - $params = array( + $params = [ 'base_id' => self::$DI['collection']->get_base_id() - ); + ]; - $files = array( - 'files' => array( + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -183,15 +183,15 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadWrongBaseId() { - $params = array('base_id' => 0); - $files = array( - 'files' => array( + $params = ['base_id' => 0]; + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -207,15 +207,15 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadNoAccessBaseId() { - $params = array('base_id' => self::$DI['collection_no_access']->get_base_id()); - $files = array( - 'files' => array( + $params = ['base_id' => self::$DI['collection_no_access']->get_base_id()]; + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -235,9 +235,9 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->tmpFile, 'KIKOO.JPG', 'image/jpeg', 123, UPLOAD_ERR_NO_FILE ); - $params = array('base_id' => self::$DI['collection']->get_base_id()); - $files = array('files' => array($file)); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + $params = ['base_id' => self::$DI['collection']->get_base_id()]; + $files = ['files' => [$file]]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -253,15 +253,15 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadNoBaseId() { - $params = array(); - $files = array( - 'files' => array( + $params = []; + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -277,18 +277,18 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUpload2Files() { - $params = array('base_id' => self::$DI['collection']->get_base_id()); - $files = array( - 'files' => array( + $params = ['base_id' => self::$DI['collection']->get_base_id()]; + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ), new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -304,19 +304,19 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadForceRecord() { - $params = array( + $params = [ 'base_id' => self::$DI['collection']->get_base_id(), 'forceAction' => Manager::FORCE_RECORD, - ); + ]; - $files = array( - 'files' => array( + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -331,7 +331,7 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $id = explode('_', $datas['id']); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); $this->assertFalse($record->is_grouping()); - $this->assertEquals(array(), $datas['reasons']); + $this->assertEquals([], $datas['reasons']); } /** @@ -339,20 +339,20 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadRecordStatus() { - $params = array( + $params = [ 'base_id' => self::$DI['collection']->get_base_id(), 'forceAction' => Manager::FORCE_RECORD, - 'status' => array( self::$DI['collection']->get_base_id() => array( 4 => 1)), - ); + 'status' => [ self::$DI['collection']->get_base_id() => [ 4 => 1]], + ]; - $files = array( - 'files' => array( + $files = [ + 'files' => [ new UploadedFile( $this->tmpFile, 'KIKOO.JPG' ) - ) - ); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + ] + ]; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -368,7 +368,7 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); $this->assertFalse($record->is_grouping()); $this->assertEquals(1, substr(strrev($record->get_status()), 4, 1)); - $this->assertEquals(array(), $datas['reasons']); + $this->assertEquals([], $datas['reasons']); } /** @@ -376,9 +376,9 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadNoFiles() { - $params = array('base_id' => self::$DI['collection']->get_base_id()); - $files = array(); - self::$DI['client']->request('POST', '/prod/upload/', $params, $files, array('HTTP_Accept' => 'application/json')); + $params = ['base_id' => self::$DI['collection']->get_base_id()]; + $files = []; + self::$DI['client']->request('POST', '/prod/upload/', $params, $files, ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); @@ -394,7 +394,7 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUploadWithoutAnything() { - self::$DI['client']->request('POST', '/prod/upload/', array(), array(), array('HTTP_Accept' => 'application/json')); + self::$DI['client']->request('POST', '/prod/upload/', [], [], ['HTTP_Accept' => 'application/json']); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php index 6b9030d483..1bb53b7f88 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php @@ -20,7 +20,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/all/'; - self::$DI['client']->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json")); + self::$DI['client']->request('GET', $route, [], [], ["HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); @@ -74,7 +74,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertFalse($datas['success']); - self::$DI['client']->request('POST', $route, array('name' => 'New List')); + self::$DI['client']->request('POST', $route, ['name' => 'New List']); $response = self::$DI['client']->getResponse(); @@ -96,7 +96,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list_id . '/'; - self::$DI['client']->request('GET', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json")); + self::$DI['client']->request('GET', $route, [], [], ["HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); $this->assertEquals(200, $response->getStatusCode()); @@ -130,7 +130,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertFalse($datas['success']); - self::$DI['client']->request('POST', $route, array('name' => 'New NAME')); + self::$DI['client']->request('POST', $route, ['name' => 'New NAME']); $response = self::$DI['client']->getResponse(); @@ -180,7 +180,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list_id . '/remove/' . $usr_id . '/'; - self::$DI['client']->request('POST', $route, array(), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json")); + self::$DI['client']->request('POST', $route, [], [], ["HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); @@ -207,7 +207,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/add/'; - self::$DI['client']->request('POST', $route, array('usr_ids' => array(self::$DI['user']->get_id())), array(), array("HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json")); + self::$DI['client']->request('POST', $route, ['usr_ids' => [self::$DI['user']->get_id()]], [], ["HTTP_CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json"]); $response = self::$DI['client']->getResponse(); @@ -245,7 +245,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/'; - self::$DI['client']->request('POST', $route, array('role' => 'general')); + self::$DI['client']->request('POST', $route, ['role' => 'general']); $response = self::$DI['client']->getResponse(); @@ -254,7 +254,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/'; - self::$DI['client']->request('POST', $route, array('role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_ADMIN)); + self::$DI['client']->request('POST', $route, ['role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_ADMIN]); $response = self::$DI['client']->getResponse(); @@ -284,7 +284,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/'; - self::$DI['client']->request('POST', $route, array('role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_ADMIN)); + self::$DI['client']->request('POST', $route, ['role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_ADMIN]); $response = self::$DI['client']->getResponse(); @@ -335,7 +335,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/'; - self::$DI['client']->request('POST', $route, array('role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_ADMIN)); + self::$DI['client']->request('POST', $route, ['role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_ADMIN]); $response = self::$DI['client']->getResponse(); @@ -351,7 +351,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user']->get_id() . '/'; - self::$DI['client']->request('POST', $route, array('role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_USER)); + self::$DI['client']->request('POST', $route, ['role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_USER]); $response = self::$DI['client']->getResponse(); @@ -367,7 +367,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/'; - self::$DI['client']->request('POST', $route, array('role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_USER)); + self::$DI['client']->request('POST', $route, ['role' => \Alchemy\Phrasea\Model\Entities\UsrListOwner::ROLE_USER]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php index ea0a334ed4..30df5b0b0c 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php @@ -35,7 +35,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $story = self::$DI['record_story_1']; $route = sprintf("/prod/WorkZone/attachStories/"); - self::$DI['client']->request('POST', $route, array('stories' => array($story->get_serialize_key()))); + self::$DI['client']->request('POST', $route, ['stories' => [$story->get_serialize_key()]]); $response = self::$DI['client']->getResponse(); $this->assertEquals(302, $response->getStatusCode()); @@ -57,9 +57,9 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $route = sprintf("/prod/WorkZone/attachStories/"); $story2 = self::$DI['record_story_2']; - $stories = array($story->get_serialize_key(), $story2->get_serialize_key()); + $stories = [$story->get_serialize_key(), $story2->get_serialize_key()]; - self::$DI['client']->request('POST', $route, array('stories' => $stories)); + self::$DI['client']->request('POST', $route, ['stories' => $stories]); $response = self::$DI['client']->getResponse(); $this->assertEquals(302, $response->getStatusCode()); @@ -96,7 +96,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['EM']->persist($StoryWZ); self::$DI['app']['EM']->flush(); - self::$DI['client']->request('POST', $route, array('stories' => array($story->get_serialize_key()))); + self::$DI['client']->request('POST', $route, ['stories' => [$story->get_serialize_key()]]); $response = self::$DI['client']->getResponse(); $this->assertEquals(302, $response->getStatusCode()); @@ -117,8 +117,8 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $story = self::$DI['record_story_1']; $route = sprintf("/prod/WorkZone/attachStories/"); //attach JSON - self::$DI['client']->request('POST', $route, array('stories' => array($story->get_serialize_key())), array(), array( - "HTTP_ACCEPT" => "application/json") + self::$DI['client']->request('POST', $route, ['stories' => [$story->get_serialize_key()]], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); @@ -126,8 +126,8 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(200, $response->getStatusCode()); //test already attached - self::$DI['client']->request('POST', $route, array('stories' => array($story->get_serialize_key())), array(), array( - "HTTP_ACCEPT" => "application/json") + self::$DI['client']->request('POST', $route, ['stories' => [$story->get_serialize_key()]], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); @@ -149,7 +149,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract //attach $attachRoute = sprintf("/prod/WorkZone/attachStories/"); - self::$DI['client']->request('POST', $attachRoute, array('stories' => array($story->get_serialize_key()))); + self::$DI['client']->request('POST', $attachRoute, ['stories' => [$story->get_serialize_key()]]); $query = self::$DI['app']['EM']->createQuery( 'SELECT COUNT(w.id) FROM \Alchemy\Phrasea\Model\Entities\StoryWZ w' @@ -173,11 +173,11 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(0, $count); //attach - self::$DI['client']->request('POST', $attachRoute, array('stories' => array($story->get_serialize_key()))); + self::$DI['client']->request('POST', $attachRoute, ['stories' => [$story->get_serialize_key()]]); //detach JSON - self::$DI['client']->request('POST', $route, array(), array(), array( - "HTTP_ACCEPT" => "application/json") + self::$DI['client']->request('POST', $route, [], [], [ + "HTTP_ACCEPT" => "application/json"] ); $response = self::$DI['client']->getResponse(); $this->assertEquals(200, $response->getStatusCode()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/RecordsRequestTest.php b/tests/Alchemy/Tests/Phrasea/Controller/RecordsRequestTest.php index ba8c2bccd9..16c2ed84cf 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/RecordsRequestTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/RecordsRequestTest.php @@ -16,14 +16,14 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract self::$DI['app'] = new Application('test'); self::giveRightsToUser(self::$DI['app'], self::$DI['user']); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); } public function testSimple() { - $request = new Request(array( - 'lst' => implode(';', array( + $request = new Request([ + 'lst' => implode(';', [ self::$DI['record_24']->get_serialize_key(), self::$DI['record_24']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), @@ -35,8 +35,8 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract '0_', '_490', '_', - )) - )); + ]) + ]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request); @@ -61,11 +61,11 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleSimple() { - $request = new Request(array( - 'lst' => implode(';', array( + $request = new Request([ + 'lst' => implode(';', [ self::$DI['record_2']->get_serialize_key(), - )) - )); + ]) + ]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request); @@ -87,15 +87,15 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleWithoutSbasRights() { self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser()) - ->update_rights_to_sbas(self::$DI['record_2']->get_sbas_id(), array('bas_chupub' => 0)); + ->update_rights_to_sbas(self::$DI['record_2']->get_sbas_id(), ['bas_chupub' => 0]); - $request = new Request(array( - 'lst' => implode(';', array( + $request = new Request([ + 'lst' => implode(';', [ self::$DI['record_2']->get_serialize_key(), - )) - )); + ]) + ]); - $records = RecordsRequest::fromRequest(self::$DI['app'], $request, false, array(), array('bas_chupub')); + $records = RecordsRequest::fromRequest(self::$DI['app'], $request, false, [], ['bas_chupub']); $this->assertEquals(0, count($records)); $this->assertEquals(1, count($records->received())); @@ -113,15 +113,15 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleWithoutBasRights() { self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser()) - ->update_rights_to_base(self::$DI['record_2']->get_base_id(), array('chgstatus' => 0)); + ->update_rights_to_base(self::$DI['record_2']->get_base_id(), ['chgstatus' => 0]); - $request = new Request(array( - 'lst' => implode(';', array( + $request = new Request([ + 'lst' => implode(';', [ self::$DI['record_2']->get_serialize_key(), - )) - )); + ]) + ]); - $records = RecordsRequest::fromRequest(self::$DI['app'], $request, false, array('chgstatus')); + $records = RecordsRequest::fromRequest(self::$DI['app'], $request, false, ['chgstatus']); $this->assertEquals(0, count($records)); $this->assertEquals(1, count($records->received())); @@ -138,16 +138,16 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleFlatten() { - $request = new Request(array( - 'lst' => implode(';', array( + $request = new Request([ + 'lst' => implode(';', [ self::$DI['record_24']->get_serialize_key(), self::$DI['record_24']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(), self::$DI['record_story_2']->get_serialize_key(), self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_no_access_by_status']->get_serialize_key(), - )) - )); + ]) + ]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request, true); @@ -172,7 +172,7 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleBasket() { $basketElement = $this->insertOneBasketElement(); - $request = new Request(array('ssel' => $basketElement->getBasket()->getId())); + $request = new Request(['ssel' => $basketElement->getBasket()->getId()]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request); @@ -192,12 +192,12 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function getBasket() { - $elements = array( + $elements = [ self::$DI['record_24'], self::$DI['record_2'], self::$DI['record_no_access'], self::$DI['record_no_access_by_status'], - ); + ]; $basket = new \Alchemy\Phrasea\Model\Entities\Basket(); $basket->setName('test'); @@ -221,7 +221,7 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleStory() { $story = $this->getStoryWZ(); - $request = new Request(array('story' => $story->getId())); + $request = new Request(['story' => $story->getId()]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request); @@ -230,7 +230,7 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract $this->assertEquals(1, count($records->stories())); $this->assertInstanceOf('record_adapter', $records->singleStory()); $this->assertTrue($records->isSingleStory()); - $this->assertEquals(array($story->getRecord(self::$DI['app'])->get_databox()), $records->databoxes()); + $this->assertEquals([$story->getRecord(self::$DI['app'])->get_databox()], $records->databoxes()); $serialized = $records->serializedList(); $exploded = explode(';', $serialized); @@ -242,7 +242,7 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleStoryFlatten() { $story = $this->getStoryWZ(); - $request = new Request(array('story' => $story->getId())); + $request = new Request(['story' => $story->getId()]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request, true); @@ -251,7 +251,7 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract $this->assertEquals(0, count($records->stories())); $this->assertNull($records->singleStory()); $this->assertFalse($records->isSingleStory()); - $this->assertEquals(array(), $records->databoxes()); + $this->assertEquals([], $records->databoxes()); $serialized = $records->serializedList(); $exploded = explode(';', $serialized); @@ -263,7 +263,7 @@ class RecordsRequestTest extends \PhraseanetPHPUnitAuthenticatedAbstract public function testSimpleStoryFlattenAndPreserve() { $story = $this->getStoryWZ(); - $request = new Request(array('story' => $story->getId())); + $request = new Request(['story' => $story->getId()]); $records = RecordsRequest::fromRequest(self::$DI['app'], $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Report/ActivityTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Report/ActivityTest.php index 38d592426b..c071b0770e 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Report/ActivityTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Report/ActivityTest.php @@ -15,14 +15,14 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsByUsers() { - self::$DI['client']->request('POST', '/report/activity/users/connexions', array( + self::$DI['client']->request('POST', '/report/activity/users/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -31,7 +31,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsByUsersCSV() { - self::$DI['client']->request('POST', '/report/activity/users/connexions', array( + self::$DI['client']->request('POST', '/report/activity/users/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -39,7 +39,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'page' => 1, 'limit' => 10, 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -48,14 +48,14 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsByUsers() { - self::$DI['client']->request('POST', '/report/activity/users/downloads', array( + self::$DI['client']->request('POST', '/report/activity/users/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -64,7 +64,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsByUsersCSV() { - self::$DI['client']->request('POST', '/report/activity/users/downloads', array( + self::$DI['client']->request('POST', '/report/activity/users/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -72,7 +72,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'page' => 1, 'limit' => 10, 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -81,13 +81,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportBestOfQuestions() { - self::$DI['client']->request('POST', '/report/activity/questions/best-of', array( + self::$DI['client']->request('POST', '/report/activity/questions/best-of', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -96,14 +96,14 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportBestOfQuestionsCSV() { - self::$DI['client']->request('POST', '/report/activity/questions/best-of', array( + self::$DI['client']->request('POST', '/report/activity/questions/best-of', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'limit' => 10, 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -112,13 +112,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportNoBestOfQuestions() { - self::$DI['client']->request('POST', '/report/activity/questions/no-best-of', array( + self::$DI['client']->request('POST', '/report/activity/questions/no-best-of', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -127,14 +127,14 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportNoBestOfQuestionsCSV() { - self::$DI['client']->request('POST', '/report/activity/questions/no-best-of', array( + self::$DI['client']->request('POST', '/report/activity/questions/no-best-of', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'limit' => 10, 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -143,12 +143,12 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportSiteActiviyPerHours() { - self::$DI['client']->request('POST', '/report/activity/instance/hours', array( + self::$DI['client']->request('POST', '/report/activity/instance/hours', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -157,13 +157,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportSiteActiviyPerHoursCSV() { - self::$DI['client']->request('POST', '/report/activity/instance/hours', array( + self::$DI['client']->request('POST', '/report/activity/instance/hours', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -172,12 +172,12 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportSiteActiviyPerDays() { - self::$DI['client']->request('POST', '/report/activity/instance/days', array( + self::$DI['client']->request('POST', '/report/activity/instance/days', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -186,13 +186,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportSiteActiviyPerDaysCSV() { - self::$DI['client']->request('POST', '/report/activity/instance/days', array( + self::$DI['client']->request('POST', '/report/activity/instance/days', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -201,7 +201,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportPushedDocuments() { - self::$DI['client']->request('POST', '/report/activity/documents/pushed', array( + self::$DI['client']->request('POST', '/report/activity/documents/pushed', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -210,7 +210,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -219,13 +219,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportPushedDocumentsPrintCSV() { - self::$DI['client']->request('POST', '/report/activity/documents/pushed', array( + self::$DI['client']->request('POST', '/report/activity/documents/pushed', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -234,13 +234,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportPushedDocumentsFilterColumns() { - self::$DI['client']->request('POST', '/report/activity/documents/pushed', array( + self::$DI['client']->request('POST', '/report/activity/documents/pushed', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -249,7 +249,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportPushedDocumentsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/activity/documents/pushed', array( + self::$DI['client']->request('POST', '/report/activity/documents/pushed', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -257,7 +257,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -266,13 +266,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportPushedDocumentsFilterConf() { - self::$DI['client']->request('POST', '/report/activity/documents/pushed', array( + self::$DI['client']->request('POST', '/report/activity/documents/pushed', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -281,13 +281,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportPushedDocumentsGroupBy() { - self::$DI['client']->request('POST', '/report/activity/documents/pushed', array( + self::$DI['client']->request('POST', '/report/activity/documents/pushed', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -296,7 +296,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportAddedDocuments() { - self::$DI['client']->request('POST', '/report/activity/documents/added', array( + self::$DI['client']->request('POST', '/report/activity/documents/added', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -305,7 +305,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -314,13 +314,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportAddedDocumentsPrintCSV() { - self::$DI['client']->request('POST', '/report/activity/documents/added', array( + self::$DI['client']->request('POST', '/report/activity/documents/added', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -329,13 +329,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportAddedDocumentsFilterColumns() { - self::$DI['client']->request('POST', '/report/activity/documents/added', array( + self::$DI['client']->request('POST', '/report/activity/documents/added', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -344,7 +344,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportAddedDocumentsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/activity/documents/added', array( + self::$DI['client']->request('POST', '/report/activity/documents/added', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -352,7 +352,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -361,13 +361,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportAddedDocumentsFilterConf() { - self::$DI['client']->request('POST', '/report/activity/documents/added', array( + self::$DI['client']->request('POST', '/report/activity/documents/added', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -376,13 +376,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportAddedDocumentsGroupBy() { - self::$DI['client']->request('POST', '/report/activity/documents/added', array( + self::$DI['client']->request('POST', '/report/activity/documents/added', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -391,7 +391,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportEditedDocuments() { - self::$DI['client']->request('POST', '/report/activity/documents/edited', array( + self::$DI['client']->request('POST', '/report/activity/documents/edited', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -400,7 +400,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -409,13 +409,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportEditedDocumentsPrintCSV() { - self::$DI['client']->request('POST', '/report/activity/documents/edited', array( + self::$DI['client']->request('POST', '/report/activity/documents/edited', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -424,13 +424,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportEditedDocumentsFilterColumns() { - self::$DI['client']->request('POST', '/report/activity/documents/edited', array( + self::$DI['client']->request('POST', '/report/activity/documents/edited', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -439,7 +439,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportEditedDocumentsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/activity/documents/edited', array( + self::$DI['client']->request('POST', '/report/activity/documents/edited', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -447,7 +447,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -456,13 +456,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportEditedDocumentsFilterConf() { - self::$DI['client']->request('POST', '/report/activity/documents/edited', array( + self::$DI['client']->request('POST', '/report/activity/documents/edited', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -471,13 +471,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportEditedDocumentsGroupBy() { - self::$DI['client']->request('POST', '/report/activity/documents/edited', array( + self::$DI['client']->request('POST', '/report/activity/documents/edited', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -486,7 +486,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportValidatedDocuments() { - self::$DI['client']->request('POST', '/report/activity/documents/validated', array( + self::$DI['client']->request('POST', '/report/activity/documents/validated', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -495,7 +495,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -504,13 +504,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportValidatedDocumentsPrintCSV() { - self::$DI['client']->request('POST', '/report/activity/documents/validated', array( + self::$DI['client']->request('POST', '/report/activity/documents/validated', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -519,13 +519,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportValidatedDocumentsFilterColumns() { - self::$DI['client']->request('POST', '/report/activity/documents/validated', array( + self::$DI['client']->request('POST', '/report/activity/documents/validated', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -534,7 +534,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportValidatedDocumentsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/activity/documents/validated', array( + self::$DI['client']->request('POST', '/report/activity/documents/validated', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -542,7 +542,7 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -551,13 +551,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportValidatedDocumentsFilterConf() { - self::$DI['client']->request('POST', '/report/activity/documents/validated', array( + self::$DI['client']->request('POST', '/report/activity/documents/validated', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -566,13 +566,13 @@ class ActivityTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportValidatedDocumentsGroupBy() { - self::$DI['client']->request('POST', '/report/activity/documents/validated', array( + self::$DI['client']->request('POST', '/report/activity/documents/validated', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Report/ExportTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Report/ExportTest.php index f4d335e453..b54fd83ed0 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Report/ExportTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Report/ExportTest.php @@ -11,10 +11,10 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 1997,Ford,E350 2000,Mercury,Cougar'; - self::$DI['client']->request('POST', '/report/export/csv', array( + self::$DI['client']->request('POST', '/report/export/csv', [ 'csv' => $data, 'name' => 'test', - )); + ]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Report/InformationsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Report/InformationsTest.php index 54b1f402f8..1164c3d56b 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Report/InformationsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Report/InformationsTest.php @@ -15,12 +15,12 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserBadRequest() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -30,13 +30,13 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUser() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'user' => self::$DI['user']->get_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -45,14 +45,14 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromConnexion() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'user' => self::$DI['user']->get_id(), 'from' => 'CNX', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -61,14 +61,14 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromQuestion() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'from' => 'ASK', 'user' => self::$DI['user']->get_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -77,14 +77,14 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromDownload() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'from' => 'GEN', 'user' => self::$DI['user']->get_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -93,7 +93,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromConnexionCSV() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -101,7 +101,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'from' => 'CNX', 'printcsv' => 'on', 'user' => self::$DI['user']->get_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -110,7 +110,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromQuestionCSV() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -118,7 +118,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'from' => 'ASK', 'printcsv' => 'on', 'user' => self::$DI['user']->get_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -127,7 +127,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromDownloadCSV() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -135,7 +135,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'from' => 'GEN', 'printcsv' => 'on', 'user' => self::$DI['user']->get_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -144,7 +144,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromDownloadOnCustomField() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -152,7 +152,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'from' => 'GEN', 'on' => 'usr_mail', 'user' => self::$DI['user']->get_email() - )); + ]); $response = self::$DI['client']->getResponse(); @@ -161,7 +161,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromConnexionOnCustomField() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -169,7 +169,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'from' => 'CNX', 'on' => 'usr_mail', 'user' => self::$DI['user']->get_email() - )); + ]); $response = self::$DI['client']->getResponse(); @@ -178,7 +178,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportUserFromQuestionOnCustomField() { - self::$DI['client']->request('POST', '/report/informations/user', array( + self::$DI['client']->request('POST', '/report/informations/user', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -186,7 +186,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'from' => 'ASK', 'on' => 'usr_mail', 'user' => self::$DI['user']->get_email() - )); + ]); $response = self::$DI['client']->getResponse(); @@ -195,12 +195,12 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInformationsBrowserBadRequest() { - self::$DI['client']->request('POST', '/report/informations/browser', array( + self::$DI['client']->request('POST', '/report/informations/browser', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -210,13 +210,13 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInfomationsBrowser() { - self::$DI['client']->request('POST', '/report/informations/browser', array( + self::$DI['client']->request('POST', '/report/informations/browser', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'user' => 'chrome', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -225,14 +225,14 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInfomationsDocumentsNotFound() { - self::$DI['client']->request('POST', '/report/informations/document', array( + self::$DI['client']->request('POST', '/report/informations/document', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'sbasid' => 0, 'rid' => 0, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -242,14 +242,14 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInfomationsDocuments() { - self::$DI['client']->request('POST', '/report/informations/document', array( + self::$DI['client']->request('POST', '/report/informations/document', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'sbasid' => self::$DI['record_1']->get_sbas_id(), 'rid' => self::$DI['record_1']->get_record_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -258,7 +258,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInfomationsDocumentsFromTool() { - self::$DI['client']->request('POST', '/report/informations/document', array( + self::$DI['client']->request('POST', '/report/informations/document', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -266,7 +266,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'sbasid' => self::$DI['record_1']->get_sbas_id(), 'rid' => self::$DI['record_1']->get_record_id(), 'from' => 'TOOL' - )); + ]); $response = self::$DI['client']->getResponse(); @@ -275,7 +275,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInfomationsDocumentsFromDashboard() { - self::$DI['client']->request('POST', '/report/informations/document', array( + self::$DI['client']->request('POST', '/report/informations/document', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -283,7 +283,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'sbasid' => self::$DI['record_1']->get_sbas_id(), 'rid' => self::$DI['record_1']->get_record_id(), 'from' => 'DASH' - )); + ]); $response = self::$DI['client']->getResponse(); @@ -292,7 +292,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportInfomationsDocumentsFromOther() { - self::$DI['client']->request('POST', '/report/informations/document', array( + self::$DI['client']->request('POST', '/report/informations/document', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -300,7 +300,7 @@ class InformationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'sbasid' => self::$DI['record_1']->get_sbas_id(), 'rid' => self::$DI['record_1']->get_record_id(), 'user' => self::$DI['user']->get_id() - )); + ]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Report/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Report/RootTest.php index 07ff64abf8..895f273040 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Report/RootTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Report/RootTest.php @@ -28,10 +28,10 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->authenticate(self::$DI['app']); - $this->XMLHTTPRequest('GET', '/report/dashboard', array( + $this->XMLHTTPRequest('GET', '/report/dashboard', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmin->format('Y-m-d H:i:s'), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -40,7 +40,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRouteInitReport() { - self::$DI['client']->request('POST', '/report/init', array('popbases' => array('1_1'))); + self::$DI['client']->request('POST', '/report/init', ['popbases' => ['1_1']]); $response = self::$DI['client']->getResponse(); @@ -49,7 +49,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexions() { - self::$DI['client']->request('POST', '/report/connexions', array( + self::$DI['client']->request('POST', '/report/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -58,7 +58,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -67,13 +67,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsPrintCSV() { - self::$DI['client']->request('POST', '/report/connexions', array( + self::$DI['client']->request('POST', '/report/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -82,13 +82,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsFilterColumns() { - self::$DI['client']->request('POST', '/report/connexions', array( + self::$DI['client']->request('POST', '/report/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -97,7 +97,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/connexions', array( + self::$DI['client']->request('POST', '/report/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -105,7 +105,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -114,13 +114,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsFilterConf() { - self::$DI['client']->request('POST', '/report/connexions', array( + self::$DI['client']->request('POST', '/report/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -129,13 +129,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportConnexionsGroupBy() { - self::$DI['client']->request('POST', '/report/connexions', array( + self::$DI['client']->request('POST', '/report/connexions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -144,7 +144,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportQuestions() { - self::$DI['client']->request('POST', '/report/questions', array( + self::$DI['client']->request('POST', '/report/questions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -153,7 +153,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -162,13 +162,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportQuestionsPrintCSV() { - self::$DI['client']->request('POST', '/report/questions', array( + self::$DI['client']->request('POST', '/report/questions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -177,13 +177,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportQuestionsFilterColumns() { - self::$DI['client']->request('POST', '/report/questions', array( + self::$DI['client']->request('POST', '/report/questions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -192,7 +192,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportQuestionsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/questions', array( + self::$DI['client']->request('POST', '/report/questions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -200,7 +200,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -209,13 +209,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportQuestionsFilterConf() { - self::$DI['client']->request('POST', '/report/questions', array( + self::$DI['client']->request('POST', '/report/questions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -224,13 +224,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportQuestionsGroupBy() { - self::$DI['client']->request('POST', '/report/questions', array( + self::$DI['client']->request('POST', '/report/questions', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -239,7 +239,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloads() { - self::$DI['client']->request('POST', '/report/downloads', array( + self::$DI['client']->request('POST', '/report/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -248,7 +248,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'champ' => 'user', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -257,13 +257,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsPrintCSV() { - self::$DI['client']->request('POST', '/report/downloads', array( + self::$DI['client']->request('POST', '/report/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -272,13 +272,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsFilterColumns() { - self::$DI['client']->request('POST', '/report/downloads', array( + self::$DI['client']->request('POST', '/report/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'user ddate', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -287,7 +287,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/downloads', array( + self::$DI['client']->request('POST', '/report/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -295,7 +295,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'user', 'filter_value' => 'admin', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -304,13 +304,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsFilterConf() { - self::$DI['client']->request('POST', '/report/downloads', array( + self::$DI['client']->request('POST', '/report/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -319,13 +319,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDownloadsGroupBy() { - self::$DI['client']->request('POST', '/report/downloads', array( + self::$DI['client']->request('POST', '/report/downloads', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'user', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -334,7 +334,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDocuments() { - self::$DI['client']->request('POST', '/report/documents', array( + self::$DI['client']->request('POST', '/report/documents', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -344,7 +344,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'tbl' => 'DOC', 'page' => 1, 'limit' => 10, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -353,13 +353,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDocumentsPrintCSV() { - self::$DI['client']->request('POST', '/report/documents', array( + self::$DI['client']->request('POST', '/report/documents', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -368,13 +368,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDocumentsFilterColumns() { - self::$DI['client']->request('POST', '/report/documents', array( + self::$DI['client']->request('POST', '/report/documents', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'list_column' => 'file mime', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -383,7 +383,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDocumentsFilterResultOnOneColumn() { - self::$DI['client']->request('POST', '/report/documents', array( + self::$DI['client']->request('POST', '/report/documents', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), @@ -391,7 +391,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'filter_column' => 'mime', 'filter_value' => 'pdf', 'liste' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -400,13 +400,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDocumentsFilterConf() { - self::$DI['client']->request('POST', '/report/documents', array( + self::$DI['client']->request('POST', '/report/documents', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'conf' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -415,13 +415,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportDocumentsGroupBy() { - self::$DI['client']->request('POST', '/report/documents', array( + self::$DI['client']->request('POST', '/report/documents', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'groupby' => 'mime', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -430,12 +430,12 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportClients() { - self::$DI['client']->request('POST', '/report/clients', array( + self::$DI['client']->request('POST', '/report/clients', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), - )); + ]); $response = self::$DI['client']->getResponse(); @@ -444,13 +444,13 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testDoReportClientPrintCSV() { - self::$DI['client']->request('POST', '/report/clients', array( + self::$DI['client']->request('POST', '/report/clients', [ 'dmin' => $this->dmin->format('Y-m-d H:i:s'), 'dmax' => $this->dmax->format('Y-m-d H:i:s'), 'sbasid' => self::$DI['collection']->get_sbas_id(), 'collection' => self::$DI['collection']->get_coll_id(), 'printcsv' => 'on', - )); + ]); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php index 2c0c52a5b6..2a571152e1 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php @@ -81,7 +81,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testGetResetMailWithToken() { $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_EMAIL, self::$DI['user']->get_id(), null, 'new_email@email.com'); - $crawler = self::$DI['client']->request('GET', '/account/reset-email/', array('token' => $token)); + $crawler = self::$DI['client']->request('GET', '/account/reset-email/', ['token' => $token]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); $this->assertEquals('/account/', $response->headers->get('location')); @@ -103,7 +103,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testGetResetMailWithBadToken() { - self::$DI['client']->request('GET', '/account/reset-email/', array('token' => '134dT0k3n')); + self::$DI['client']->request('GET', '/account/reset-email/', ['token' => '134dT0k3n']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); $this->assertEquals('/account/', $response->headers->get('location')); @@ -126,11 +126,11 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testPostResetMailBadPassword() { - self::$DI['client']->request('POST', '/account/reset-email/', array( + self::$DI['client']->request('POST', '/account/reset-email/', [ 'form_password' => 'changeme', 'form_email' => 'new@email.com', 'form_email_confirm' => 'new@email.com', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -146,11 +146,11 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $password = \random::generatePassword(); self::$DI['app']['authentication']->getUser()->set_password($password); - self::$DI['client']->request('POST', '/account/reset-email/', array( + self::$DI['client']->request('POST', '/account/reset-email/', [ 'form_password' => $password, 'form_email' => "invalid#!&&@@email.x", 'form_email_confirm' => 'invalid#!&&@@email.x', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -166,11 +166,11 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $password = \random::generatePassword(); self::$DI['app']['authentication']->getUser()->set_password($password); - self::$DI['client']->request('POST', '/account/reset-email/', array( + self::$DI['client']->request('POST', '/account/reset-email/', [ 'form_password' => $password, 'form_email' => 'email1@email.com', 'form_email_confirm' => 'email2@email.com', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -188,11 +188,11 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $password = \random::generatePassword(); self::$DI['app']['authentication']->getUser()->set_password($password); - self::$DI['client']->request('POST', '/account/reset-email/', array( + self::$DI['client']->request('POST', '/account/reset-email/', [ 'form_password' => $password, 'form_email' => 'email1@email.com', 'form_email_confirm' => 'email1@email.com', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -272,7 +272,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUpdateAccount() { - $bases = $notifs = array(); + $bases = $notifs = []; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { @@ -292,7 +292,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract array_shift($notifs); - self::$DI['client']->request('POST', '/account/', array( + self::$DI['client']->request('POST', '/account/', [ 'demand' => $bases, 'form_gender' => 'M', 'form_firstname' => 'gros', @@ -312,9 +312,9 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'form_prefixFTPfolder' => '', 'form_retryFTP' => '', 'notifications' => $notifs, - 'form_defaultdataFTP' => array('document', 'preview', 'caption'), + 'form_defaultdataFTP' => ['document', 'preview', 'caption'], 'mail_notifications' => '1' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -322,7 +322,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $sql = 'SELECT base_id FROM demand WHERE usr_id = :usr_id AND en_cours="1" '; $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => self::$DI['app']['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => self::$DI['app']['authentication']->getUser()->get_id()]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -338,7 +338,7 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testAUthorizedAppGrantAccessNotSuccessfull() { - self::$DI['client']->request('GET', '/account/security/application/0/grant/', array(), array(), array('HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest')); + self::$DI['client']->request('GET', '/account/security/application/0/grant/', [], [], ['HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -357,12 +357,12 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->markTestSkipped('Application could not be created'); } - self::$DI['client']->request('GET', '/account/security/application/' . self::$authorizedApp->get_id() . '/grant/', array( + self::$DI['client']->request('GET', '/account/security/application/' . self::$authorizedApp->get_id() . '/grant/', [ 'revoke' => $revoke - ), array(), array( + ], [], [ 'HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest' - )); + ]); $response = self::$DI['client']->getResponse(); @@ -383,12 +383,12 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function revokeProvider() { - return array( - array('1', true), - array('0', false), - array(null, false), - array('titi', true), - ); + return [ + ['1', true], + ['0', false], + [null, false], + ['titi', true], + ]; } /** @@ -398,14 +398,14 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$DI['app']['authentication']->getUser()->set_password($oldPassword); - $crawler = self::$DI['client']->request('POST', '/account/reset-password/', array( - 'password' => array( + $crawler = self::$DI['client']->request('POST', '/account/reset-password/', [ + 'password' => [ 'password' => $password, 'confirm' => $passwordConfirm - ), + ], 'oldPassword' => $oldPassword, '_token' => 'token', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -415,14 +415,14 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPostRenewPasswordBadOldPassword() { - $crawler = self::$DI['client']->request('POST', '/account/reset-password/', array( - 'password' => array( + $crawler = self::$DI['client']->request('POST', '/account/reset-password/', [ + 'password' => [ 'password' => 'password', 'confirm' => 'password' - ), + ], 'oldPassword' => 'oulala', '_token' => 'token', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertFalse($response->isRedirect()); @@ -435,13 +435,13 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['authentication']->getUser()->set_password($password); - $crawler = self::$DI['client']->request('POST', '/account/reset-password/', array( - 'password' => array( + $crawler = self::$DI['client']->request('POST', '/account/reset-password/', [ + 'password' => [ 'password' => 'password', 'confirm' => 'password' - ), + ], 'oldPassword' => $password, - )); + ]); $response = self::$DI['client']->getResponse(); @@ -455,14 +455,14 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['app']['authentication']->getUser()->set_password($password); - self::$DI['client']->request('POST', '/account/reset-password/', array( - 'password' => array( + self::$DI['client']->request('POST', '/account/reset-password/', [ + 'password' => [ 'password' => 'password', 'confirm' => 'password' - ), + ], 'oldPassword' => $password, '_token' => 'token', - )); + ]); $response = self::$DI['client']->getResponse(); @@ -474,8 +474,8 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function passwordProvider() { - return array( - array(\random::generatePassword(), 'password', 'not_identical_password'), - ); + return [ + [\random::generatePassword(), 'password', 'not_identical_password'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php index 1fad6aa72e..2bab3bdae3 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php @@ -33,7 +33,7 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testPostNewAppInvalidArguments() { - $crawler = self::$DI['client']->request('POST', '/developers/application/', array( + $crawler = self::$DI['client']->request('POST', '/developers/application/', [ 'type' => \API_OAuth2_Application::WEB_TYPE, 'name' => '', 'description' => 'okok', @@ -41,7 +41,7 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'callback' => 'my.callback.com', 'scheme-website' => 'http://', 'scheme-callback' => 'http://' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $form = $crawler->selectButton(_('boutton::valider'))->form(); @@ -58,7 +58,7 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $apps = \API_OAuth2_Application::load_dev_app_by_user(self::$DI['app'], self::$DI['user']); $nbApp = count($apps); - self::$DI['client']->request('POST', '/developers/application/', array( + self::$DI['client']->request('POST', '/developers/application/', [ 'type' => \API_OAuth2_Application::WEB_TYPE, 'name' => 'hello', 'description' => 'okok', @@ -66,7 +66,7 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract 'callback' => 'my.callback.com', 'scheme-website' => 'http://', 'scheme-callback' => 'http://' - )); + ]); $apps = \API_OAuth2_Application::load_dev_app_by_user(self::$DI['app'], self::$DI['user']); @@ -151,9 +151,9 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRenewAppCallbackError() { - $this->XMLHTTPRequest('POST', '/developers/application/0/callback/', array( + $this->XMLHTTPRequest('POST', '/developers/application/0/callback/', [ 'callback' => 'my.callback.com' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $content = json_decode(self::$DI['client']->getResponse()->getContent()); @@ -181,9 +181,9 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $oauthApp = \API_OAuth2_Application::create(self::$DI['app'], self::$DI['user'], 'test app'); - $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->get_id() . '/callback/', array( + $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->get_id() . '/callback/', [ 'callback' => 'my.callback.com' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $content = json_decode(self::$DI['client']->getResponse()->getContent()); @@ -207,9 +207,9 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testRenewAccessTokenError() { - $this->XMLHTTPRequest('POST', '/developers/application/0/access_token/', array( + $this->XMLHTTPRequest('POST', '/developers/application/0/access_token/', [ 'callback' => 'my.callback.com' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $content = json_decode(self::$DI['client']->getResponse()->getContent()); @@ -247,9 +247,9 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testAuthorizeGrantpasswordError() { - $this->XMLHTTPRequest('POST', '/developers/application/0/authorize_grant_password/', array( + $this->XMLHTTPRequest('POST', '/developers/application/0/authorize_grant_password/', [ 'callback' => 'my.callback.com' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $content = json_decode(self::$DI['client']->getResponse()->getContent()); @@ -263,9 +263,9 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $oauthApp = \API_OAuth2_Application::create(self::$DI['app'], self::$DI['user'], 'test app'); - $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->get_id() . '/authorize_grant_password/', array( + $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->get_id() . '/authorize_grant_password/', [ 'grant' => '1' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $content = json_decode(self::$DI['client']->getResponse()->getContent()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php index a8597adc28..d9f15f6a3b 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php @@ -27,10 +27,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract parent::setUp(); if (null === self::$demands) { - self::$demands = array(self::$DI['collection']->get_coll_id()); + self::$demands = [self::$DI['collection']->get_coll_id()]; } if (null === self::$collections) { - self::$collections = array(self::$DI['collection']->get_base_id()); + self::$collections = [self::$DI['collection']->get_base_id()]; $sxml = simplexml_load_string(self::$DI['collection']->get_prefs()); $sxml->caninscript = 1; @@ -103,7 +103,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->logout(self::$DI['app']); - self::$DI['client']->request('GET', '/login/', array('postlog' => '1', 'redirect' => 'prod')); + self::$DI['client']->request('GET', '/login/', ['postlog' => '1', 'redirect' => 'prod']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); $this->assertEquals('/login/logout/?redirect=prod', $response->headers->get('location')); @@ -141,9 +141,9 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRegisterConfirmMailWrongCode() { $this->logout(self::$DI['app']); - self::$DI['client']->request('GET', '/login/register-confirm/', array( + self::$DI['client']->request('GET', '/login/register-confirm/', [ 'code' => '34dT0k3n' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -159,9 +159,9 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); $email = $this->generateEmail(); $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_EMAIL, 0, null, $email); - self::$DI['client']->request('GET', '/login/register-confirm/', array( + self::$DI['client']->request('GET', '/login/register-confirm/', [ 'code' => $token - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -180,7 +180,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['user']->set_mail_locked(false); - self::$DI['client']->request('GET', '/login/register-confirm/', array('code' => $token)); + self::$DI['client']->request('GET', '/login/register-confirm/', ['code' => $token]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -203,7 +203,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['user']->set_mail_locked(true); $this->deleteRequest(); $appboxRegister->add_request(self::$DI['user'], self::$DI['collection']); - self::$DI['client']->request('GET', '/login/register-confirm/', array('code' => $token)); + self::$DI['client']->request('GET', '/login/register-confirm/', ['code' => $token]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -229,7 +229,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->deleteRequest(); - self::$DI['client']->request('GET', '/login/register-confirm/', array('code' => $token)); + self::$DI['client']->request('GET', '/login/register-confirm/', ['code' => $token]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -245,10 +245,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRenewPasswordInvalidEmail() { $this->logout(self::$DI['app']); - $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', array( + $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', [ 'email' => 'invalid.email.com', '_token' => 'token', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertFalse($response->isRedirect()); @@ -262,10 +262,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRenewPasswordUnknowEmail() { $this->logout(self::$DI['app']); - $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', array( + $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', [ 'email' => 'invalid_email@test.com', '_token' => 'token', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertFalse($response->isRedirect()); @@ -280,10 +280,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestPasswordUpdate'); $this->logout(self::$DI['app']); - self::$DI['client']->request('POST', '/login/forgot-password/', array( + self::$DI['client']->request('POST', '/login/forgot-password/', [ 'email' => self::$DI['user']->get_email(), '_token' => 'token', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -298,11 +298,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->logout(self::$DI['app']); $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_PASSWORD, self::$DI['user']->get_id()); - $crawler = self::$DI['client']->request('POST', '/login/renew-password/', array( + $crawler = self::$DI['client']->request('POST', '/login/renew-password/', [ 'token' => $token, '_token' => 'token', - 'password' => array('password' => 'password', 'confirm' => 'not_identical') - )); + 'password' => ['password' => 'password', 'confirm' => 'not_identical'] + ]); $response = self::$DI['client']->getResponse(); @@ -313,11 +313,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRenewPasswordBadToken() { $this->logout(self::$DI['app']); - self::$DI['client']->request('POST', '/login/renew-password/', array( + self::$DI['client']->request('POST', '/login/renew-password/', [ 'token' => 'badToken', '_token' => 'token', - 'password' => array('password' => 'password', 'confirm' => 'password') - )); + 'password' => ['password' => 'password', 'confirm' => 'password'] + ]); $response = self::$DI['client']->getResponse(); $this->assertEquals(401, $response->getStatusCode()); @@ -325,11 +325,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRenewPasswordBadTokenWheneverItsAuthenticated() { - self::$DI['client']->request('POST', '/login/renew-password/', array( + self::$DI['client']->request('POST', '/login/renew-password/', [ 'token' => 'badToken', '_token' => 'token', - 'password' => array('password' => 'password', 'confirm' => 'password') - )); + 'password' => ['password' => 'password', 'confirm' => 'password'] + ]); $response = self::$DI['client']->getResponse(); @@ -340,10 +340,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRenewPasswordNoToken() { $this->logout(self::$DI['app']); - self::$DI['client']->request('POST', '/login/renew-password/', array( + self::$DI['client']->request('POST', '/login/renew-password/', [ '_token' => 'token', - 'password' => array('password' => 'password', 'confirm' => 'password') - )); + 'password' => ['password' => 'password', 'confirm' => 'password'] + ]); $response = self::$DI['client']->getResponse(); @@ -352,10 +352,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRenewPasswordNoTokenWheneverItsAuthenticated() { - self::$DI['client']->request('POST', '/login/renew-password/', array( + self::$DI['client']->request('POST', '/login/renew-password/', [ '_token' => 'token', - 'password' => array('password' => 'password', 'confirm' => 'password') - )); + 'password' => ['password' => 'password', 'confirm' => 'password'] + ]); $response = self::$DI['client']->getResponse(); @@ -371,11 +371,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_PASSWORD, self::$DI['user']->get_id()); - self::$DI['client']->request('POST', '/login/renew-password/', array( + self::$DI['client']->request('POST', '/login/renew-password/', [ 'token' => $token, '_token' => 'token', - 'password' => array('password' => 'password', 'confirm' => 'password') - )); + 'password' => ['password' => 'password', 'confirm' => 'password'] + ]); $response = self::$DI['client']->getResponse(); @@ -395,9 +395,9 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_PASSWORD, self::$DI['user']->get_id()); - $crawler = self::$DI['client']->request('GET', '/login/renew-password/', array( + $crawler = self::$DI['client']->request('GET', '/login/renew-password/', [ 'token' => $token - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); @@ -425,10 +425,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testForgotPasswordInvalidEmail() { $this->logout(self::$DI['app']); - $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', array( + $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', [ '_token' => 'token', 'email' => 'invalid.email', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertFalse($response->isRedirect()); @@ -439,10 +439,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testForgotPasswordWrongEmail() { $this->logout(self::$DI['app']); - $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', array( + $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', [ '_token' => 'token', 'email' => 'invalid@email.com', - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertFalse($response->isRedirect()); @@ -455,10 +455,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestPasswordUpdate'); $this->logout(self::$DI['app']); - $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', array( + $crawler = self::$DI['client']->request('POST', '/login/forgot-password/', [ '_token' => 'token', 'email' => self::$DI['user']->get_email(), - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -518,11 +518,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function provideRegistrationRouteAndMethods() { - return array( - array('GET', '/login/register/'), - array('GET', '/login/register-classic/'), - array('POST', '/login/register-classic/'), - ); + return [ + ['GET', '/login/register/'], + ['GET', '/login/register-classic/'], + ['POST', '/login/register-classic/'], + ]; } /** @@ -547,7 +547,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); - $parameters = array_merge(array('_token' => 'token'), $parameters); + $parameters = array_merge(['_token' => 'token'], $parameters); foreach ($parameters as $key => $parameter) { if ('collections' === $key && null === $parameter) { $parameters[$key] = self::$demands; @@ -581,180 +581,180 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function provideInvalidRegistrationData() { - return array( - array(array(//required field missing - "password" => array( + return [ + [[//required field missing + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "accept-tou" => '1', "collections" => null, - ), array(), 1), - array(array(//required extra-field missing - "password" => array( + ], [], 1], + [[//required extra-field missing + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null - ), array( - array( + ], [ + [ 'name' => 'login', 'required' => true, - ) - ), 1), - array(array(//password mismatch - "password" => array( + ] + ], 1], + [[//password mismatch + "password" => [ 'password' => 'password', 'confirm' => 'passwordMismatch' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null - ), array(), 1), - array(array(//password tooshort - "password" => array( + ], [], 1], + [[//password tooshort + "password" => [ 'password' => 'min', 'confirm' => 'min' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null - ), array(), 1), - array(array(//email invalid - "password" => array( + ], [], 1], + [[//email invalid + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => 'invalid.email', "accept-tou" => '1', "collections" => null - ), array(), 1), - array(array(//login exists + ], [], 1], + [[//login exists "login" => null, - "password" => array( + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null - ), array( - array( + ], [ + [ 'name' => 'login', 'required' => true, - ) - ), 1), - array(array(//mails exists - "password" => array( + ] + ], 1], + [[//mails exists + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => null, "accept-tou" => '1', "collections" => null - ), array(), 1), - array(array(//tou declined - "password" => array( + ], [], 1], + [[//tou declined + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "collections" => null - ), array(), 1) - ); + ], [], 1] + ]; } public function provideRegistrationData() { - return array( - array(array( - "password" => array( + return [ + [[ + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null, - ), array()), - array(array( - "password" => array( + ], []], + [[ + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null - ), array( - array( + ], [ + [ 'name' => 'login', 'required' => false, - ) - )), - array(array(//extra-fields are not required - "password" => array( + ] + ]], + [[//extra-fields are not required + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null - ), array( - array( + ], [ + [ 'name' => 'login', 'required' => false, - ), - array( + ], + [ 'name' => 'gender', 'required' => false, - ), - array( + ], + [ 'name' => 'firstname', 'required' => false, - ), - array( + ], + [ 'name' => 'lastname', 'required' => false, - ), - array( + ], + [ 'name' => 'address', 'required' => false, - ), - array( + ], + [ 'name' => 'zipcode', 'required' => false, - ), - array( + ], + [ 'name' => 'geonameid', 'required' => false, - ), - array( + ], + [ 'name' => 'position', 'required' => false, - ), - array( + ], + [ 'name' => 'company', 'required' => false, - ), - array( + ], + [ 'name' => 'job', 'required' => false, - ), - array( + ], + [ 'name' => 'tel', 'required' => false, - ), - array( + ], + [ 'name' => 'fax', 'required' => false, - ) - )), - array(array(//extra-fields are required - "password" => array( + ] + ]], + [[//extra-fields are required + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null, @@ -770,63 +770,63 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract "job" => 'job', "tel" => 'tel', "fax" => 'fax', - ), array( - array( + ], [ + [ 'name' => 'login', 'required' => true, - ), - array( + ], + [ 'name' => 'gender', 'required' => true, - ), - array( + ], + [ 'name' => 'firstname', 'required' => true, - ), - array( + ], + [ 'name' => 'lastname', 'required' => true, - ), - array( + ], + [ 'name' => 'address', 'required' => true, - ), - array( + ], + [ 'name' => 'zipcode', 'required' => true, - ), - array( + ], + [ 'name' => 'geonameid', 'required' => true, - ), - array( + ], + [ 'name' => 'position', 'required' => true, - ), - array( + ], + [ 'name' => 'company', 'required' => true, - ), - array( + ], + [ 'name' => 'job', 'required' => true, - ), - array( + ], + [ 'name' => 'tel', 'required' => true, - ), - array( + ], + [ 'name' => 'fax', 'required' => true, - ) - )), - ); + ] + ]], + ]; } public function testPostRegisterWithProviderIdAndAlreadyBoundProvider() { $this->enableTOU(); - self::$DI['app']['registration.fields'] = array(); + self::$DI['app']['registration.fields'] = []; $this->logout(self::$DI['app']); $provider = $this->getMock('Alchemy\Phrasea\Authentication\Provider\ProviderInterface'); @@ -845,16 +845,16 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->method('getToken') ->will($this->returnValue($token)); - $parameters = array_merge(array('_token' => 'token'), array( - "password" => array( + $parameters = array_merge(['_token' => 'token'], [ + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null, "provider-id" => 'provider-test', - )); + ]); foreach ($parameters as $key => $parameter) { if ('collections' === $key && null === $parameter) { @@ -877,19 +877,19 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPostRegisterWithUnknownProvider() { $this->enableTOU(); - self::$DI['app']['registration.fields'] = array(); + self::$DI['app']['registration.fields'] = []; $this->logout(self::$DI['app']); - $parameters = array_merge(array('_token' => 'token'), array( - "password" => array( + $parameters = array_merge(['_token' => 'token'], [ + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null, "provider-id" => 'provider-test', - )); + ]); foreach ($parameters as $key => $parameter) { if ('collections' === $key && null === $parameter) { @@ -913,7 +913,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPostRegisterWithProviderNotAuthenticated() { $this->enableTOU(); - self::$DI['app']['registration.fields'] = array(); + self::$DI['app']['registration.fields'] = []; $this->logout(self::$DI['app']); $provider = $this->getMock('Alchemy\Phrasea\Authentication\Provider\ProviderInterface'); @@ -923,16 +923,16 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->method('getToken') ->will($this->throwException(new NotAuthenticatedException('Not authenticated'))); - $parameters = array_merge(array('_token' => 'token'), array( - "password" => array( + $parameters = array_merge(['_token' => 'token'], [ + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null, "provider-id" => 'provider-test', - )); + ]); foreach ($parameters as $key => $parameter) { if ('collections' === $key && null === $parameter) { @@ -956,27 +956,27 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testPostRegisterWithProviderId() { $this->enableTOU(); - self::$DI['app']['registration.fields'] = array(); + self::$DI['app']['registration.fields'] = []; $this->logout(self::$DI['app']); - $emails = array( + $emails = [ 'Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation'=>0, 'Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered'=>0, 'Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered'=>0, - ); + ]; $this->mockNotificationsDeliverer($emails); - $parameters = array_merge(array('_token' => 'token'), array( - "password" => array( + $parameters = array_merge(['_token' => 'token'], [ + "password" => [ 'password' => 'password', 'confirm' => 'password' - ), + ], "email" => $this->generateEmail(), "accept-tou" => '1', "collections" => null, "provider-id" => 'provider-test', - )); + ]); $provider = $this->getMock('Alchemy\Phrasea\Authentication\Provider\ProviderInterface'); $this->addProvider('provider-test', $provider); @@ -1012,7 +1012,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $user = new \User_Adapter((int) $userId, self::$DI['app']); $ret = self::$DI['app']['EM']->getRepository('\Alchemy\Phrasea\Model\Entities\UsrAuthProvider') - ->findBy(array('usr_id' => $userId, 'provider' => 'provider-test')); + ->findBy(['usr_id' => $userId, 'provider' => 'provider-test']); $this->assertCount(1, $ret); $user->delete(); @@ -1034,15 +1034,15 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); - $emails = array( + $emails = [ 'Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation'=>0, 'Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered'=>0, 'Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered'=>0, - ); + ]; $this->mockNotificationsDeliverer($emails); - $parameters = array_merge(array('_token' => 'token'), $parameters); + $parameters = array_merge(['_token' => 'token'], $parameters); foreach ($parameters as $key => $parameter) { if ('collections' === $key && null === $parameter) { $parameters[$key] = self::$demands; @@ -1082,7 +1082,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testGetLogout() { $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); - self::$DI['client']->request('GET', '/login/logout/', array('app' => 'prod')); + self::$DI['client']->request('GET', '/login/logout/', ['app' => 'prod']); $this->assertFalse(self::$DI['app']['authentication']->isAuthenticated()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); @@ -1107,7 +1107,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation'); $this->logout(self::$DI['app']); - self::$DI['client']->request('GET', '/login/send-mail-confirm/', array('usr_id' => self::$DI['user']->get_id())); + self::$DI['client']->request('GET', '/login/send-mail-confirm/', ['usr_id' => self::$DI['user']->get_id()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -1121,7 +1121,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testSendConfirmMailWrongUser() { $this->logout(self::$DI['app']); - self::$DI['client']->request('GET', '/login/send-mail-confirm/', array('usr_id' => 0)); + self::$DI['client']->request('GET', '/login/send-mail-confirm/', ['usr_id' => 0]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); @@ -1142,13 +1142,13 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); - self::$DI['client']->request('POST', '/login/authenticate/', array( + self::$DI['client']->request('POST', '/login/authenticate/', [ 'login' => $login, 'password' => $password, '_token' => 'token', - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location')); @@ -1175,31 +1175,31 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $phpunit->assertEquals($context, $event->getContext()->getContext()); }); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); - self::$DI['client']->request('POST', '/login/authenticate/', array( + self::$DI['client']->request('POST', '/login/authenticate/', [ 'login' => $login, 'password' => $password, '_token' => 'token', - )); + ]); $this->assertEquals(1, $preEvent); } public function provideEventNames() { - return array( - array(PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate', Context::CONTEXT_NATIVE), - array(PhraseaEvents::POST_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PostAuthenticate', Context::CONTEXT_NATIVE), - ); + return [ + [PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate', Context::CONTEXT_NATIVE], + [PhraseaEvents::POST_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PostAuthenticate', Context::CONTEXT_NATIVE], + ]; } public function provideGuestEventNames() { - return array( - array(PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate', Context::CONTEXT_GUEST), - array(PhraseaEvents::POST_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PostAuthenticate', Context::CONTEXT_GUEST), - ); + return [ + [PhraseaEvents::PRE_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PreAuthenticate', Context::CONTEXT_GUEST], + [PhraseaEvents::POST_AUTHENTICATE, 'Alchemy\Phrasea\Core\Event\PostAuthenticate', Context::CONTEXT_GUEST], + ]; } /** @@ -1214,14 +1214,14 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); - self::$DI['client']->request('POST', '/login/authenticate/', array( + self::$DI['client']->request('POST', '/login/authenticate/', [ 'login' => $login, 'password' => $password, '_token' => 'token', 'redirect' => '/admin' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegExp('/admin/', self::$DI['client']->getResponse()->headers->get('Location')); @@ -1236,11 +1236,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $user = \User_Adapter::getInstance($usr_id, self::$DI['app']); - self::$DI['app']['acl']->get($user)->give_access_to_base(array(self::$DI['collection']->get_base_id())); + self::$DI['app']['acl']->get($user)->give_access_to_base([self::$DI['collection']->get_base_id()]); $this->logout(self::$DI['app']); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); self::$DI['client']->request('POST', '/login/authenticate/guest/'); @@ -1268,11 +1268,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $usr_id = \User_Adapter::get_usr_id_from_login(self::$DI['app'], 'invite'); $user = \User_Adapter::getInstance($usr_id, self::$DI['app']); - self::$DI['app']['acl']->get($user)->give_access_to_base(array(self::$DI['collection']->get_base_id())); + self::$DI['app']['acl']->get($user)->give_access_to_base([self::$DI['collection']->get_base_id()]); $this->logout(self::$DI['app']); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); self::$DI['client']->request('POST', '/login/authenticate/guest/'); @@ -1286,7 +1286,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->logout(self::$DI['app']); - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); self::$DI['client']->request('GET', '/login/authenticate/guest/'); @@ -1305,11 +1305,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testBadAuthenticate() { $this->logout(self::$DI['app']); - self::$DI['client']->request('POST', '/login/authenticate/', array( + self::$DI['client']->request('POST', '/login/authenticate/', [ 'login' => self::$DI['user']->get_login(), 'password' => 'test', '_token' => 'token', - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['app']['session']->getFlashBag()->has('error')); @@ -1322,12 +1322,12 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testBadAuthenticateCheckRedirect() { $this->logout(self::$DI['app']); - self::$DI['client']->request('POST', '/login/authenticate/', array( + self::$DI['client']->request('POST', '/login/authenticate/', [ 'login' => self::$DI['user']->get_login(), 'password' => 'test', '_token' => 'token', 'redirect' => '/prod' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertRegExp('/redirect=prod/', self::$DI['client']->getResponse()->headers->get('Location')); @@ -1342,11 +1342,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->logout(self::$DI['app']); $password = \random::generatePassword(); self::$DI['user']->set_mail_locked(true); - self::$DI['client']->request('POST', '/login/authenticate/', array( + self::$DI['client']->request('POST', '/login/authenticate/', [ 'login' => self::$DI['user']->get_login(), 'password' => $password, '_token' => 'token' - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertEquals('/login/', self::$DI['client']->getResponse()->headers->get('location')); @@ -1367,7 +1367,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->with($this->equalTo('provider-test')) ->will($this->returnValue($provider)); - $parameters = array('key1' => 'value1', 'key2' => 'value2'); + $parameters = ['key1' => 'value1', 'key2' => 'value2']; $response = new Response(); @@ -1395,11 +1395,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function provideAuthProvidersRoutesAndMethods() { - return array( - array('GET', '/login/provider/provider-test/authenticate/'), - array('GET', '/login/provider/provider-test/callback/'), - array('GET', '/login/register-classic/?providerId=provider-test'), - ); + return [ + ['GET', '/login/provider/provider-test/authenticate/'], + ['GET', '/login/provider/provider-test/callback/'], + ['GET', '/login/register-classic/?providerId=provider-test'], + ]; } /** @@ -1517,7 +1517,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertSame(302, self::$DI['client']->getResponse()->getStatusCode()); $ret = self::$DI['app']['EM']->getRepository('\Alchemy\Phrasea\Model\Entities\UsrAuthProvider') - ->findBy(array('usr_id' => self::$DI['user']->get_id(), 'provider' => 'provider-test')); + ->findBy(['usr_id' => self::$DI['user']->get_id(), 'provider' => 'provider-test']); $this->assertCount(1, $ret); @@ -1560,7 +1560,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $provider->expects($this->once()) ->method('getTemplates') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $identity->expects($this->once()) ->method('getEmail') @@ -1580,7 +1580,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->getMock(); self::$DI['app']['authentication.providers.account-creator']->expects($this->once()) ->method('create') - ->with(self::$DI['app'], 42, 'supermail@superprovider.com', array()) + ->with(self::$DI['app'], 42, 'supermail@superprovider.com', []) ->will($this->returnValue($createdUser)); self::$DI['app']['authentication.providers.account-creator']->expects($this->once()) ->method('isEnabled') @@ -1592,7 +1592,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertSame(302, self::$DI['client']->getResponse()->getStatusCode()); $ret = self::$DI['app']['EM']->getRepository('\Alchemy\Phrasea\Model\Entities\UsrAuthProvider') - ->findBy(array('usr_id' => $createdUser->get_id(), 'provider' => 'provider-test')); + ->findBy(['usr_id' => $createdUser->get_id(), 'provider' => 'provider-test']); $this->assertCount(1, $ret); @@ -1693,11 +1693,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testGetRegistrationFields() { - $fields = array( - 'field' => array( + $fields = [ + 'field' => [ 'required' => false - ) - ); + ] + ]; self::$DI['app']['registration.fields'] = $fields; $this->logout(self::$DI['app']); @@ -1741,7 +1741,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract private function addUsrAuthDoctrineEntitySupport($id, $out, $participants = false) { $repo = $this->getMockBuilder('Doctrine\ORM\EntityRepository\UsrAuthProviderRepository') - ->setMethods(array('findWithProviderAndId')) + ->setMethods(['findWithProviderAndId']) ->disableOriginalConstructor() ->getMock(); @@ -1766,7 +1766,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $repo->expects($this->once()) ->method('findNotConfirmedAndNotRemindedParticipantsByExpireDate') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); self::$DI['app']['EM']->expects($this->at(1)) ->method('getRepository') @@ -1790,7 +1790,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $sql = "DELETE FROM demand WHERE usr_id = :usr_id"; $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => self::$DI['user']->get_id())); + $stmt->execute([':usr_id' => self::$DI['user']->get_id()]); $stmt->closeCursor(); } @@ -1806,7 +1806,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract private function disableTOU() { if (null === self::$termsOfUse) { - self::$termsOfUse = array(); + self::$termsOfUse = []; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus(); @@ -1820,7 +1820,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract private function enableTOU() { if (null === self::$termsOfUse) { - self::$termsOfUse = array(); + self::$termsOfUse = []; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php index 5092cdc69a..1905c8a017 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php @@ -173,7 +173,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract $this->insertOneFeed(self::$DI['user'], "test1", true); $this->insertOneFeed(self::$DI['user'], "test2", true); - $all_feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC')); + $all_feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC']); foreach ($all_feeds as $feed) { $this->assertTrue($feed->isPublic()); @@ -190,7 +190,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract $this->insertOneFeed(self::$DI['user'], "test1", true); $this->insertOneFeed(self::$DI['user'], "test2", true); - $all_feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC')); + $all_feeds = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC']); foreach ($all_feeds as $feed) { $this->assertTrue($feed->isPublic()); @@ -361,7 +361,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract public function checkRSSEntryItemsNode(\DOMXPath $xpath, FeedEntry $entry, $count) { $content = $entry->getItems(); - $available_medium = array('image', 'audio', 'video'); + $available_medium = ['image', 'audio', 'video']; array_walk($content, $this->removeBadItems($content, $available_medium)); $media_group = $xpath->query("/rss/channel/item[" . $count . "]/media:group"); $this->assertEquals(sizeof($content), $media_group->length, sizeof($content)." != ".$media_group->length); @@ -391,7 +391,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract public function parseAttributes(\DOMNode $node) { - $current_attributes = array(); + $current_attributes = []; foreach ($node->attributes as $attribute) { $current_attributes[$attribute->name] = $attribute->value; } @@ -460,75 +460,75 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract public function checkOptionnalMediaGroupNode(\DOMNode $node, FeedItem $entry_item) { - $fields = array( - 'title' => array( + $fields = [ + 'title' => [ 'dc_field' => \databox_Field_DCESAbstract::Title, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:title', - 'attributes' => array( + 'attributes' => [ 'type' => 'plain' - ) - ), + ] + ], 'separator' => ' ' - ) - , 'description' => array( + ] + , 'description' => [ 'dc_field' => \databox_Field_DCESAbstract::Description, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:description', - 'attributes' => array() - ), + 'attributes' => [] + ], 'separator' => ' ' - ) - , 'contributor' => array( + ] + , 'contributor' => [ 'dc_field' => \databox_Field_DCESAbstract::Contributor, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:credit', - 'attributes' => array( + 'attributes' => [ 'role' => 'contributor', 'scheme' => 'urn:ebu' - ) - ), + ] + ], 'separator' => ' ' - ) - , 'director' => array( + ] + , 'director' => [ 'dc_field' => \databox_Field_DCESAbstract::Creator, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:credit', - 'attributes' => array( + 'attributes' => [ 'role' => 'director', 'scheme' => 'urn:ebu' - ) - ), + ] + ], 'separator' => ' ' - ) - , 'publisher' => array( + ] + , 'publisher' => [ 'dc_field' => \databox_Field_DCESAbstract::Publisher, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:credit', - 'attributes' => array( + 'attributes' => [ 'role' => 'publisher', 'scheme' => 'urn:ebu' - ) - ), + ] + ], 'separator' => ' ' - ) - , 'rights' => array( + ] + , 'rights' => [ 'dc_field' => \databox_Field_DCESAbstract::Rights, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:copyright', - 'attributes' => array() - ), + 'attributes' => [] + ], 'separator' => ' ' - ) - , 'keywords' => array( + ] + , 'keywords' => [ 'dc_field' => \databox_Field_DCESAbstract::Subject, - 'media_field' => array( + 'media_field' => [ 'name' => 'media:keywords', - 'attributes' => array() - ), + 'attributes' => [] + ], 'separator' => ', ' - ) - ); + ] + ]; foreach ($fields as $key_field => $field) { @@ -674,7 +674,7 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract $content = $entry->getItems()->toArray(); - $available_medium = array('image', 'audio', 'video'); + $available_medium = ['image', 'audio', 'video']; array_walk($content, $this->removeBadItems($content, $available_medium)); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php index 19815e6361..95283944aa 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/RootTest.php @@ -15,7 +15,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $cookieJar = new CookieJar(); $cookieJar->set(new BrowserCookie('locale', 'de_DE')); - $client = new Client(self::$DI['app'], array(), null, $cookieJar); + $client = new Client(self::$DI['app'], [], null, $cookieJar); $crawler = $client->request('GET', '/language/fr_CA/'); $response = $client->getResponse(); @@ -145,7 +145,7 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $cookieJar = new CookieJar(); $cookieJar->set(new BrowserCookie('persistent', $token)); - $client = new Client($app, array(), null, $cookieJar); + $client = new Client($app, [], null, $cookieJar); $client->request('GET', '/unit-test-route'); $this->assertTrue($boolean); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php index 2cb7477db4..abc276b1f1 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php @@ -24,9 +24,9 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testUpdSessionChangeUser() { - $this->XMLHTTPRequest('POST', '/session/update/', array( + $this->XMLHTTPRequest('POST', '/session/update/', [ 'usr' => self::$DI['user_alt1']->get_id() - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $datas = json_decode(self::$DI['client']->getResponse()->getContent()); $this->checkSessionReturn($datas); @@ -40,10 +40,10 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->authenticate(self::$DI['app']); - $this->XMLHTTPRequest('POST', '/session/update/', array( + $this->XMLHTTPRequest('POST', '/session/update/', [ 'usr' => self::$DI['user']->get_id(), 'module' => 1 - )); + ]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); $datas = json_decode(self::$DI['client']->getResponse()->getContent()); $this->checkSessionReturn($datas); @@ -57,9 +57,9 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->authenticate(self::$DI['app']); - $this->XMLHTTPRequest('POST', '/session/update/', array( + $this->XMLHTTPRequest('POST', '/session/update/', [ 'usr' => self::$DI['user']->get_id() - )); + ]); $datas = json_decode(self::$DI['client']->getResponse()->getContent()); $datas = json_decode(self::$DI['client']->getResponse()->getContent()); @@ -110,11 +110,11 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue(null)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $this->XMLHTTPRequest('POST', '/session/delete/1'); $this->assertTrue(self::$DI['client']->getResponse()->isOK()); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $em = null; } @@ -138,12 +138,12 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue($session)); self::$DI['app']['EM'] = $em; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); self::$DI['client']->request('POST', '/session/delete/1'); $this->assertFalse(self::$DI['client']->getResponse()->isOK()); $this->assertEquals(self::$DI['client']->getResponse()->getStatusCode(), 403); self::$DI['app']['EM'] = $originalEm; - self::$DI['client'] = new Client(self::$DI['app'], array()); + self::$DI['client'] = new Client(self::$DI['app'], []); $em = null; } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php b/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php index afd20b5bdf..79cb1d5bb5 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/SetupTest.php @@ -111,7 +111,7 @@ class SetupTest extends \PhraseanetWebTestCaseAbstract ->getMock(); $acl->expects($this->once()) ->method('get_granted_sbas') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider') ->disableOriginalConstructor() @@ -139,7 +139,7 @@ class SetupTest extends \PhraseanetWebTestCaseAbstract $dataDir = sys_get_temp_dir() . '/datainstall/'; - $params = array( + $params = [ 'email' => 'user@example.org', 'password' => 'prètty%%password', 'binary_xpdf' => '/path/to/xpdf', @@ -162,9 +162,9 @@ class SetupTest extends \PhraseanetWebTestCaseAbstract 'ab_name' => $abName, 'db_name' => $dbName, 'db_template' => 'en-simple', - 'create_task' => array(), + 'create_task' => [], 'binary_phraseanet_indexer' => '/path/to/phraseanet_indexer', - ); + ]; $crawler = $client->request('POST', '/setup/installer/install/', $params); $response = $client->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php index 8d35bf6fe8..967a0f86e7 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php @@ -42,9 +42,9 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testSetNotificationsReaded() { - $this->XMLHTTPRequest('POST', '/user/notifications/read/', array( + $this->XMLHTTPRequest('POST', '/user/notifications/read/', [ 'notifications' => '' - )); + ]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); @@ -61,7 +61,7 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testRequireAuthentication() { self::$DI['app']['authentication']->setUser($this->getMockBuilder('\User_Adapter') - ->setMethods(array('is_guest')) + ->setMethods(['is_guest']) ->disableOriginalConstructor() ->getMock()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php b/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php index 4147baa21c..9edd92e723 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php @@ -12,7 +12,7 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function testSaveUserPref() { self::$DI['app']['authentication']->setUser($this->getMockBuilder('\User_Adapter') - ->setMethods(array('setPrefs')) + ->setMethods(['setPrefs']) ->disableOriginalConstructor() ->getMock()); @@ -21,7 +21,7 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->with($this->equalTo('prop_test'), $this->equalTo('val_test')) ->will($this->returnValue(true)); - $this->XMLHTTPRequest('POST', '/user/preferences/', array('prop' => 'prop_test', 'value' => 'val_test')); + $this->XMLHTTPRequest('POST', '/user/preferences/', ['prop' => 'prop_test', 'value' => 'val_test']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); @@ -36,7 +36,7 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testSaveUserPrefNoXMLHTTPRequests() { - self::$DI['client']->request('POST', '/user/preferences/', array('prop' => 'prop_test', 'value' => 'val_test')); + self::$DI['client']->request('POST', '/user/preferences/', ['prop' => 'prop_test', 'value' => 'val_test']); $this->assertBadResponse(self::$DI['client']->getResponse()); } @@ -46,7 +46,7 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testSaveTempPrefNoXMLHTTPRequests() { - self::$DI['client']->request('POST', '/user/preferences/temporary/', array('prop' => 'prop_test', 'value' => 'val_test')); + self::$DI['client']->request('POST', '/user/preferences/temporary/', ['prop' => 'prop_test', 'value' => 'val_test']); $this->assertBadResponse(self::$DI['client']->getResponse()); } @@ -56,7 +56,7 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testSaveTemporaryPref() { - $this->XMLHTTPRequest('POST', "/user/preferences/temporary/", array('prop' => 'prop_test', 'value' => 'val_test')); + $this->XMLHTTPRequest('POST', "/user/preferences/temporary/", ['prop' => 'prop_test', 'value' => 'val_test']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Utils/ConnectionTestTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Utils/ConnectionTestTest.php index b63b9b05ad..e1ae15b9ae 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Utils/ConnectionTestTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Utils/ConnectionTestTest.php @@ -11,13 +11,13 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract { $connexion = self::$DI['app']['configuration']['main']['database']; - $params = array( + $params = [ "hostname" => $connexion['host'], "port" => $connexion['port'], "user" => $connexion['user'], "password" => $connexion['password'], "dbname" => $connexion['dbname'], - ); + ]; self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); $response = self::$DI['client']->getResponse(); @@ -28,13 +28,13 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract { $connexion = self::$DI['app']['configuration']['main']['database']; - $params = array( + $params = [ "hostname" => $connexion['host'], "port" => $connexion['port'], "user" => $connexion['user'], "password" => "fakepassword", "dbname" => $connexion['dbname'], - ); + ]; self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); $response = self::$DI['client']->getResponse(); @@ -54,13 +54,13 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract { $connexion = self::$DI['app']['configuration']['main']['database']; - $params = array( + $params = [ "hostname" => $connexion['host'], "port" => $connexion['port'], "user" => $connexion['user'], "password" => $connexion['password'], "dbname" => "fake-DTABASE-name" - ); + ]; self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Utils/PathFileTestTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Utils/PathFileTestTest.php index 80bb5e4262..3642b3ff24 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Utils/PathFileTestTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Utils/PathFileTestTest.php @@ -10,7 +10,7 @@ class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract public function testRoutePath() { $file = new \SplFileObject(__DIR__ . '/../../../../../files/cestlafete.jpg'); - self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", array('path' => $file->getPathname())); + self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", ['path' => $file->getPathname()]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); @@ -26,7 +26,7 @@ class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract public function testRouteUrl() { - self::$DI['client']->request("GET", "/admin/tests/pathurl/url/", array('url' => "www.google.com")); + self::$DI['client']->request("GET", "/admin/tests/pathurl/url/", ['url' => "www.google.com"]); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/CLISDriversServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/CLISDriversServiceProviderTest.php index 7435cf1f20..bb6eed60f5 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/CLISDriversServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/CLISDriversServiceProviderTest.php @@ -11,33 +11,33 @@ class CLISDriversServiceProviderTest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider', 'executable-finder', 'Symfony\Component\Process\ExecutableFinder' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider', 'driver.bower', 'Alchemy\Phrasea\Command\Developer\Utils\BowerDriver' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider', 'driver.composer', 'Alchemy\Phrasea\Command\Developer\Utils\ComposerDriver' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider', 'driver.uglifyjs', 'Alchemy\Phrasea\Command\Developer\Utils\UglifyJsDriver' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider', 'driver.recess', 'Alchemy\Phrasea\Command\Developer\Utils\RecessDriver' - ), - ); + ], + ]; } public function testComposerTimeout() diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/ComposerSetupServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/ComposerSetupServiceProviderTest.php index c160e92a92..ae7294439f 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/ComposerSetupServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/ComposerSetupServiceProviderTest.php @@ -9,12 +9,12 @@ class ComposerSetupServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\CLIProvider\ComposerSetupServiceProvider', 'composer-setup', 'Alchemy\Phrasea\Utilities\ComposerSetup' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/LessBuilderServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/LessBuilderServiceProviderTest.php index a8f54e87c0..e9a82da51c 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/LessBuilderServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/LessBuilderServiceProviderTest.php @@ -9,17 +9,17 @@ class LessBuilderServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider', 'phraseanet.less-compiler', '\Alchemy\Phrasea\Utilities\Less\Compiler' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider', 'phraseanet.less-builder', '\Alchemy\Phrasea\Utilities\Less\Builder' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php index 7159ade2af..32065bfa80 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php @@ -12,58 +12,58 @@ class PluginServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.json-validator', 'JsonSchema\Validator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.plugins-validator', 'Alchemy\Phrasea\Plugin\Schema\PluginValidator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.manifest-validator', 'Alchemy\Phrasea\Plugin\Schema\ManifestValidator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.import-strategy', 'Alchemy\Phrasea\Plugin\Importer\ImportStrategy' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.autoloader-generator', 'Alchemy\Phrasea\Plugin\Management\AutoloaderGenerator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.composer-installer', 'Alchemy\Phrasea\Plugin\Management\ComposerInstaller' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.explorer', 'Alchemy\Phrasea\Plugin\Management\PluginsExplorer' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.importer', 'Alchemy\Phrasea\Plugin\Importer\Importer' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.importer.folder-importer', 'Alchemy\Phrasea\Plugin\Importer\FolderImporter' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider', 'plugins.assets-manager', 'Alchemy\Phrasea\Plugin\Management\AssetsManager' - ) - ); + ] + ]; } public function testSchemaIsDefined() @@ -94,7 +94,7 @@ class PluginServiceProvidertest extends ServiceProviderTestCase } $app = self::$DI['cli']; - $app['configuration'] = array('binaries' => array('php_binary' => null)); + $app['configuration'] = ['binaries' => ['php_binary' => null]]; $app->register(new PluginServiceProvider()); $this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']); } @@ -102,7 +102,7 @@ class PluginServiceProvidertest extends ServiceProviderTestCase public function testInstallerCanDetectPhpConf() { $app = self::$DI['cli']; - $app['configuration'] = array('binaries' => array('php_binary' => null)); + $app['configuration'] = ['binaries' => ['php_binary' => null]]; $app->register(new PluginServiceProvider()); $this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']); } diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/SignalHandlerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/SignalHandlerServiceProviderTest.php index d4e667321d..ffc589d4ab 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/SignalHandlerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/SignalHandlerServiceProviderTest.php @@ -6,12 +6,12 @@ class SignalHandlerServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider', 'signal-handler', 'Neutron\SignalHandler\SignalHandler' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/TaskManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/TaskManagerServiceProviderTest.php index 7edfafb69c..aea1ce8aec 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/TaskManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/TaskManagerServiceProviderTest.php @@ -9,22 +9,22 @@ class TaskManagerServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider', 'task-manager.logger', 'Monolog\Logger' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider', 'task-manager', 'Alchemy\TaskManager\TaskManager' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider', 'task-manager.task-list', 'Alchemy\Phrasea\TaskManager\TaskList' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php index 59ba99a19c..4d3a2eb29a 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php @@ -28,27 +28,27 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $class = new \stdClass(); $class->key = 'value'; - $data = array( + $data = [ 'key' => $class, 'key2' => 'boum', - ); + ]; $compiled = $compiler->compile($data); $this->assertInternalType("string", $compiled); $this->assertSame(0, strpos($compiled, "'.$compiled); - $this->assertSame(array('key' => array('key' => 'value'), 'key2' => 'boum'), $result); + $this->assertSame(['key' => ['key' => 'value'], 'key2' => 'boum'], $result); } public function provideDataToCompile() { - return array( - array(array()), - array(array('key' => array('value1', 'value2', 'booleantrue' => true, 'booleanfalse' => false), array('gizmo'))), - array(array(array(array()))), - array(array(null, false, array(), true)), - array(array('key' => 'value', "associativeint" => 12345, 34567)), - ); + return [ + [[]], + [['key' => ['value1', 'value2', 'booleantrue' => true, 'booleanfalse' => false], ['gizmo']]], + [[[[]]]], + [[null, false, [], true]], + [['key' => 'value', "associativeint" => 12345, 34567]], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php index 1959f427ba..f32bc4d46e 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php @@ -224,10 +224,10 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase $yaml = new Yaml(); $conf = new Configuration($yaml, $compiler, $configFile, $compiled, false); - $conf->setConfig(array('main' => 'boule')); + $conf->setConfig(['main' => 'boule']); $updated = $yaml->parse(file_get_contents($configFile)); - $this->assertEquals(array('main' => 'boule'), $conf->getConfig()); + $this->assertEquals(['main' => 'boule'], $conf->getConfig()); } public function testCompilNever() @@ -279,7 +279,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase ->getMock(); $compiler->expects($this->once()) ->method('compile') - ->with(array('main' => 'tiptop')) + ->with(['main' => 'tiptop']) ->will($this->returnValue(' "tiptop");')); $yaml = $this->getMockBuilder('Symfony\Component\Yaml\Yaml') @@ -287,12 +287,12 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase ->getMock(); $yaml::staticExpects($this->once()) ->method('parse') - ->will($this->returnValue(array('main' => 'tiptop'))); + ->will($this->returnValue(['main' => 'tiptop'])); $conf = new Configuration($yaml, $compiler, $configFile, $compiled, true); - $this->assertSame(array('main' => 'tiptop'), $conf->getConfig()); - $this->assertSame(array('main' => 'tiptop'), $conf->getConfig()); - $this->assertSame(array('main' => 'tiptop'), $conf->getConfig()); + $this->assertSame(['main' => 'tiptop'], $conf->getConfig()); + $this->assertSame(['main' => 'tiptop'], $conf->getConfig()); + $this->assertSame(['main' => 'tiptop'], $conf->getConfig()); $this->assertSame('tiptop', $conf['main']); $this->assertSame('tiptop', $conf['main']); $this->assertSame('tiptop', $conf['main']); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriberTest.php index 667ee18000..13fc2b8532 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriberTest.php @@ -34,15 +34,15 @@ class ApiExceptionHandlerSubscriberTest extends \PHPUnit_Framework_TestCase public function provideExceptionsAndCode() { - return array( - array(new \API_V1_exception_methodnotallowed(), 405), - array(new MethodNotAllowedHttpException(array('PUT', 'HEAD')), 405), - array(new \API_V1_exception_badrequest(), 400), - array(new \API_V1_exception_forbidden(), 403), - array(new \API_V1_exception_unauthorized(), 401), - array(new \API_V1_exception_internalservererror(), 500), - array(new NotFoundHttpException(), 404), - array(new \Exception(), 500), - ); + return [ + [new \API_V1_exception_methodnotallowed(), 405], + [new MethodNotAllowedHttpException(['PUT', 'HEAD']), 405], + [new \API_V1_exception_badrequest(), 400], + [new \API_V1_exception_forbidden(), 403], + [new \API_V1_exception_unauthorized(), 401], + [new \API_V1_exception_internalservererror(), 500], + [new NotFoundHttpException(), 404], + [new \Exception(), 500], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php index 87da546fa8..7e20d54766 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriberTest.php @@ -55,10 +55,10 @@ class ApiOauth2ErrorsSubscriberTest extends \PHPUnit_Framework_TestCase public function provideExceptionsAndCode() { - return array( - array(new HttpException(512, null, null, array('content-type' => 'application/json')), 512, 'application/json'), - array(new HttpException(512, null, null), 512, 'text/html; charset=UTF-8'), - array(new \Exception(), 500, 'text/html; charset=UTF-8'), - ); + return [ + [new HttpException(512, null, null, ['content-type' => 'application/json']), 512, 'application/json'], + [new HttpException(512, null, null), 512, 'text/html; charset=UTF-8'], + [new \Exception(), 500, 'text/html; charset=UTF-8'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriberTest.php index fd3446ffe9..d4f14ac6fe 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriberTest.php @@ -44,23 +44,23 @@ class CookiesDisablerSubscriberTest extends \PHPUnit_Framework_TestCase $cookieJar = new CookieJar(); $cookieJar->set(new BrowserCookie('test-cookie', 'cookievalue')); - return new Client($app, array(), null, $cookieJar); + return new Client($app, [], null, $cookieJar); } public function provideVariousRoutes() { - return array( - array(false, '/prod'), - array(false, '/admin'), - array(false, '/api'), - array(false, '/api/oauthv2'), - array(false, '/'), - array(false, '/datafiles/'), - array(true, '/permalink'), - array(true, '/permalink/v1'), - array(true, '/api/v1'), - array(true, '/api/v1/'), - array(true, '/api/v1/records'), - ); + return [ + [false, '/prod'], + [false, '/admin'], + [false, '/api'], + [false, '/api/oauthv2'], + [false, '/'], + [false, '/datafiles/'], + [true, '/permalink'], + [true, '/permalink/v1'], + [true, '/api/v1'], + [true, '/api/v1/'], + [true, '/api/v1/records'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php index f2edf8ddcb..127372aa1f 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php @@ -30,7 +30,7 @@ class DebuggerSubscriberTest extends \PHPUnit_Framework_TestCase unlink($app['phraseanet.configuration.config-compiled-path']); } - $app['configuration']['debugger'] = array('allowed-ips' => $authorized); + $app['configuration']['debugger'] = ['allowed-ips' => $authorized]; $app['dispatcher']->addSubscriber(new DebuggerSubscriber($app)); $app->get('/', function () { return 'success'; @@ -41,19 +41,19 @@ class DebuggerSubscriberTest extends \PHPUnit_Framework_TestCase $this->setExpectedException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); } - $app->handle(new Request(array(), array(), array(), array(), array(), array('REMOTE_ADDR' => $incomingIp))); + $app->handle(new Request([], [], [], [], [], ['REMOTE_ADDR' => $incomingIp])); } public function provideIpsAndEnvironments() { - return array( - array(false, Application::ENV_PROD, '127.0.0.1', array()), - array(false, Application::ENV_PROD, '192.168.0.1', array()), - array(false, Application::ENV_DEV, '127.0.0.1', array()), - array(true, Application::ENV_DEV, '192.168.0.1', array()), - array(false, Application::ENV_DEV, '192.168.0.1', array('192.168.0.1')), - array(false, Application::ENV_TEST, '127.0.0.1', array()), - array(false, Application::ENV_TEST, '192.168.0.1', array()), - ); + return [ + [false, Application::ENV_PROD, '127.0.0.1', []], + [false, Application::ENV_PROD, '192.168.0.1', []], + [false, Application::ENV_DEV, '127.0.0.1', []], + [true, Application::ENV_DEV, '192.168.0.1', []], + [false, Application::ENV_DEV, '192.168.0.1', ['192.168.0.1']], + [false, Application::ENV_TEST, '127.0.0.1', []], + [false, Application::ENV_TEST, '192.168.0.1', []], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/FirewallSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/FirewallSubscriberTest.php index 87bb9e4401..abbf371a29 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/FirewallSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/FirewallSubscriberTest.php @@ -15,7 +15,7 @@ class FirewallSubscriberTest extends \PHPUnit_Framework_TestCase unset($app['exception_handler']); $app['dispatcher']->addSubscriber(new FirewallSubscriber()); $app->get('/', function () { - throw new HttpException(500, null, null, array('X-Phraseanet-Redirect' => '/hello-world')); + throw new HttpException(500, null, null, ['X-Phraseanet-Redirect' => '/hello-world']); }); $client = new Client($app); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/JsonRequestSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/JsonRequestSubscriberTest.php index 1bf8332ecb..560676882d 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/JsonRequestSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/JsonRequestSubscriberTest.php @@ -21,11 +21,11 @@ class JsonRequestSubscriberTest extends \PHPUnit_Framework_TestCase }); $client = new Client($app); - $headers = $isJson ? array('HTTP_ACCEPT' => 'application/json') : array(); + $headers = $isJson ? ['HTTP_ACCEPT' => 'application/json'] : []; if ($exceptionExpected) { $this->setExpectedException('Exception'); } - $client->request('GET', $route, array(), array(), $headers); + $client->request('GET', $route, [], [], $headers); if (!$exceptionExpected) { $this->assertEquals(200, $client->getResponse()->getStatusCode()); $this->assertEquals('application/json', $client->getResponse()->headers->get('content-type')); @@ -38,16 +38,16 @@ class JsonRequestSubscriberTest extends \PHPUnit_Framework_TestCase public function provideRouteParameters() { - return array( - array('/admin/status', true, true), - array('/admin/collection/24', false, true), - array('/admin/collection/24', true, false), - array('/admin/databox/42', false, true), - array('/admin/databox/42', true, false), - array('/report', false, true), - array('/report', true, false), - array('/prod', false, true), - array('/prod', true, false), - ); + return [ + ['/admin/status', true, true], + ['/admin/collection/24', false, true], + ['/admin/collection/24', true, false], + ['/admin/databox/42', false, true], + ['/admin/databox/42', true, false], + ['/report', false, true], + ['/report', true, false], + ['/prod', false, true], + ['/prod', true, false], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/MaintenanceSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/MaintenanceSubscriberTest.php index 107a49127a..9039d64a56 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/MaintenanceSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/MaintenanceSubscriberTest.php @@ -55,7 +55,7 @@ class MaintenanceSubscriberTest extends \PHPUnit_Framework_TestCase $this->fail('An exception should have been raised'); } catch (HttpException $e) { $this->assertEquals(503, $e->getStatusCode()); - $this->assertEquals(array('Retry-After' => 3600), $e->getHeaders()); + $this->assertEquals(['Retry-After' => 3600], $e->getHeaders()); } } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php index cb446595da..dc59def029 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php @@ -19,7 +19,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $this->mockRegistryAndReturnLocale($app, 'fr_FR'); $client = new Client($app); - $client->request('GET', '/', array(), array(), array('HTTP_accept-language' => '')); + $client->request('GET', '/', [], [], ['HTTP_accept-language' => '']); $this->assertEquals('fr_FR', $client->getResponse()->getContent()); } @@ -31,8 +31,8 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $cookieJar = new CookieJar(); $cookieJar->set(new BrowserCookie('locale', 'de_DE')); - $client = new Client($app, array(), null, $cookieJar); - $client->request('GET', '/', array(), array(), array('HTTP_accept-language' => '')); + $client = new Client($app, [], null, $cookieJar); + $client->request('GET', '/', [], [], ['HTTP_accept-language' => '']); $this->assertEquals('de_DE', $client->getResponse()->getContent()); } @@ -42,7 +42,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $app = $this->getAppThatReturnLocale(); $client = new Client($app); - $client->request('GET', '/', array(), array(), array('HTTP_ACCEPT_LANGUAGE' => 'fr_FR,fr;q=0.9')); + $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr_FR,fr;q=0.9']); $this->assertEquals('fr_FR', $client->getResponse()->getContent()); } @@ -52,7 +52,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $app = $this->getAppThatReturnLocale(); $client = new Client($app); - $client->request('GET', '/', array(), array(), array('HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.9')); + $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.9']); $this->assertEquals('fr_FR', $client->getResponse()->getContent()); } @@ -60,7 +60,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract public function testCookieIsSet() { $client = new Client(self::$DI['app']); - $client->request('GET', '/', array(), array(), array('HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.9')); + $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.9']); $settedCookie = null; foreach ($client->getResponse()->headers->getCookies() as $cookie) { @@ -83,7 +83,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $this->mockRegistryAndReturnLocale($app, 'en_USA'); $client = $this->getClientWithCookie($app, null); - $client->request('GET', '/', array(), array(), array('HTTP_accept-language' => '')); + $client->request('GET', '/', [], [], ['HTTP_accept-language' => '']); $this->assertEquals('en_USA', $client->getResponse()->getContent()); } @@ -97,7 +97,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $this->mockRegistryAndReturnLocale($app, 'en_USA'); $client = $this->getClientWithCookie($app, 'de_PL'); - $client->request('GET', '/', array(), array(), array('HTTP_accept-language' => '')); + $client->request('GET', '/', [], [], ['HTTP_accept-language' => '']); $this->assertEquals('en_USA', $client->getResponse()->getContent()); } @@ -135,6 +135,6 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract $cookieJar->set(new BrowserCookie('locale', $locale)); } - return new Client($app, array(), null, $cookieJar); + return new Client($app, [], null, $cookieJar); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php index 45d8f06f4b..1f424098d2 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php @@ -25,7 +25,7 @@ class TrustedProxySubscriberTest extends \PHPUnit_Framework_TestCase $configuration->expects($this->once()) ->method('offsetGet') ->with('trusted-proxies') - ->will($this->returnValue(array('8.8.8.8', '127.0.0.1'))); + ->will($this->returnValue(['8.8.8.8', '127.0.0.1'])); $configuration->expects($this->once()) ->method('offsetExists') @@ -42,7 +42,7 @@ class TrustedProxySubscriberTest extends \PHPUnit_Framework_TestCase $client->request('GET', '/'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(array('8.8.8.8', '127.0.0.1'), Request::getTrustedProxies()); + $this->assertEquals(['8.8.8.8', '127.0.0.1'], Request::getTrustedProxies()); } public function testAllowedIpsAreSetWhenEmpty() @@ -66,6 +66,6 @@ class TrustedProxySubscriberTest extends \PHPUnit_Framework_TestCase $client->request('GET', '/'); $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertEquals(array(), Request::getTrustedProxies()); + $this->assertEquals([], Request::getTrustedProxies()); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Middleware/BasketMiddlewareProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Middleware/BasketMiddlewareProviderTest.php index c5139fdb2a..12ef29e14c 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Middleware/BasketMiddlewareProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Middleware/BasketMiddlewareProviderTest.php @@ -9,20 +9,20 @@ class BasketMiddlewareProviderTest extends MiddlewareProviderTestCase { public function provideDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Middleware\BasketMiddlewareProvider', 'middleware.basket.converter' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Middleware\BasketMiddlewareProvider', 'middleware.basket.user-access' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Middleware\BasketMiddlewareProvider', 'middleware.basket.user-is-owner' - ), - ); + ], + ]; } public function testConverterWithNoParameter() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ACLServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ACLServiceProviderTest.php index 648ff2235a..8a5b90b476 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ACLServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ACLServiceProviderTest.php @@ -6,12 +6,12 @@ class ACLServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\ACLServiceProvider', 'acl.basket', 'Alchemy\\Phrasea\\ACL\\BasketACL', - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php index 6264908124..8c67726077 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php @@ -15,68 +15,68 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication', 'Alchemy\\Phrasea\\Authentication\\Authenticator', - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.token-validator', 'Alchemy\Phrasea\Authentication\Token\TokenValidator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.persistent-manager', 'Alchemy\Phrasea\Authentication\PersistentCookie\Manager' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.suggestion-finder', 'Alchemy\Phrasea\Authentication\SuggestionFinder' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.providers.factory', 'Alchemy\Phrasea\Authentication\Provider\Factory' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.providers', 'Alchemy\Phrasea\Authentication\ProvidersCollection' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.manager', 'Alchemy\Phrasea\Authentication\Manager' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'auth.password-encoder', 'Alchemy\Phrasea\Authentication\Phrasea\PasswordEncoder' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'auth.old-password-encoder', 'Alchemy\Phrasea\Authentication\Phrasea\OldPasswordEncoder' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'auth.native.failure-manager', 'Alchemy\Phrasea\Authentication\Phrasea\FailureManager' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'auth.native', 'Alchemy\Phrasea\Authentication\Phrasea\PasswordAuthenticationInterface' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider', 'authentication.providers.account-creator', 'Alchemy\Phrasea\Authentication\AccountCreator' - ), - ); + ], + ]; } public function testFailureManagerAttemptsConfiguration() @@ -108,9 +108,9 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase $app->register(new ConfigurationServiceProvider()); $conf = $app['configuration']->getConfig(); - $conf['authentication']['auto-create'] = array( - 'templates' => array(), - ); + $conf['authentication']['auto-create'] = [ + 'templates' => [], + ]; $app['configuration']->setConfig($conf); $app['authentication.providers.account-creator']; @@ -139,9 +139,9 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase $app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox']; $conf = $app['configuration']->getConfig(); - $conf['authentication']['captcha'] = array( + $conf['authentication']['captcha'] = [ 'enabled' => true, - ); + ]; $app['configuration']->setConfig($conf); $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') @@ -177,9 +177,9 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase $app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox']; $conf = $app['configuration']->getConfig(); - $conf['authentication']['captcha'] = array( + $conf['authentication']['captcha'] = [ 'enabled' => false, - ); + ]; $app['configuration']->setConfig($conf); $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') @@ -203,15 +203,15 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase $template2->set_template(self::$DI['user']); $conf = $app['configuration']->getConfig(); - $conf['authentication']['auto-create'] = array( - 'templates' => array( + $conf['authentication']['auto-create'] = [ + 'templates' => [ $template1->get_id(), $template2->get_login() - ) - ); + ] + ]; $app['configuration']->setConfig($conf); - $this->assertEquals(array($template1, $template2), $app['authentication.providers.account-creator']->getTemplates()); + $this->assertEquals([$template1, $template2], $app['authentication.providers.account-creator']->getTemplates()); $template1->delete(); $template2->delete(); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php index 327ddf1240..0db7ea4358 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php @@ -14,25 +14,25 @@ class BorderManagerServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider', 'border-manager', 'Alchemy\\Phrasea\\Border\\Manager' - ), - ); + ], + ]; } public function testItLoadsWithoutXPDF() { $app = new Application(); - $app->register(new XPDFServiceProvider(), array( - 'xpdf.configuration' => array( + $app->register(new XPDFServiceProvider(), [ + 'xpdf.configuration' => [ 'pdftotext.binaries' => '/path/to/nowhere', - ) - )); + ] + ]); $app->register(new BorderManagerServiceProvider()); - $app['configuration'] = array('border-manager' => array('enabled' => false)); + $app['configuration'] = ['border-manager' => ['enabled' => false]]; $this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']); $this->assertNull($app['border-manager']->getPdfToText()); @@ -48,13 +48,13 @@ class BorderManagerServiceProvidertest extends ServiceProviderTestCase } $app = new Application(); - $app->register(new XPDFServiceProvider(), array( - 'xpdf.configuration' => array( + $app->register(new XPDFServiceProvider(), [ + 'xpdf.configuration' => [ 'pdftotext.binaries' => $php, - ) - )); + ] + ]); $app->register(new BorderManagerServiceProvider()); - $app['configuration'] = array('border-manager' => array('enabled' => false)); + $app['configuration'] = ['border-manager' => ['enabled' => false]]; $this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']); $this->assertInstanceOf('XPDF\PdfToText', $app['border-manager']->getPdfToText()); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php index 9636d5f32e..1494df0744 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php @@ -9,8 +9,8 @@ class BrowserServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\BrowserServiceProvider', 'browser', 'Browser'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\BrowserServiceProvider', 'browser', 'Browser'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheConnectionServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheConnectionServiceProviderTest.php index 045616abac..99dee02b17 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheConnectionServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheConnectionServiceProviderTest.php @@ -6,12 +6,12 @@ class CacheConnectionServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\CacheConnectionServiceProvider', 'cache.connection-factory', 'Alchemy\\Phrasea\\Cache\\ConnectionFactory' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php index ebc16fcc8d..39a4ac45c8 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php @@ -9,22 +9,22 @@ class CacheServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\CacheServiceProvider', 'cache', 'Doctrine\\Common\\Cache\\Cache' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\CacheServiceProvider', 'opcode-cache', 'Doctrine\\Common\\Cache\\Cache' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\CacheServiceProvider', 'phraseanet.cache-service', 'Alchemy\\Phrasea\\Cache\\Manager' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php index 1ae75f73e3..26493bcd1a 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php @@ -14,18 +14,18 @@ class ConfigurationServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider', 'configuration', 'Alchemy\\Phrasea\\Core\\Configuration\\Configuration' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider', 'phraseanet.configuration', 'Alchemy\\Phrasea\\Core\\Configuration\\Configuration' - ), - ); + ], + ]; } public function testRequestTrustedProxiesAreSetOnRequest() @@ -35,7 +35,7 @@ class ConfigurationServiceProvidertest extends ServiceProviderTestCase $app->register(new ConfigurationServiceProvider()); $app['phraseanet.configuration.config-path'] = __DIR__ . '/fixtures/config-proxies.yml'; $app['phraseanet.configuration.config-compiled-path'] = __DIR__ . '/fixtures/config-proxies.php'; - $this->assertSame(array(), Request::getTrustedProxies()); + $this->assertSame([], Request::getTrustedProxies()); $app->boot(); $app->get('/', function () { @@ -45,7 +45,7 @@ class ConfigurationServiceProvidertest extends ServiceProviderTestCase $client = new Client($app); $client->request('GET', '/'); - $this->assertSame(array('127.0.0.1', '66.6.66.6'), Request::getTrustedProxies()); + $this->assertSame(['127.0.0.1', '66.6.66.6'], Request::getTrustedProxies()); unlink($app['phraseanet.configuration.config-compiled-path']); } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php index 7fce108fe4..6dbe9041d4 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php @@ -9,8 +9,8 @@ class ConfigurationTesterServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider', 'phraseanet.configuration-tester', 'Alchemy\\Phrasea\\Setup\\ConfigurationTester'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider', 'phraseanet.configuration-tester', 'Alchemy\\Phrasea\\Setup\\ConfigurationTester'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConvertersServiceProvider.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConvertersServiceProvider.php index 6c4842d1e9..f6e46e6832 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConvertersServiceProvider.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConvertersServiceProvider.php @@ -6,17 +6,17 @@ class ConvertersServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\ConvertersServiceProvider', 'converter.task', 'Alchemy\Phrasea\Controller\Converter\TaskConverter' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\ConvertersServiceProvider', 'converter.basket', 'Alchemy\Phrasea\Controller\Converter\BasketConverter' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/FeedServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/FeedServiceProviderTest.php index 6d65359bb6..04263a5a06 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/FeedServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/FeedServiceProviderTest.php @@ -9,17 +9,17 @@ class FeedServiceProviderTest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\FeedServiceProvider', 'feed.user-link-generator', 'Alchemy\Phrasea\Feed\Link\FeedLinkGenerator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\FeedServiceProvider', 'feed.aggregate-link-generator', 'Alchemy\Phrasea\Feed\Link\AggregateLinkGenerator' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php index 749f7288d8..caebbcd83b 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/FileServeServiceProviderTest.php @@ -12,18 +12,18 @@ class FileServeServiceProviderTest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\FileServeServiceProvider', 'phraseanet.file-serve', 'Alchemy\Phrasea\Http\ServeFileResponseFactory' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\FileServeServiceProvider', 'phraseanet.xsendfile-factory', 'Alchemy\Phrasea\Http\XSendFile\XSendFileFactory' - ), - ); + ], + ]; } public function testMapping() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/JMSSerializerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/JMSSerializerServiceProviderTest.php index 737fb7c922..3668482943 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/JMSSerializerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/JMSSerializerServiceProviderTest.php @@ -9,8 +9,8 @@ class JMSServiceProviderServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\JMSSerializerServiceProvider', 'serializer', 'JMS\Serializer\Serializer'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\JMSSerializerServiceProvider', 'serializer', 'JMS\Serializer\Serializer'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php index 1ca6874d7b..f0c3bc8b61 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php @@ -33,7 +33,7 @@ class LocaleServiceProvidertest extends \PhraseanetPHPUnitAbstract $app['configuration']->expects($this->any()) ->method('offsetGet') ->with('main') - ->will($this->returnValue(array('languages' => array('fr_FR', 'en_US', 'de')))); + ->will($this->returnValue(['languages' => ['fr_FR', 'en_US', 'de']])); $original = Application::getAvailableLanguages(); unset($original['en_GB']); @@ -57,7 +57,7 @@ class LocaleServiceProvidertest extends \PhraseanetPHPUnitAbstract $app['configuration']->expects($this->any()) ->method('offsetGet') ->with('main') - ->will($this->returnValue(array('languages' => array('en_US')))); + ->will($this->returnValue(['languages' => ['en_US']])); $app['monolog'] = $this->getMock('Psr\Log\LoggerInterface'); $app['monolog']->expects($this->once()) ->method('error'); @@ -73,7 +73,7 @@ class LocaleServiceProvidertest extends \PhraseanetPHPUnitAbstract $app->register(new LocaleServiceProvider()); $this->assertEquals(array_values(Application::getAvailableLanguages()), array_values($app['locales.I18n.available'])); - $this->assertEquals(array('de', 'en', 'fr', 'nl'), array_keys($app['locales.I18n.available'])); + $this->assertEquals(['de', 'en', 'fr', 'nl'], array_keys($app['locales.I18n.available'])); } public function testLocaleI18n() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ManipulatorServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ManipulatorServiceProviderTest.php index 8ca3a7c71c..ae21d198e5 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ManipulatorServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ManipulatorServiceProviderTest.php @@ -6,17 +6,17 @@ class ManipulatorServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\ManipulatorServiceProvider', 'manipulator.task', 'Alchemy\Phrasea\Model\Manipulator\TaskManipulator' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\ManipulatorServiceProvider', 'manipulator.acl', 'Alchemy\Phrasea\Model\Manipulator\ACLManipulator' - ), - ); + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/NotificationDelivererServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/NotificationDelivererServiceProviderTest.php index cdf170d6d2..3fec7ce790 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/NotificationDelivererServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/NotificationDelivererServiceProviderTest.php @@ -11,9 +11,9 @@ class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider', 'notification.deliverer', 'Alchemy\\Phrasea\\Notification\\Deliverer'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider', 'notification.deliverer', 'Alchemy\\Phrasea\\Notification\\Deliverer'], + ]; } /** @@ -49,8 +49,8 @@ class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase public function provideConfigurationData() { - return array( - array('\Swift_Transport_EsmtpTransport', array( + return [ + ['\Swift_Transport_EsmtpTransport', [ 'GV_smtp' => true, 'GV_smtp_auth' => true, 'GV_smtp_host' => 'special.host.mail', @@ -64,8 +64,8 @@ class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase 'expected-username' => 'superman', 'expected-password' => 'b4tm4n', 'expected-authmode' => null, - )), - array('\Swift_Transport_MailTransport', array( + ]], + ['\Swift_Transport_MailTransport', [ 'GV_smtp' => false, 'GV_smtp_auth' => true, 'GV_smtp_host' => 'special.host.mail', @@ -79,8 +79,8 @@ class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase 'expected-username' => 'superman', 'expected-password' => 'b4tm4n', 'expected-authmode' => null, - )), - array('\Swift_Transport_EsmtpTransport', array( + ]], + ['\Swift_Transport_EsmtpTransport', [ 'GV_smtp' => true, 'GV_smtp_auth' => false, 'GV_smtp_host' => 'special.host.mail', @@ -94,8 +94,8 @@ class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase 'expected-username' => null, 'expected-password' => null, 'expected-authmode' => null, - )), - array('\Swift_Transport_MailTransport', array( + ]], + ['\Swift_Transport_MailTransport', [ 'GV_smtp' => false, 'GV_smtp_auth' => false, 'expected-host' => null, @@ -104,7 +104,7 @@ class NotificationDelivererServiceProvidertest extends ServiceProviderTestCase 'expected-username' => null, 'expected-password' => null, 'expected-authmode' => null, - )), - ); + ]], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php index 75b33d7aa2..05a267dc5b 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php @@ -9,12 +9,12 @@ class ORMServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM', 'Doctrine\\ORM\\EntityManager'), - array('Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.sql-logger', 'Alchemy\\Phrasea\\Model\\MonologSQLLogger'), - array('Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.driver', 'Doctrine\\ORM\Mapping\\Driver\\DriverChain'), - array('Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.config', 'Doctrine\\ORM\\Configuration'), - array('Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.events-manager', 'Doctrine\\Common\\EventManager'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM', 'Doctrine\\ORM\\EntityManager'], + ['Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.sql-logger', 'Alchemy\\Phrasea\\Model\\MonologSQLLogger'], + ['Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.driver', 'Doctrine\\ORM\Mapping\\Driver\\DriverChain'], + ['Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.config', 'Doctrine\\ORM\\Configuration'], + ['Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM.events-manager', 'Doctrine\\Common\\EventManager'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseaVersionServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseaVersionServiceProviderTest.php index 682a0e1d2a..064f7249ad 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseaVersionServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseaVersionServiceProviderTest.php @@ -9,8 +9,8 @@ class PhraseaVersionServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\PhraseaVersionServiceProvider', 'phraseanet.version', 'Alchemy\Phrasea\Core\Version'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\PhraseaVersionServiceProvider', 'phraseanet.version', 'Alchemy\Phrasea\Core\Version'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseanetServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseanetServiceProviderTest.php index b88a0b1813..c852267d4b 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseanetServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/PhraseanetServiceProviderTest.php @@ -9,32 +9,32 @@ class PhraseanetServiceProviderTest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider', 'phraseanet.appbox', '\appbox' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider', 'phraseanet.registry', '\registry' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider', 'firewall', 'Alchemy\Phrasea\Security\Firewall' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider', 'events-manager', '\eventsmanager_broker' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider', 'acl', 'Alchemy\Phrasea\Authentication\ACLProvider' - ) - ); + ] + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/RegistrationServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/RegistrationServiceProviderTest.php index 0146247514..80b1f42f1a 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/RegistrationServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/RegistrationServiceProviderTest.php @@ -14,11 +14,11 @@ class RegistrationServiceProvidertest extends \PhraseanetPHPUnitAbstract self::$DI['app']->register(new RegistrationServiceProvider()); $conf = self::$DI['app']['configuration']->getConfig(); - $conf['registration-fields'] = array('plop'); + $conf['registration-fields'] = ['plop']; self::$DI['app']['configuration'] = $conf; - $this->assertEquals(array('plop'), self::$DI['app']['registration.fields']); - $this->assertEquals(array('plop'), self::$DI['app']['registration.fields']); + $this->assertEquals(['plop'], self::$DI['app']['registration.fields']); + $this->assertEquals(['plop'], self::$DI['app']['registration.fields']); $this->assertInternalType('array', self::$DI['app']['registration.optional-fields']); } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php index 78932d60e7..fd471b0370 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php @@ -9,8 +9,8 @@ class SearchEngineServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider', 'phraseanet.SE', 'Alchemy\Phrasea\SearchEngine\SearchEngineInterface'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider', 'phraseanet.SE', 'Alchemy\Phrasea\SearchEngine\SearchEngineInterface'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php index 3d2a696cbe..d54f16c99d 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/TasksServiceProviderTest.php @@ -9,33 +9,33 @@ class TasksServiceProviderTest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array( + return [ + [ 'Alchemy\Phrasea\Core\Provider\TasksServiceProvider', 'task-manager.job-factory', 'Alchemy\Phrasea\TaskManager\Job\Factory' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\TasksServiceProvider', 'task-manager.status', 'Alchemy\Phrasea\TaskManager\TaskManagerStatus' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\TasksServiceProvider', 'task-manager.log-file.factory', 'Alchemy\Phrasea\TaskManager\Log\LogFileFactory' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\TasksServiceProvider', 'task-manager.notifier', 'Alchemy\Phrasea\TaskManager\Notifier' - ), - array( + ], + [ 'Alchemy\Phrasea\Core\Provider\TasksServiceProvider', 'task-manager.live-information', 'Alchemy\Phrasea\TaskManager\LiveInformation' - ), - ); + ], + ]; } public function testGetAvailableJobs() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/TemporaryFilesystemServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/TemporaryFilesystemServiceProviderTest.php index b3535f5682..afc6d64e6e 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/TemporaryFilesystemServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/TemporaryFilesystemServiceProviderTest.php @@ -9,8 +9,8 @@ class TemporaryFilesystemServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\TemporaryFilesystemServiceProvider', 'temporary-filesystem', 'Neutron\TemporaryFilesystem\TemporaryFilesystemInterface'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\TemporaryFilesystemServiceProvider', 'temporary-filesystem', 'Neutron\TemporaryFilesystem\TemporaryFilesystemInterface'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/TokensServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/TokensServiceProviderTest.php index de74d7a645..52f1e11376 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/TokensServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/TokensServiceProviderTest.php @@ -9,8 +9,8 @@ class TokensServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\TokensServiceProvider', 'tokens', '\random'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\TokensServiceProvider', 'tokens', '\random'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php index dff848d312..50c6fb437b 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php @@ -9,8 +9,8 @@ class UnicodeServiceProvidertest extends ServiceProviderTestCase { public function provideServiceDescription() { - return array( - array('Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider', 'unicode', '\unicode'), - ); + return [ + ['Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider', 'unicode', '\unicode'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Feed/AggregateLinkGeneratorTest.php b/tests/Alchemy/Tests/Phrasea/Feed/AggregateLinkGeneratorTest.php index 74e43541bd..914b09ff90 100644 --- a/tests/Alchemy/Tests/Phrasea/Feed/AggregateLinkGeneratorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Feed/AggregateLinkGeneratorTest.php @@ -20,7 +20,7 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $another_feed = new Feed($user); $another_feed->setTitle("another_title"); - $feeds = array($feed, $another_feed); + $feeds = [$feed, $another_feed]; $aggregate = new Aggregate(self::$DI['app']['EM'], $feeds); @@ -67,15 +67,15 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $this->assertCount(0, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findBy(array('value' => $tokenValue))); + ->findBy(['value' => $tokenValue])); $this->assertCount(1, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findBy(array('value' => $capture['token']))); + ->findBy(['value' => $capture['token']])); } else { - $expectedParams = array( + $expectedParams = [ 'token' => $tokenValue, 'format' => $format, - ); + ]; if ($page !== null) { $expectedParams['page'] = $page; @@ -85,7 +85,7 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $this->assertCount(1, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findBy(array('value' => $tokenValue))); + ->findBy(['value' => $tokenValue])); } } else { if (null !== $page) { @@ -96,11 +96,11 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $this->assertCount(1, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findBy(array('value' => $capture['token']))); + ->findBy(['value' => $capture['token']])); } $token = self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findOneBy(array('usrId' => $user->get_id())); + ->findOneBy(['usrId' => $user->get_id()]); self::$DI['app']['EM']->remove($token); self::$DI['app']['EM']->flush(); } @@ -115,33 +115,33 @@ class AggregateLinkGeneratorTest extends \PhraseanetPHPUnitAbstract ->method('get_id') ->will($this->returnValue(42)); - return array( - array('doliprane', 'atom', $user, null, false, false), - array('doliprane', 'atom', $user, null, false, true), - array('doliprane', 'atom', $user, null, true, false), - array('doliprane', 'atom', $user, null, true, true), - array('doliprane', 'atom', $user, 1, false, false), - array('doliprane', 'atom', $user, 1, false, true), - array('doliprane', 'atom', $user, 1, true, false), - array('doliprane', 'atom', $user, 1, true, true), - array('doliprane', 'rss', $user, null, false, false), - array('doliprane', 'rss', $user, null, false, true), - array('doliprane', 'rss', $user, null, true, false), - array('doliprane', 'rss', $user, null, true, true), - array('doliprane', 'rss', $user, 1, false, false), - array('doliprane', 'rss', $user, 1, false, true), - array('doliprane', 'rss', $user, 1, true, false), - array('doliprane', 'rss', $user, 1, true, true), - ); + return [ + ['doliprane', 'atom', $user, null, false, false], + ['doliprane', 'atom', $user, null, false, true], + ['doliprane', 'atom', $user, null, true, false], + ['doliprane', 'atom', $user, null, true, true], + ['doliprane', 'atom', $user, 1, false, false], + ['doliprane', 'atom', $user, 1, false, true], + ['doliprane', 'atom', $user, 1, true, false], + ['doliprane', 'atom', $user, 1, true, true], + ['doliprane', 'rss', $user, null, false, false], + ['doliprane', 'rss', $user, null, false, true], + ['doliprane', 'rss', $user, null, true, false], + ['doliprane', 'rss', $user, null, true, true], + ['doliprane', 'rss', $user, 1, false, false], + ['doliprane', 'rss', $user, 1, false, true], + ['doliprane', 'rss', $user, 1, true, false], + ['doliprane', 'rss', $user, 1, true, true], + ]; } public function provideGenerationDataPublic() { - return array( - array('doliprane', 'atom', null), - array('doliprane', 'atom', 1), - array('doliprane', 'rss', null), - array('doliprane', 'rss', 1) - ); + return [ + ['doliprane', 'atom', null], + ['doliprane', 'atom', 1], + ['doliprane', 'rss', null], + ['doliprane', 'rss', 1] + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Feed/FeedLinkGeneratorTest.php b/tests/Alchemy/Tests/Phrasea/Feed/FeedLinkGeneratorTest.php index a4f2891176..6df68de67a 100644 --- a/tests/Alchemy/Tests/Phrasea/Feed/FeedLinkGeneratorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Feed/FeedLinkGeneratorTest.php @@ -60,16 +60,16 @@ class FeedLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $this->assertCount(0, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findBy(array('value' => $tokenValue))); + ->findBy(['value' => $tokenValue])); $this->assertCount(1, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findBy(array('value' => $capture['token']))); + ->findBy(['value' => $capture['token']])); } else { - $expectedParams = array( + $expectedParams = [ 'token' => $tokenValue, 'id' => $feed->getId(), 'format' => $format, - ); + ]; if ($page !== null) { $expectedParams['page'] = $page; @@ -79,7 +79,7 @@ class FeedLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $this->assertCount(1, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findBy(array('value' => $tokenValue))); + ->findBy(['value' => $tokenValue])); } } else { if (null !== $page) { @@ -91,11 +91,11 @@ class FeedLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $this->assertCount(1, self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findBy(array('value' => $capture['token']))); + ->findBy(['value' => $capture['token']])); } $token = self::$DI['app']['EM'] ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findOneBy(array('usrId' => $user->get_id(), 'feed' => $feed->getId())); + ->findOneBy(['usrId' => $user->get_id(), 'feed' => $feed->getId()]); self::$DI['app']['EM']->remove($token); self::$DI['app']['EM']->flush(); } @@ -157,24 +157,24 @@ class FeedLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $feed = new \Alchemy\Phrasea\Model\Entities\Feed(); $feed->setTitle('Title'); - return array( - array('doliprane', 'atom', $feed, $user, null, false, false), - array('doliprane', 'atom', $feed, $user, null, false, true), - array('doliprane', 'atom', $feed, $user, null, true, false), - array('doliprane', 'atom', $feed, $user, null, true, true), - array('doliprane', 'atom', $feed, $user, 1, false, false), - array('doliprane', 'atom', $feed, $user, 1, false, true), - array('doliprane', 'atom', $feed, $user, 1, true, false), - array('doliprane', 'atom', $feed, $user, 1, true, true), - array('doliprane', 'rss', $feed, $user, null, false, false), - array('doliprane', 'rss', $feed, $user, null, false, true), - array('doliprane', 'rss', $feed, $user, null, true, false), - array('doliprane', 'rss', $feed, $user, null, true, true), - array('doliprane', 'rss', $feed, $user, 1, false, false), - array('doliprane', 'rss', $feed, $user, 1, false, true), - array('doliprane', 'rss', $feed, $user, 1, true, false), - array('doliprane', 'rss', $feed, $user, 1, true, true), - ); + return [ + ['doliprane', 'atom', $feed, $user, null, false, false], + ['doliprane', 'atom', $feed, $user, null, false, true], + ['doliprane', 'atom', $feed, $user, null, true, false], + ['doliprane', 'atom', $feed, $user, null, true, true], + ['doliprane', 'atom', $feed, $user, 1, false, false], + ['doliprane', 'atom', $feed, $user, 1, false, true], + ['doliprane', 'atom', $feed, $user, 1, true, false], + ['doliprane', 'atom', $feed, $user, 1, true, true], + ['doliprane', 'rss', $feed, $user, null, false, false], + ['doliprane', 'rss', $feed, $user, null, false, true], + ['doliprane', 'rss', $feed, $user, null, true, false], + ['doliprane', 'rss', $feed, $user, null, true, true], + ['doliprane', 'rss', $feed, $user, 1, false, false], + ['doliprane', 'rss', $feed, $user, 1, false, true], + ['doliprane', 'rss', $feed, $user, 1, true, false], + ['doliprane', 'rss', $feed, $user, 1, true, true], + ]; } public function provideGenerationDataPublic() @@ -182,11 +182,11 @@ class FeedLinkGeneratorTest extends \PhraseanetPHPUnitAbstract $feed = new \Alchemy\Phrasea\Model\Entities\Feed(); $feed->setTitle('Title'); - return array( - array('doliprane', 'atom', $feed, null), - array('doliprane', 'atom', $feed, 1), - array('doliprane', 'rss', $feed, null), - array('doliprane', 'rss', $feed, 1) - ); + return [ + ['doliprane', 'atom', $feed, null], + ['doliprane', 'atom', $feed, 1], + ['doliprane', 'rss', $feed, null], + ['doliprane', 'rss', $feed, 1] + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameTest.php b/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameTest.php index c7ec707b9e..54575d5d64 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameTest.php @@ -15,7 +15,7 @@ class GeonameTest extends \PhraseanetPHPUnitAbstract $connector->expects($this->once()) ->method('geoname') ->with(123456) - ->will($this->returnValue(new GeonameResult(array()))); + ->will($this->returnValue(new GeonameResult([]))); $constraint = new Geoname($connector); $this->assertTrue($constraint->isValid(123456)); diff --git a/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameValidatorTest.php index 288681bb0b..bd2007fff9 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Constraint/GeonameValidatorTest.php @@ -35,10 +35,10 @@ class GeonameValidatorTest extends \PhraseanetPHPUnitAbstract public function provideData() { - return array( - array(true), - array(false), - ); + return [ + [true], + [false], + ]; } private function getConstraint() diff --git a/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewEmailValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewEmailValidatorTest.php index 4a12e00b39..43e6c4c2f9 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewEmailValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewEmailValidatorTest.php @@ -35,12 +35,12 @@ class NewEmailValidatorTest extends \PhraseanetPHPUnitAbstract public function provideValidationData() { - return array( - array('romain@neutron.io', true), - array('romain@neutron.io', false), - array('', false), - array(null, false), - ); + return [ + ['romain@neutron.io', true], + ['romain@neutron.io', false], + ['', false], + [null, false], + ]; } private function getConstraint() diff --git a/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewLoginValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewLoginValidatorTest.php index 3423bdb99d..425d277809 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewLoginValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Constraint/NewLoginValidatorTest.php @@ -35,12 +35,12 @@ class NewLoginValidatorTest extends \PhraseanetPHPUnitAbstract public function provideValidationData() { - return array( - array('romainneutron', true), - array('romainneutron', false), - array('', false), - array(null, false), - ); + return [ + ['romainneutron', true], + ['romainneutron', false], + ['', false], + [null, false], + ]; } private function getConstraint() diff --git a/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenTest.php b/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenTest.php index 5d5c9ac1a3..5c33ece891 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenTest.php @@ -12,7 +12,7 @@ class PasswordTokenTest extends \PhraseanetPHPUnitAbstract $random = $this ->getMockBuilder('random') ->disableOriginalConstructor() - ->setMethods(array('helloToken')) + ->setMethods(['helloToken']) ->getMock(); $token = \random::generatePassword(); @@ -32,7 +32,7 @@ class PasswordTokenTest extends \PhraseanetPHPUnitAbstract $random = $this ->getMockBuilder('random') ->disableOriginalConstructor() - ->setMethods(array('helloToken')) + ->setMethods(['helloToken']) ->getMock(); $token = \random::generatePassword(); @@ -41,7 +41,7 @@ class PasswordTokenTest extends \PhraseanetPHPUnitAbstract ->expects($this->once()) ->method('helloToken') ->with($token) - ->will($this->returnValue(array('usr_id' => mt_rand(), 'type' => \random::TYPE_PASSWORD))); + ->will($this->returnValue(['usr_id' => mt_rand(), 'type' => \random::TYPE_PASSWORD])); $constraint = new PasswordToken(self::$DI['app'], $random); $this->assertTrue($constraint->isValid($token)); diff --git a/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenValidatorTest.php index 99491d722b..706237818b 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Constraint/PasswordTokenValidatorTest.php @@ -35,10 +35,10 @@ class PasswordTokenValidatorTest extends \PhraseanetPHPUnitAbstract public function provideValidationData() { - return array( - array(\random::generatePassword(), true), - array(\random::generatePassword(), false), - ); + return [ + [\random::generatePassword(), true], + [\random::generatePassword(), false], + ]; } private function getConstraint() diff --git a/tests/Alchemy/Tests/Phrasea/Form/FormTestCase.php b/tests/Alchemy/Tests/Phrasea/Form/FormTestCase.php index 62d52488c0..ec004e3226 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/FormTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/Form/FormTestCase.php @@ -13,7 +13,7 @@ abstract class FormTestCase extends \PhraseanetPHPUnitAbstract ->disableOriginalConstructor() ->getMock(); - $form->buildForm($builder, array('disabled' => false)); + $form->buildForm($builder, ['disabled' => false]); } public function testGetName() diff --git a/tests/Alchemy/Tests/Phrasea/Form/Login/PhraseaRegisterFormTest.php b/tests/Alchemy/Tests/Phrasea/Form/Login/PhraseaRegisterFormTest.php index e7e6775d88..a24494e60f 100644 --- a/tests/Alchemy/Tests/Phrasea/Form/Login/PhraseaRegisterFormTest.php +++ b/tests/Alchemy/Tests/Phrasea/Form/Login/PhraseaRegisterFormTest.php @@ -10,44 +10,44 @@ class PhraseaRegisterFormTest extends FormTestCase { protected function getForm() { - $available = array( - 'parameter' => array( + $available = [ + 'parameter' => [ 'type' => 'text', 'label' => 'Yollah !', - ) - ); - $params = array( - array( + ] + ]; + $params = [ + [ 'name' => 'parameter', 'required' => true - ) - ); + ] + ]; return new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer()); } public function testFormDoesRegisterValidFields() { - $available = array( - 'parameter' => array( + $available = [ + 'parameter' => [ 'type' => 'text', 'label' => 'Yollah !', - ), - 'parameter2' => array( + ], + 'parameter2' => [ 'type' => 'text', 'label' => 'Yollah !', - ) - ); - $params = array( - array( + ] + ]; + $params = [ + [ 'name' => 'parameter', 'required' => true - ), - array( + ], + [ 'name' => 'parameter2', 'required' => true - ) - ); + ] + ]; $form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer()); @@ -56,22 +56,22 @@ class PhraseaRegisterFormTest extends FormTestCase public function testFormDoesNotRegisterNonValidFields() { - $available = array( - 'parameter' => array( + $available = [ + 'parameter' => [ 'type' => 'text', 'label' => 'Yollah !', - ) - ); - $params = array( - array( + ] + ]; + $params = [ + [ 'name' => 'parameter', 'required' => true - ), - array( + ], + [ 'name' => 'parameter2', 'required' => true - ) - ); + ] + ]; $form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer()); diff --git a/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php b/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php index a355a61e66..0afec8f609 100644 --- a/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Http/ServeFileResponseFactoryTest.php @@ -65,12 +65,12 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCaseAbstract BinaryFileResponse::trustXSendfileTypeHeader(); $this->factory = new ServeFileResponseFactory(new \unicode()); $mode = new NginxMode( - array( - array( + [ + [ 'directory' => __DIR__ . '/../../../../files/', 'mount-point' => '/protected/' - ) - ) + ] + ] ); $request = Request::create('/'); $mode->setHeaders($request); @@ -88,12 +88,12 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCaseAbstract BinaryFileResponse::trustXSendfileTypeHeader(); $this->factory = new ServeFileResponseFactory(new \unicode()); $mode = new NginxMode( - array( - array( + [ + [ 'directory' => __DIR__ . '/../../../../files', 'mount-point' => '/protected' - ) - ) + ] + ] ); $request = Request::create('/'); $mode->setHeaders($request); @@ -122,12 +122,12 @@ class ServeFileResponseFactoryTest extends \PhraseanetWebTestCaseAbstract BinaryFileResponse::trustXSendfileTypeHeader(); $this->factory = new ServeFileResponseFactory(new \unicode()); $mode = new NginxMode( - array( - array( + [ + [ 'directory' => __DIR__ . '/../../../../files/', 'mount-point' => '/protected/' - ) - ) + ] + ] ); $request = Request::create('/'); $mode->setHeaders($request); diff --git a/tests/Alchemy/Tests/Phrasea/Http/XSendFile/ApacheModeTest.php b/tests/Alchemy/Tests/Phrasea/Http/XSendFile/ApacheModeTest.php index 7941d732a6..e218ffcad9 100644 --- a/tests/Alchemy/Tests/Phrasea/Http/XSendFile/ApacheModeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Http/XSendFile/ApacheModeTest.php @@ -9,7 +9,7 @@ class ApacheModeTest extends \PhraseanetPHPUnitAbstract { public function testGetVirtualHost() { - $mode = new ApacheMode(array(array('directory' => __DIR__ ))); + $mode = new ApacheMode([['directory' => __DIR__ ]]); $conf = $mode->getVirtualHostConfiguration(); $this->assertRegExp('#'.__DIR__ . '#', $conf); } @@ -17,15 +17,15 @@ class ApacheModeTest extends \PhraseanetPHPUnitAbstract public function testSetValidHeaders() { $request = Request::create('/'); - $mode = new ApacheMode(array(array('directory' => __DIR__ ))); + $mode = new ApacheMode([['directory' => __DIR__ ]]); $mode->setHeaders($request); $this->assertArrayHasKey('x-sendfile-type', $request->headers->all()); } public function testUnextingDirectoryMapping() { - $mode = new ApacheMode(array(array('directory' => __DIR__ . '/Unknown/Dir'))); - $this->assertEquals(array(), $mode->getMapping()); + $mode = new ApacheMode([['directory' => __DIR__ . '/Unknown/Dir']]); + $this->assertEquals([], $mode->getMapping()); } /** @@ -39,9 +39,9 @@ class ApacheModeTest extends \PhraseanetPHPUnitAbstract public function provideMappings() { - return array( - array(array(array('wrong-key' => __DIR__))), - array(array('not-an-array')), - ); + return [ + [[['wrong-key' => __DIR__]]], + [['not-an-array']], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Http/XSendFile/NginxModeTest.php b/tests/Alchemy/Tests/Phrasea/Http/XSendFile/NginxModeTest.php index 38685e359f..f4575cd5a0 100644 --- a/tests/Alchemy/Tests/Phrasea/Http/XSendFile/NginxModeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Http/XSendFile/NginxModeTest.php @@ -9,8 +9,8 @@ class XSendFileModeNginxTest extends \PhraseanetPHPUnitAbstract { public function testGetVirtualHost() { - $mode = new NginxMode(array(array( - 'directory' => __DIR__, 'mount-point' => '/download'))); + $mode = new NginxMode([[ + 'directory' => __DIR__, 'mount-point' => '/download']]); $conf = $mode->getVirtualHostConfiguration(); $this->assertRegExp('#'.__DIR__ . '#', $conf); } @@ -18,7 +18,7 @@ class XSendFileModeNginxTest extends \PhraseanetPHPUnitAbstract public function testSetValidHeaders() { $request = Request::create('/'); - $mode = new NginxMode(array(array('directory' => __DIR__, 'mount-point' => '/download'))); + $mode = new NginxMode([['directory' => __DIR__, 'mount-point' => '/download']]); $mode->setHeaders($request); $this->assertArrayHasKey('x-sendfile-type', $request->headers->all()); $this->assertArrayHasKey('x-accel-mapping', $request->headers->all()); @@ -30,16 +30,16 @@ class XSendFileModeNginxTest extends \PhraseanetPHPUnitAbstract $upload = __DIR__ . '/../../../../../'; $request = Request::create('/'); - $mode = new NginxMode(array( - array( + $mode = new NginxMode([ + [ 'directory' => $protected, 'mount-point' => '/protected/' - ), - array( + ], + [ 'directory' => $upload, 'mount-point' => '/uploads/' - ), - )); + ], + ]); $mode->setHeaders($request); $this->assertArrayHasKey('x-sendfile-type', $request->headers->all()); $this->assertArrayHasKey('x-accel-mapping', $request->headers->all()); @@ -49,7 +49,7 @@ class XSendFileModeNginxTest extends \PhraseanetPHPUnitAbstract public function testSetInvalidHeaders() { $request = Request::create('/'); - $mode = new NginxMode(array(array('directory' => __DIR__ . '/Unknown/Dir', 'mount-point' => '/download'))); + $mode = new NginxMode([['directory' => __DIR__ . '/Unknown/Dir', 'mount-point' => '/download']]); $mode->setHeaders($request); $this->assertArrayNotHasKey('x-sendfile-type', $request->headers->all()); $this->assertArrayNotHasKey('x-accel-mapping', $request->headers->all()); @@ -57,8 +57,8 @@ class XSendFileModeNginxTest extends \PhraseanetPHPUnitAbstract public function testUnextingDirectoryMapping() { - $mode = new NginxMode(array(array('directory' => __DIR__ . '/Unknown/Dir', 'mount-point' => '/download'))); - $this->assertEquals(array(), $mode->getMapping()); + $mode = new NginxMode([['directory' => __DIR__ . '/Unknown/Dir', 'mount-point' => '/download']]); + $this->assertEquals([], $mode->getMapping()); } /** @@ -72,11 +72,11 @@ class XSendFileModeNginxTest extends \PhraseanetPHPUnitAbstract public function provideMappings() { - return array( - array(array(array('Directory' => __DIR__))), - array(array(array('wrong-key' => __DIR__, 'mount-point' => '/'))), - array(array(array('directory' => __DIR__, 'wrong-key' => '/'))), - array(array('not-an-array')), - ); + return [ + [[['Directory' => __DIR__]]], + [[['wrong-key' => __DIR__, 'mount-point' => '/']]], + [[['directory' => __DIR__, 'wrong-key' => '/']]], + [['not-an-array']], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Http/XSendFile/XSendFileFactoryTest.php b/tests/Alchemy/Tests/Phrasea/Http/XSendFile/XSendFileFactoryTest.php index 39beb2f9f4..c37e78071e 100644 --- a/tests/Alchemy/Tests/Phrasea/Http/XSendFile/XSendFileFactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Http/XSendFile/XSendFileFactoryTest.php @@ -65,17 +65,17 @@ class XSendFileFactoryTest extends \PhraseanetPHPUnitAbstract public function provideTypes() { - return array( - array('apache', $this->getApacheMapping(), 'Alchemy\Phrasea\Http\XSendFile\ApacheMode'), - array('apache2', $this->getApacheMapping(), 'Alchemy\Phrasea\Http\XSendFile\ApacheMode'), - array('xsendfile', $this->getApacheMapping(), 'Alchemy\Phrasea\Http\XSendFile\ApacheMode'), - array('nginx',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'), - array('sendfile',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'), - array('xaccel',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'), - array('xaccelredirect',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'), - array('x-accel',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'), - array('x-accel-redirect',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'), - ); + return [ + ['apache', $this->getApacheMapping(), 'Alchemy\Phrasea\Http\XSendFile\ApacheMode'], + ['apache2', $this->getApacheMapping(), 'Alchemy\Phrasea\Http\XSendFile\ApacheMode'], + ['xsendfile', $this->getApacheMapping(), 'Alchemy\Phrasea\Http\XSendFile\ApacheMode'], + ['nginx',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'], + ['sendfile',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'], + ['xaccel',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'], + ['xaccelredirect',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'], + ['x-accel',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'], + ['x-accel-redirect',$this->getNginxMapping(), 'Alchemy\Phrasea\Http\XSendFile\NginxMode'], + ]; } public function testInvalidMappingThrowsAnExceptionIfRequired() @@ -86,7 +86,7 @@ class XSendFileFactoryTest extends \PhraseanetPHPUnitAbstract ->method('error') ->with($this->isType('string')); - $factory = new XSendFileFactory($logger, true, 'nginx', array()); + $factory = new XSendFileFactory($logger, true, 'nginx', []); $this->setExpectedException('Alchemy\Phrasea\Exception\RuntimeException'); $factory->getMode(true); } @@ -99,7 +99,7 @@ class XSendFileFactoryTest extends \PhraseanetPHPUnitAbstract ->method('error') ->with($this->isType('string')); - $factory = new XSendFileFactory($logger, true, 'nginx', array()); + $factory = new XSendFileFactory($logger, true, 'nginx', []); $this->assertInstanceOf('Alchemy\Phrasea\Http\XSendFile\NginxMode', $factory->getMode(false)); } @@ -111,22 +111,22 @@ class XSendFileFactoryTest extends \PhraseanetPHPUnitAbstract ->method('error') ->with($this->isType('string')); - $factory = new XSendFileFactory($logger, true, 'nginx', array()); + $factory = new XSendFileFactory($logger, true, 'nginx', []); $this->assertInstanceOf('Alchemy\Phrasea\Http\XSendFile\NginxMode', $factory->getMode()); } private function getNginxMapping() { - return array(array( + return [[ 'directory' => __DIR__ . '/../../../../files/', 'mount-point' => '/protected/' - )); + ]]; } private function getApacheMapping() { - return array(array( + return [[ 'directory' => __DIR__ . '/../../../../files/', - )); + ]]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/EnumTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/EnumTest.php index f727cb6338..74472180b2 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/EnumTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/EnumTest.php @@ -14,7 +14,7 @@ class EnumTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Enum('Numo', 'enumerateur', array('un', 'dos', 'tres'), 'dos'); + $this->object = new Enum('Numo', 'enumerateur', ['un', 'dos', 'tres'], 'dos'); } /** @@ -52,7 +52,7 @@ class EnumTest extends \PHPUnit_Framework_TestCase */ public function testGetAvailableValues() { - $this->assertEquals(array('un', 'dos', 'tres'), $this->object->getAvailableValues()); + $this->assertEquals(['un', 'dos', 'tres'], $this->object->getAvailableValues()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/MultiTest.php b/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/MultiTest.php index 08906dc004..fc628122e3 100644 --- a/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/MultiTest.php +++ b/tests/Alchemy/Tests/Phrasea/Media/Subdef/OptionType/MultiTest.php @@ -14,7 +14,7 @@ class MultiTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->object = new Multi('MUMU', 'multiateur', array('un', 'dos', 'tres'), 'dos'); + $this->object = new Multi('MUMU', 'multiateur', ['un', 'dos', 'tres'], 'dos'); } /** @@ -22,11 +22,11 @@ class MultiTest extends \PHPUnit_Framework_TestCase */ public function testSetValue() { - $this->assertEquals(array('dos'), $this->object->getValue()); + $this->assertEquals(['dos'], $this->object->getValue()); $this->object->setValue('tres'); - $this->assertEquals(array('tres'), $this->object->getValue()); + $this->assertEquals(['tres'], $this->object->getValue()); $this->object->setValue(''); - $this->assertEquals(array(), $this->object->getValue()); + $this->assertEquals([], $this->object->getValue()); } /** @@ -51,7 +51,7 @@ class MultiTest extends \PHPUnit_Framework_TestCase */ public function testGetAvailableValues() { - $this->assertEquals(array('un', 'dos', 'tres'), $this->object->getAvailableValues()); + $this->assertEquals(['un', 'dos', 'tres'], $this->object->getAvailableValues()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php b/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php index 61da70f9c3..633ecb2674 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Entities/UserTest.php @@ -142,22 +142,22 @@ class UserTest extends \PhraseanetPHPUnitAbstract public function genderProvider() { - return array( - array(null), - array(User::GENDER_MISS), - array(User::GENDER_MR), - array(User::GENDER_MR), - ); + return [ + [null], + [User::GENDER_MISS], + [User::GENDER_MR], + [User::GENDER_MR], + ]; } public function invalidGenderProvider() { - return array( - array(false), - array(''), - array(1), - array('madame') - ); + return [ + [false], + [''], + [1], + ['madame'] + ]; } public function testGetSettingValue() diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php index be615b3e05..56ae6ec289 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php @@ -24,19 +24,19 @@ class ACLManipulatorTest extends \PhraseanetPHPUnitAbstract foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $databoxId = $databox->get_sbas_id(); - $acl->update_rights_to_sbas($databoxId, array( + $acl->update_rights_to_sbas($databoxId, [ 'bas_manage' => '0', 'bas_modify_struct' => '0', 'bas_modif_th' => '0', 'bas_chupub' => '0' - )); + ]); foreach ($databox->get_collections() as $collection) { $baseId = $collection->get_base_id(); $acl->set_limits($baseId, true); $acl->set_masks_on_base($baseId, '1', '1', '1', '1'); - $acl->update_rights_to_base($baseId, array( + $acl->update_rights_to_base($baseId, [ 'canputinalbum' => '0', 'candwnldhd' => '0', 'candwnldsubdef' => '0', @@ -55,7 +55,7 @@ class ACLManipulatorTest extends \PhraseanetPHPUnitAbstract 'manage' => '0', 'modify_struct' => '0', 'bas_modify_struct' => '0' - )); + ]); break 2; } diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php index 7c1aac12f2..4d952cb19a 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/TaskManipulatorTest.php @@ -22,7 +22,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract $this->assertEquals('bla bla', $task->getJobId()); $this->assertEquals('super settings', $task->getSettings()); $this->assertEquals(0, $task->getPeriod()); - $this->assertSame(array($task), $this->findAllTasks()); + $this->assertSame([$task], $this->findAllTasks()); return $task; } @@ -39,7 +39,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract $task->setName('new name'); $this->assertSame($task, $manipulator->update($task)); self::$DI['app']['EM']->clear(); - $this->assertEquals(array($task), $this->findAllTasks()); + $this->assertEquals([$task], $this->findAllTasks()); } public function testDelete() @@ -52,7 +52,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract $manipulator = new TaskManipulator(self::$DI['app']['EM'], $notifier); $task = $this->loadTask(); $manipulator->delete($task); - $this->assertEquals(array(), $this->findAllTasks()); + $this->assertEquals([], $this->findAllTasks()); } public function testStart() @@ -121,7 +121,7 @@ class TaskManipulatorTest extends \PhraseanetPHPUnitAbstract $tasks = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Task')->findAll(); $this->assertSame('EmptyCollection', $task->getJobId()); - $this->assertSame(array($task), $tasks); + $this->assertSame([$task], $tasks); $settings = simplexml_load_string($task->getSettings()); $this->assertEquals(42, (int) $settings->bas_id); } diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php index 4c6bf57aaf..153665ff38 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php @@ -60,7 +60,7 @@ class UserManipulatorTest extends \PhraseanetPHPUnitAbstract $geoname->expects($this->once()) ->method('get') ->with($this->equalTo('country')) - ->will($this->returnValue(array('code' => 'fr'))); + ->will($this->returnValue(['code' => 'fr'])); $geonamesConnector = $this->getMockBuilder('Alchemy\Geonames\Connector') ->disableOriginalConstructor() @@ -87,7 +87,7 @@ class UserManipulatorTest extends \PhraseanetPHPUnitAbstract $this->assertFalse($user->isAdmin()); $user2 = self::$DI['app']['manipulator.user']->createUser('login2', 'toto'); $this->assertFalse($user2->isAdmin()); - self::$DI['app']['manipulator.user']->promote(array($user, $user2)); + self::$DI['app']['manipulator.user']->promote([$user, $user2]); $user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login'); $this->assertTrue($user->isAdmin()); $user2 = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login'); @@ -127,7 +127,7 @@ class UserManipulatorTest extends \PhraseanetPHPUnitAbstract $geoname->expects($this->once()) ->method('get') ->with($this->equalTo('country')) - ->will($this->returnValue(array('code' => 'fr'))); + ->will($this->returnValue(['code' => 'fr'])); $geonamesConnector = $this->getMockBuilder('Alchemy\Geonames\Connector') ->disableOriginalConstructor() diff --git a/tests/Alchemy/Tests/Phrasea/Model/Repositories/TaskRepositoryTest.php b/tests/Alchemy/Tests/Phrasea/Model/Repositories/TaskRepositoryTest.php index 49be417b6d..b26edc80b2 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Repositories/TaskRepositoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Repositories/TaskRepositoryTest.php @@ -24,13 +24,13 @@ class TaskRepositoryTest extends \PhraseanetPHPUnitAbstract self::$DI['app']['EM']->flush(); $repository = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Task'); - $this->assertSame(array($task2), $repository->findActiveTasks()); + $this->assertSame([$task2], $repository->findActiveTasks()); $task1->setStatus(Task::STATUS_STARTED); self::$DI['app']['EM']->persist($task1); self::$DI['app']['EM']->flush(); - $this->assertSame(array($task1, $task2), $repository->findActiveTasks()); + $this->assertSame([$task1, $task2], $repository->findActiveTasks()); } } diff --git a/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php b/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php index 36f599e5bf..8007740ca9 100644 --- a/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php +++ b/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php @@ -133,7 +133,7 @@ class DelivererTest extends \PHPUnit_Framework_TestCase $deliverer->deliver($mail, true); /* @var $catchEmail \Swift_Message */ - $this->assertEquals(array($email => $name), $catchEmail->getReadReceiptTo()); + $this->assertEquals([$email => $name], $catchEmail->getReadReceiptTo()); } /** @@ -241,7 +241,7 @@ class DelivererTest extends \PHPUnit_Framework_TestCase $deliverer->deliver($mail); /* @var $catchEmail \Swift_Message */ - $this->assertEquals(array($email => $name), $catchEmail->getFrom()); + $this->assertEquals([$email => $name], $catchEmail->getFrom()); } /** @@ -280,7 +280,7 @@ class DelivererTest extends \PHPUnit_Framework_TestCase $deliverer->deliver($mail); /* @var $catchEmail \Swift_Message */ - $this->assertEquals(array($email => $name), $catchEmail->getTo()); + $this->assertEquals([$email => $name], $catchEmail->getTo()); } /** @@ -323,7 +323,7 @@ class DelivererTest extends \PHPUnit_Framework_TestCase $deliverer->deliver($mail); /* @var $catchEmail \Swift_Message */ - $this->assertEquals(array($email => $name), $catchEmail->getReplyTo()); + $this->assertEquals([$email => $name], $catchEmail->getReplyTo()); } private function getEventDispatcherMock() diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/ClassLoader.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/ClassLoader.php index ef9924516a..13bed82532 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/ClassLoader.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/ClassLoader.php @@ -42,10 +42,10 @@ namespace Composer\Autoload; */ class ClassLoader { - private $prefixes = array(); - private $fallbackDirs = array(); + private $prefixes = []; + private $fallbackDirs = []; private $useIncludePath = false; - private $classMap = array(); + private $classMap = []; public function getPrefixes() { @@ -162,7 +162,7 @@ class ClassLoader */ public function register($prepend = false) { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); + spl_autoload_register([$this, 'loadClass'], true, $prepend); } /** @@ -170,7 +170,7 @@ class ClassLoader */ public function unregister() { - spl_autoload_unregister(array($this, 'loadClass')); + spl_autoload_unregister([$this, 'loadClass']); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_classmap.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_classmap.php index d3ef7827a3..c95a94e1d9 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_classmap.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_classmap.php @@ -5,6 +5,6 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); -return array( +return [ 'Vendor\\PluginService' => $baseDir . '/src/Vendor/PluginService.php', -); +]; diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_namespaces.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_namespaces.php index 43ccccf9a9..c69bc99672 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_namespaces.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_namespaces.php @@ -5,6 +5,6 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); -return array( - 'Vendor' => array($baseDir . '/src'), -); +return [ + 'Vendor' => [$baseDir . '/src'], +]; diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_real.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_real.php index 10cf2abce2..11030fa495 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_real.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/PluginDirInstalled/test-plugin/vendor/composer/autoload_real.php @@ -19,9 +19,9 @@ class ComposerAutoloaderInit7a818310afafc4600ddb36d030b5d99d return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit7a818310afafc4600ddb36d030b5d99d', 'loadClassLoader'), true, true); + spl_autoload_register(['ComposerAutoloaderInit7a818310afafc4600ddb36d030b5d99d', 'loadClassLoader'], true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit7a818310afafc4600ddb36d030b5d99d', 'loadClassLoader')); + spl_autoload_unregister(['ComposerAutoloaderInit7a818310afafc4600ddb36d030b5d99d', 'loadClassLoader']); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/ClassLoader.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/ClassLoader.php index ef9924516a..13bed82532 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/ClassLoader.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/ClassLoader.php @@ -42,10 +42,10 @@ namespace Composer\Autoload; */ class ClassLoader { - private $prefixes = array(); - private $fallbackDirs = array(); + private $prefixes = []; + private $fallbackDirs = []; private $useIncludePath = false; - private $classMap = array(); + private $classMap = []; public function getPrefixes() { @@ -162,7 +162,7 @@ class ClassLoader */ public function register($prepend = false) { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); + spl_autoload_register([$this, 'loadClass'], true, $prepend); } /** @@ -170,7 +170,7 @@ class ClassLoader */ public function unregister() { - spl_autoload_unregister(array($this, 'loadClass')); + spl_autoload_unregister([$this, 'loadClass']); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_classmap.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_classmap.php index af4ad5805a..ca5d68d0cc 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_classmap.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_classmap.php @@ -5,5 +5,5 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); -return array( -); +return [ +]; diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_namespaces.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_namespaces.php index 7b9d51608f..8e80598a33 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_namespaces.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_namespaces.php @@ -5,5 +5,5 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); -return array( -); +return [ +]; diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_real.php b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_real.php index 77390018db..139afa967a 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_real.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Fixtures/vendor/composer/autoload_real.php @@ -19,9 +19,9 @@ class ComposerAutoloaderInit4ea6c38a75e30f622d666844c915395f return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit4ea6c38a75e30f622d666844c915395f', 'loadClassLoader'), true, true); + spl_autoload_register(['ComposerAutoloaderInit4ea6c38a75e30f622d666844c915395f', 'loadClassLoader'], true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit4ea6c38a75e30f622d666844c915395f', 'loadClassLoader')); + spl_autoload_unregister(['ComposerAutoloaderInit4ea6c38a75e30f622d666844c915395f', 'loadClassLoader']); $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImportStrategyTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImportStrategyTest.php index c394bb0cca..24a9ad3c55 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImportStrategyTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImportStrategyTest.php @@ -28,17 +28,17 @@ class ImportStrategyTest extends PluginTestCase public function provideFolderSources() { - return array( - array(__DIR__), - array(dirname(__DIR__)), - ); + return [ + [__DIR__], + [dirname(__DIR__)], + ]; } public function provideInvalidFolderSources() { - return array( - array('/path/to/invalid/dir'), - array(__FILE__), - ); + return [ + ['/path/to/invalid/dir'], + [__FILE__], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImporterTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImporterTest.php index aa0bbd9f0e..52c1b49911 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImporterTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Importer/ImporterTest.php @@ -23,7 +23,7 @@ class ImporterTest extends PluginTestCase ->method('import') ->with($source, $target); - $importer = new Importer($strategy, array('elephant' => $importerInterface)); + $importer = new Importer($strategy, ['elephant' => $importerInterface]); $importer->import($source, $target); } @@ -45,7 +45,7 @@ class ImporterTest extends PluginTestCase $importerInterface->expects($this->never()) ->method('import'); - $importer = new Importer($strategy, array('rhinoceros' => $importerInterface)); + $importer = new Importer($strategy, ['rhinoceros' => $importerInterface]); $importer->import($source, $target); } } diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php index a4d52cdc14..1008ca95e9 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php @@ -16,19 +16,19 @@ class AutoloaderGeneratorTest extends \PHPUnit_Framework_TestCase $pluginDir = __DIR__ . '/../Fixtures/PluginDirInstalled/test-plugin'; $pluginsDir = __DIR__ . '/../Fixtures/PluginDirInstalled'; - $files = array( + $files = [ $pluginsDir . '/services.php', $pluginsDir . '/autoload.php', $pluginsDir . '/commands.php', $pluginsDir . '/twig-paths.php', $pluginsDir . '/login.less', $pluginsDir . '/account.less', - ); + ]; $this->cleanup($files); $generator = new AutoloaderGenerator($pluginsDir); - $generator->write(array(new Manifest(json_decode(file_get_contents($pluginDir . '/manifest.json'), true)))); + $generator->write([new Manifest(json_decode(file_get_contents($pluginDir . '/manifest.json'), true))]); $finder = new ExecutableFinder(); $php = $finder->find('php'); @@ -39,7 +39,7 @@ class AutoloaderGeneratorTest extends \PHPUnit_Framework_TestCase foreach ($files as $file) { $this->assertFileExists($file); - $process = ProcessBuilder::create(array($php, '-l', $file))->getProcess(); + $process = ProcessBuilder::create([$php, '-l', $file])->getProcess(); $process->run(); $this->assertTrue($process->isSuccessful(), basename($file) . ' is valid'); } @@ -65,7 +65,7 @@ class AutoloaderGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Vendor\CustomCommand', $cli['console']->find('hello:world')); $mapping = require $pluginsDir . '/twig-paths.php'; - $this->assertSame(array('plugin-test-plugin' => $pluginsDir . '/test-plugin/views', $pluginsDir . '/test-plugin/views', $pluginsDir . '/test-plugin/twig-views'), $mapping); + $this->assertSame(['plugin-test-plugin' => $pluginsDir . '/test-plugin/views', $pluginsDir . '/test-plugin/views', $pluginsDir . '/test-plugin/twig-views'], $mapping); $this->assertRegExp('#@import#', file_get_contents($pluginsDir . '/login.less')); $this->assertRegExp('#@import#', file_get_contents($pluginsDir . '/account.less')); diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Management/ComposerInstallerTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Management/ComposerInstallerTest.php index 07e954e7c8..0ae5dd206d 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Management/ComposerInstallerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Management/ComposerInstallerTest.php @@ -21,7 +21,7 @@ class ComposerInstallerTest extends \PHPUnit_Framework_TestCase $installFile = __DIR__ . '/installer'; $composer = __DIR__ . '/composer.phar'; - $fs->remove(array($composer, $installFile, $vendorDir)); + $fs->remove([$composer, $installFile, $vendorDir]); if (null === $php) { $this->markTestSkipped('Unable to find PHP executable.'); diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Management/PluginsExplorerTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Management/PluginsExplorerTest.php index f5565c9d23..621cb86641 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Management/PluginsExplorerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Management/PluginsExplorerTest.php @@ -18,12 +18,12 @@ class PluginsExplorerTest extends PluginTestCase { $explorer = new PluginsExplorer(__DIR__ . '/../Fixtures/PluginDir'); - $dirs = array(); + $dirs = []; foreach ($explorer as $dir) { $dirs[] = (string) realpath($dir); } - $this->assertSame(array(realpath(__DIR__ . '/../Fixtures/PluginDir/TestPlugin')), $dirs); + $this->assertSame([realpath(__DIR__ . '/../Fixtures/PluginDir/TestPlugin')], $dirs); } } diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestTest.php index 67bb91acab..9014d46f3d 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestTest.php @@ -13,20 +13,20 @@ class ManifestTest extends \PHPUnit_Framework_TestCase $this->assertEquals('test-plugin', $manifest->getName()); $this->assertEquals('A custom class connector', $manifest->getDescription()); - $this->assertEquals(array('connector'), $manifest->getKeywords()); - $this->assertEquals(array(array( + $this->assertEquals(['connector'], $manifest->getKeywords()); + $this->assertEquals([[ 'name' => 'Author name', 'homepage' => 'http://example.com', 'email' => 'email@example.com', - )), $manifest->getAuthors()); + ]], $manifest->getAuthors()); $this->assertEquals('http://example.com/project/example', $manifest->getHomepage()); $this->assertEquals('MIT', $manifest->getLicense()); $this->assertEquals('0.1', $manifest->getVersion()); $this->assertEquals('3.8', $manifest->getMinimumPhraseanetVersion()); $this->assertEquals('3.10', $manifest->getMaximumPhraseanetVersion()); - $this->assertEquals(array('views', 'twig-views'), $manifest->getTwigPaths()); - $this->assertEquals(array(array('class' => 'Vendor\CustomCommand')), $manifest->getCommands()); - $this->assertEquals(array(array('class' => 'Vendor\PluginService')), $manifest->getServices()); - $this->assertEquals(array('property' => 'value'), $manifest->getExtra()); + $this->assertEquals(['views', 'twig-views'], $manifest->getTwigPaths()); + $this->assertEquals([['class' => 'Vendor\CustomCommand']], $manifest->getCommands()); + $this->assertEquals([['class' => 'Vendor\PluginService']], $manifest->getServices()); + $this->assertEquals(['property' => 'value'], $manifest->getExtra()); } } diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestValidatorTest.php index 992bb9eaaa..089b2e0fcd 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Schema/ManifestValidatorTest.php @@ -19,10 +19,10 @@ class ManifestValidatorTest extends PluginTestCase public function provideGoodManifestFiles() { - return array( - array(__DIR__ . '/../Fixtures/manifest-good-big.json'), - array(__DIR__ . '/../Fixtures/manifest-good-minimal.json'), - ); + return [ + [__DIR__ . '/../Fixtures/manifest-good-big.json'], + [__DIR__ . '/../Fixtures/manifest-good-minimal.json'], + ]; } /** @@ -37,15 +37,15 @@ class ManifestValidatorTest extends PluginTestCase public function provideWrongManifestFiles() { - return array( - array(__DIR__ . '/../Fixtures/manifest-wrong1.json'), - array(__DIR__ . '/../Fixtures/manifest-wrong2.json'), - array(__DIR__ . '/../Fixtures/manifest-wrong3.json'), - array(__DIR__ . '/../Fixtures/manifest-wrong4.json'), - array(__DIR__ . '/../Fixtures/manifest-wrong5-min-version.json'), - array(__DIR__ . '/../Fixtures/manifest-wrong6-max-version.json'), - array(__DIR__ . '/../Fixtures/manifest-wrong7-invalid-name.json') - ); + return [ + [__DIR__ . '/../Fixtures/manifest-wrong1.json'], + [__DIR__ . '/../Fixtures/manifest-wrong2.json'], + [__DIR__ . '/../Fixtures/manifest-wrong3.json'], + [__DIR__ . '/../Fixtures/manifest-wrong4.json'], + [__DIR__ . '/../Fixtures/manifest-wrong5-min-version.json'], + [__DIR__ . '/../Fixtures/manifest-wrong6-max-version.json'], + [__DIR__ . '/../Fixtures/manifest-wrong7-invalid-name.json'] + ]; } /** @@ -54,7 +54,7 @@ class ManifestValidatorTest extends PluginTestCase public function testValidateInvalidData() { $validator = $this->createValidator(); - $validator->validate(array()); + $validator->validate([]); } /** @@ -62,7 +62,7 @@ class ManifestValidatorTest extends PluginTestCase */ public function testConstructWithInvalidSchema() { - new ManifestValidator(new JsonSchemaValidator(), array(), self::$DI['cli']['phraseanet.version']); + new ManifestValidator(new JsonSchemaValidator(), [], self::$DI['cli']['phraseanet.version']); } public function testCreate() diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Schema/PluginValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Schema/PluginValidatorTest.php index 0e37aad308..4e5ab4b556 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Schema/PluginValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Schema/PluginValidatorTest.php @@ -28,22 +28,22 @@ class PluginValidatorTest extends PluginTestCase public function providePluginDirs() { - return array( - array(__DIR__ . '/../Fixtures/PluginDir/TestPlugin'), - ); + return [ + [__DIR__ . '/../Fixtures/PluginDir/TestPlugin'], + ]; } public function provideInvalidPluginDirs() { - return array( - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidManifest'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginMissingComposer'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginMissingManifest'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidName'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidTwigPath'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginNoPublicDirectory'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidTwigPathMapping'), - array(__DIR__ . '/../Fixtures/WrongPlugins/TestPluginWrongManifest'), - ); + return [ + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidManifest'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginMissingComposer'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginMissingManifest'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidName'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidTwigPath'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginNoPublicDirectory'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginInvalidTwigPathMapping'], + [__DIR__ . '/../Fixtures/WrongPlugins/TestPluginWrongManifest'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaEngineTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaEngineTest.php index e6e7a4d18d..95aacf896c 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaEngineTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaEngineTest.php @@ -29,7 +29,7 @@ class PhraseaEngineTest extends SearchEngineAbstractTest self::$searchEngine = PhraseaEngine::create(self::$DI['app']); } - protected function updateIndex(array $stemms = array()) + protected function updateIndex(array $stemms = []) { $appbox = self::$DI['app']['phraseanet.appbox']; $cmd = '/usr/local/bin/phraseanet_indexer ' @@ -82,10 +82,10 @@ class PhraseaEngineTest extends SearchEngineAbstractTest $date = new \DateTime('-2 months'); foreach ($rs as $row) { - $stmt->execute(array( + $stmt->execute([ ':date' => $date->format(DATE_ISO8601), ':session_id' => $row['session_id'], - )); + ]); break; } diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php index 6c227a2ca3..59f6fcd199 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php @@ -111,7 +111,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $this->updateIndex(); $options = $this->getOptions(); - $options->setDateFields(array($date_field)); + $options->setDateFields([$date_field]); $options->setMinDate(\DateTime::createFromFormat('Y-m-d H:i:s', '2012-12-23 01:01:00')); self::$searchEngine->setOptions($options); @@ -143,7 +143,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA if ($date_field) { - $toupdate = array(); + $toupdate = []; try { $values = $record->get_caption()->get_field($databox_field->get_name())->get_values(); @@ -153,11 +153,11 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $meta_id = null; } - $toupdate[$databox_field->get_id()] = array( + $toupdate[$databox_field->get_id()] = [ 'meta_id' => $meta_id , 'meta_struct_id' => $databox_field->get_id() , 'value' => $date - ); + ]; $record->set_metadatas($toupdate); } @@ -182,7 +182,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $this->updateIndex(); $options = $this->getOptions(); - $options->setDateFields(array($date_field)); + $options->setDateFields([$date_field]); $options->setMaxDate(\DateTime::createFromFormat('Y-m-d H:i:s', '2012-12-20 01:01:00')); self::$searchEngine->setOptions($options); @@ -215,7 +215,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $this->updateIndex(); $options = $this->getOptions(); - $options->setDateFields(array($date_field)); + $options->setDateFields([$date_field]); $options->setMinDate(\DateTime::createFromFormat('Y-m-d H:i:s', '2012-12-18 01:01:00')); $options->setMaxDate(\DateTime::createFromFormat('Y-m-d H:i:s', '2012-12-20 01:01:00')); self::$searchEngine->setOptions($options); @@ -234,7 +234,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA protected function editRecord($string2add, \record_adapter &$record, $indexable = true, $business = false) { - $toupdate = array(); + $toupdate = []; $field = null; foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) { @@ -251,11 +251,11 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $meta_id = null; } - $toupdate[$field->get_id()] = array( + $toupdate[$field->get_id()] = [ 'meta_id' => $meta_id , 'meta_struct_id' => $field->get_id() , 'value' => $string2add - ); + ]; break; } @@ -357,7 +357,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $this->editRecord($index_string, $record); self::$searchEngine->addRecord($record); - $this->updateIndex(array($language)); + $this->updateIndex([$language]); self::$searchEngine->resetCache(); $results = self::$searchEngine->query($query_string, 0, 1); @@ -366,14 +366,14 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA public function provideStemmData() { - $stemms = array(); + $stemms = []; - $examples = array( - 'fr' => array('word' => 'chevaux', 'stemm' => 'cheval'), - 'en' => array('word' => 'consistency', 'stemm' => 'consistent'), - 'de' => array('word' => 'aufeinanderfolgender', 'stemm' => 'aufeinanderfolg'), - 'nl' => array('word' => 'lichamelijk', 'stemm' => 'licham'), - ); + $examples = [ + 'fr' => ['word' => 'chevaux', 'stemm' => 'cheval'], + 'en' => ['word' => 'consistency', 'stemm' => 'consistent'], + 'de' => ['word' => 'aufeinanderfolgender', 'stemm' => 'aufeinanderfolg'], + 'nl' => ['word' => 'lichamelijk', 'stemm' => 'licham'], + ]; foreach (Application::getAvailableLanguages() as $languageCode => $name) { $data = explode('_', $languageCode); @@ -383,11 +383,11 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $this->fail(sprintf('Missing stemm examples for language %s', $code)); } - $stemms[] = array( + $stemms[] = [ $code, $examples[$code]['word'], $examples[$code]['stemm'], - ); + ]; } return $stemms; @@ -401,7 +401,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $query_string = 'boomboklot' . $record->get_record_id() . 'onfield'; $field = $this->editRecord($query_string, $record); - $options->setFields(array($field)); + $options->setFields([$field]); self::$searchEngine->setOptions($options); @@ -421,7 +421,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $query_string = 'boomboklot' . $record->get_record_id() . 'businessAvailable'; $this->editRecord($query_string, $record, true, true); - $options->allowBusinessFieldsOn(array($record->get_collection())); + $options->allowBusinessFieldsOn([$record->get_collection()]); self::$searchEngine->setOptions($options); self::$searchEngine->addRecord($record); @@ -458,7 +458,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) { if ($selectedField->get_id() != $field->get_id()) { - $options->setFields(array($field)); + $options->setFields([$field]); break; } @@ -508,7 +508,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $this->assertEquals(0, $results->getTotal()); $options = $this->getDefaultOptions(); - $options->setFields(array($field)); + $options->setFields([$field]); self::$searchEngine->setOptions($options); self::$searchEngine->resetCache(); @@ -542,7 +542,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $results = self::$searchEngine->query($query_string, 0, 1); $this->assertEquals(0, $results->getTotal()); - $options->setFields(array($field)); + $options->setFields([$field]); self::$searchEngine->setOptions($options); self::$searchEngine->resetCache(); @@ -554,7 +554,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA { $this->assertTrue(is_array(self::$searchEngine->getAvailableTypes())); foreach (self::$searchEngine->getAvailableTypes() as $type) { - $this->assertTrue(in_array($type, array(SearchEngineInterface::GEM_TYPE_ENTRY, SearchEngineInterface::GEM_TYPE_RECORD, SearchEngineInterface::GEM_TYPE_STORY))); + $this->assertTrue(in_array($type, [SearchEngineInterface::GEM_TYPE_ENTRY, SearchEngineInterface::GEM_TYPE_RECORD, SearchEngineInterface::GEM_TYPE_STORY])); } } @@ -627,7 +627,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA self::$searchEngine->addRecord($record); $this->updateIndex(); - $options->setStatus(array(4 => array('on' => array($record->get_databox()->get_sbas_id())))); + $options->setStatus([4 => ['on' => [$record->get_databox()->get_sbas_id()]]]); self::$searchEngine->setOptions($options); self::$searchEngine->resetCache(); @@ -642,7 +642,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $record = self::$DI['record_24']; $record->set_binary_status('10000'); - $options->setStatus(array(4 => array('on' => array($record->get_databox()->get_sbas_id())))); + $options->setStatus([4 => ['on' => [$record->get_databox()->get_sbas_id()]]]); self::$searchEngine->setOptions($options); $query_string = 'boomboklot' . $record->get_record_id() . 'statusQueryOnOverOn'; @@ -663,7 +663,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $record = self::$DI['record_24']; $record->set_binary_status('10000'); - $options->setStatus(array(4 => array('off' => array($record->get_databox()->get_sbas_id())))); + $options->setStatus([4 => ['off' => [$record->get_databox()->get_sbas_id()]]]); self::$searchEngine->setOptions($options); $query_string = 'boomboklot' . $record->get_record_id() . 'statusQueryOff'; @@ -684,7 +684,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA $record = self::$DI['record_24']; $record->set_binary_status('00000'); - $options->setStatus(array(4 => array('off' => array($record->get_databox()->get_sbas_id())))); + $options->setStatus([4 => ['off' => [$record->get_databox()->get_sbas_id()]]]); self::$searchEngine->setOptions($options); $query_string = 'boomboklot' . $record->get_record_id() . 'statusQueryOff'; @@ -710,7 +710,7 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA self::$searchEngine->addRecord($record); $this->updateIndex(); - $options->setStatus(array(4 => array('on' => array($record->get_databox()->get_sbas_id())))); + $options->setStatus([4 => ['on' => [$record->get_databox()->get_sbas_id()]]]); self::$searchEngine->setOptions($options); self::$searchEngine->resetCache(); @@ -739,16 +739,16 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA self::$searchEngine->resetCache(); $results = self::$searchEngine->query($query_string, 0, 1); - $fields = array(); + $fields = []; $foundRecord = $results->getResults()->first(); $this->assertInstanceOf('\record_adapter', $foundRecord); foreach ($foundRecord->get_caption()->get_fields() as $field) { - $fields[$field->get_name()] = array( + $fields[$field->get_name()] = [ 'value' => $field->get_serialized_values() , 'separator' => ';' - ); + ]; } $found = false; @@ -768,5 +768,5 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA abstract public function testAutocomplete(); - abstract protected function updateIndex(array $stemms = array()); + abstract protected function updateIndex(array $stemms = []); } diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineLoggerTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineLoggerTest.php index 9c30d6115e..15ae573df7 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineLoggerTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineLoggerTest.php @@ -13,7 +13,7 @@ class SearchEngineLoggerTest extends \PhraseanetPHPUnitAbstract public function testLog() { $databox = self::$DI['collection']->get_databox(); - $coll_ids = array(self::$DI['collection']->get_coll_id()); + $coll_ids = [self::$DI['collection']->get_coll_id()]; $answers = 42; $query = \random::generatePassword(); diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineOptionsTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineOptionsTest.php index 78b69c4e96..32868cc3fd 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineOptionsTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineOptionsTest.php @@ -13,13 +13,13 @@ class SearchEngineOptionsTest extends \PhraseanetPHPUnitAbstract public function testSerialize() { $options = new SearchEngineOptions(self::$DI['app']); - $options->onCollections(array(self::$DI['collection'])); + $options->onCollections([self::$DI['collection']]); - $options->allowBusinessFieldsOn(array(self::$DI['collection'])); + $options->allowBusinessFieldsOn([self::$DI['collection']]); foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $field) { - $options->setFields(array($field)); - $options->setDateFields(array($field)); + $options->setFields([$field]); + $options->setDateFields([$field]); break; } @@ -48,13 +48,13 @@ class SearchEngineOptionsTest extends \PhraseanetPHPUnitAbstract $options = SearchEngineOptions::fromRequest(self::$DI['app'], $httpRequest); - $this->assertEquals(array(self::$DI['collection']), $options->getCollections()); - $this->assertEquals(array($field), $options->getFields()); + $this->assertEquals([self::$DI['collection']], $options->getCollections()); + $this->assertEquals([$field], $options->getFields()); $this->assertEquals('video', $options->getRecordType()); $this->assertEquals('1', $options->getSearchType()); $this->assertEquals('2012/12/21', $options->getMaxDate()->format('Y/m/d')); $this->assertEquals('2009/04/24', $options->getMinDate()->format('Y/m/d')); - $this->assertEquals(array($dateField), $options->getDateFields()); + $this->assertEquals([$dateField], $options->getDateFields()); $this->assertEquals('asc', $options->getSortOrder()); $this->assertEquals('topinambour', $options->getSortBy()); $this->assertEquals(true, $options->isStemmed()); @@ -73,13 +73,13 @@ class SearchEngineOptionsTest extends \PhraseanetPHPUnitAbstract $options = SearchEngineOptions::fromRequest(self::$DI['app'], $httpRequest); - $this->assertEquals(array(), $options->getCollections()); - $this->assertEquals(array(), $options->getFields()); + $this->assertEquals([], $options->getCollections()); + $this->assertEquals([], $options->getFields()); $this->assertEquals('video', $options->getRecordType()); $this->assertEquals('1', $options->getSearchType()); $this->assertEquals('2012/12/21', $options->getMaxDate()->format('Y/m/d')); $this->assertEquals('2009/04/24', $options->getMinDate()->format('Y/m/d')); - $this->assertEquals(array(), $options->getDateFields()); + $this->assertEquals([], $options->getDateFields()); $this->assertEquals('asc', $options->getSortOrder()); $this->assertEquals('topinambour', $options->getSortBy()); $this->assertEquals(true, $options->isStemmed()); @@ -93,13 +93,13 @@ class SearchEngineOptionsTest extends \PhraseanetPHPUnitAbstract { $options = SearchEngineOptions::fromRequest(self::$DI['app'], new Request()); - $this->assertEquals(array(), $options->getCollections()); - $this->assertEquals(array(), $options->getFields()); + $this->assertEquals([], $options->getCollections()); + $this->assertEquals([], $options->getFields()); $this->assertEquals(null, $options->getRecordType()); $this->assertEquals('0', $options->getSearchType()); $this->assertEquals(null, $options->getMaxDate()); $this->assertEquals(null, $options->getMinDate()); - $this->assertEquals(array(), $options->getDateFields()); + $this->assertEquals([], $options->getDateFields()); $this->assertEquals('desc', $options->getSortOrder()); $this->assertEquals(null, $options->getSortBy()); $this->assertEquals(false, $options->isStemmed()); @@ -123,10 +123,10 @@ class SearchEngineOptionsTest extends \PhraseanetPHPUnitAbstract $this->fail('Unable to get a field'); } - $data = array( - 'bases' => array(self::$DI['collection']->get_base_id()), - 'status' => array('4' => array('on' => array(self::$DI['collection']->get_databox()->get_sbas_id()))), - 'fields' => array($field->get_name()), + $data = [ + 'bases' => [self::$DI['collection']->get_base_id()], + 'status' => ['4' => ['on' => [self::$DI['collection']->get_databox()->get_sbas_id()]]], + 'fields' => [$field->get_name()], 'record_type' => 'video', 'search_type' => '1', 'date_min' => '2009/04/24', @@ -135,14 +135,14 @@ class SearchEngineOptionsTest extends \PhraseanetPHPUnitAbstract 'ord' => 'asc', 'sort' => 'topinambour', 'stemme' => 'true', - ); + ]; $dataWithoutBases = $data; unset($dataWithoutBases['bases']); - return array( - array(array(), $data, $field, $dateField), - array($data, array(), $field, $dateField), - ); + return [ + [[], $data, $field, $dateField], + [$data, [], $field, $dateField], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineResultTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineResultTest.php index 582b5d5f4e..3e13b9b124 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineResultTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineResultTest.php @@ -13,9 +13,9 @@ class SearchEngineResultTest extends \PhraseanetPHPUnitAbstract */ public function testBasic() { - $results = new ArrayCollection(array( + $results = new ArrayCollection([ self::$DI['record_24'] - )); + ]); $query = 'Gotainer'; $duration = 1 / 3; @@ -24,9 +24,9 @@ class SearchEngineResultTest extends \PhraseanetPHPUnitAbstract $total = 10000; $error = 'this is an error message'; $warning = 'this is a warning message'; - $suggestions = new ArrayCollection(array( + $suggestions = new ArrayCollection([ new SearchEngineSuggestion($query, 'Richard', 22) - )); + ]); $propositions = new ArrayCollection(); $indexes = 'new-index'; @@ -51,9 +51,9 @@ class SearchEngineResultTest extends \PhraseanetPHPUnitAbstract public function testWithOffsetStartAtZero() { - $results = new ArrayCollection(array( + $results = new ArrayCollection([ self::$DI['record_24'] - )); + ]); $query = 'Gotainer'; $duration = 1 / 3; @@ -62,9 +62,9 @@ class SearchEngineResultTest extends \PhraseanetPHPUnitAbstract $total = 10000; $error = 'this is an error message'; $warning = 'this is a warning message'; - $suggestions = new ArrayCollection(array( + $suggestions = new ArrayCollection([ new SearchEngineSuggestion($query, 'Richard', 22) - )); + ]); $propositions = new ArrayCollection(); $indexes = 'new-index'; diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineSuggestionTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineSuggestionTest.php index b1eb86186e..cc924b80a6 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineSuggestionTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineSuggestionTest.php @@ -40,7 +40,7 @@ class SearchEngineSuggestionTest extends \PhraseanetPHPUnitAbstract $hits = 35; $suggestion = new SearchEngineSuggestion($query, $words, $hits); - $this->assertEquals(array('query' => $words, 'hits' => 35), $suggestion->toArray()); + $this->assertEquals(['query' => $words, 'hits' => 35], $suggestion->toArray()); } public function testToArrayWithNullValue() @@ -50,6 +50,6 @@ class SearchEngineSuggestionTest extends \PhraseanetPHPUnitAbstract $hits = null; $suggestion = new SearchEngineSuggestion($query, $words, $hits); - $this->assertEquals(array('query' => $words, 'hits' => null), $suggestion->toArray()); + $this->assertEquals(['query' => $words, 'hits' => null], $suggestion->toArray()); } } diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchEngineTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchEngineTest.php index 58a26eafd3..abcf9e602f 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchEngineTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchEngineTest.php @@ -36,19 +36,19 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest $appbox = $app['phraseanet.appbox']; $configuration = $app['configuration']->getConfig(); - $configuration['main']['search-engine']['options'] = array( + $configuration['main']['search-engine']['options'] = [ 'host' => '127.0.0.1', 'port' => 9312, 'rt_host' => '127.0.0.1', 'rt_port' => 9306, - ); + ]; $app['configuration']->setConfig($configuration); self::$searchEngine = SphinxSearchEngine::create($app, $app['configuration']['main']['search-engine']['options']); self::$config = tempnam(sys_get_temp_dir(), 'tmp_sphinx.conf'); $configuration = self::$searchEngine->getConfigurationPanel()->getConfiguration(); - $configuration['date_fields'] = array(); + $configuration['date_fields'] = []; foreach ($appbox->get_databoxes() as $databox) { foreach ($databox->get_meta_structure() as $databox_field) { @@ -119,7 +119,7 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest { $record = self::$DI['record_24']; - $toupdate = array(); + $toupdate = []; foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) { try { @@ -130,11 +130,11 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest $meta_id = null; } - $toupdate[$field->get_id()] = array( + $toupdate[$field->get_id()] = [ 'meta_id' => $meta_id , 'meta_struct_id' => $field->get_id() , 'value' => 'jeanne, jeannine, jeannette, jean-pierre et jean claude' - ); + ]; break; } @@ -163,7 +163,7 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest } } - protected function updateIndex(array $stemms = array()) + protected function updateIndex(array $stemms = []) { return $this; } diff --git a/tests/Alchemy/Tests/Phrasea/Setup/AbstractSetupTester.php b/tests/Alchemy/Tests/Phrasea/Setup/AbstractSetupTester.php index e40dc50f27..2d38d25118 100644 --- a/tests/Alchemy/Tests/Phrasea/Setup/AbstractSetupTester.php +++ b/tests/Alchemy/Tests/Phrasea/Setup/AbstractSetupTester.php @@ -6,7 +6,7 @@ use Alchemy\Phrasea\Application; abstract class AbstractSetupTester extends \PHPUnit_Framework_TestCase { - private $tearDownHandlers = array(); + private $tearDownHandlers = []; public function tearDown() { diff --git a/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php b/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php index f6e920bd25..17aa912293 100644 --- a/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php +++ b/tests/Alchemy/Tests/Phrasea/Setup/Version/Migration/Migration38Test.php @@ -20,7 +20,7 @@ class Migration38Test extends AbstractSetupTester private function revert() { - foreach (array('binaries.yml.bkp', 'config.yml.bkp', 'connexions.yml.bkp', 'services.yml.bkp') as $backupFile) { + foreach (['binaries.yml.bkp', 'config.yml.bkp', 'connexions.yml.bkp', 'services.yml.bkp'] as $backupFile) { if (is_file(__DIR__ . '/../Probe/fixtures-3807/config/' . $backupFile)) { rename(__DIR__ . '/../Probe/fixtures-3807/config/' . $backupFile, __DIR__ . '/../Probe/fixtures-3807/config/' . substr($backupFile, 0, -4)); } @@ -56,24 +56,24 @@ class Migration38Test extends AbstractSetupTester $modified['main']['servername'] = 'http://sub.domain.tld/'; $modified['main']['maintenance'] = true; $modified['binaries']['test_binary'] = '/path/to/test/binary/file'; - $modified['main']['database'] = array_replace($modified['main']['database'], array( + $modified['main']['database'] = array_replace($modified['main']['database'], [ 'host' => 'sql-host', 'port' => '13306', 'user' => 'username', 'password' => 's3cr3t', 'dbname' => 'phrasea_db', - )); - $modified['main']['cache'] = array( + ]); + $modified['main']['cache'] = [ 'type' => 'MemcacheCache', - 'options' => array( + 'options' => [ 'host' => 'memcache-host', 'port' => 21211, - ) - ); - $modified['main']['opcodecache'] = array( + ] + ]; + $modified['main']['opcodecache'] = [ 'type' => 'ApcCache', - 'options' => array(), - ); + 'options' => [], + ]; $modified['border-manager']['enabled'] = false; return $modified; @@ -81,11 +81,11 @@ class Migration38Test extends AbstractSetupTester private function getCurrent() { - return array( - 'main' => array( + return [ + 'main' => [ 'servername' => 'http://local.phrasea/', 'maintenance' => false, - 'database' => array( + 'database' => [ 'host' => '127.0.0.1', 'port' => '3306', 'user' => 'root', @@ -93,71 +93,71 @@ class Migration38Test extends AbstractSetupTester 'dbname' => 'ab_test', 'driver' => 'pdo_mysql', 'charset' => 'UTF8', - ), - 'database-test' => array( + ], + 'database-test' => [ 'driver' => 'pdo_sqlite', 'path' => '/tmp/db.sqlite', 'charset' => 'UTF8', - ), + ], 'api-timers' => true, - 'cache' => array( + 'cache' => [ 'type' => 'ArrayCache', - 'options' => array( - ), - ), - 'opcodecache' => array( + 'options' => [ + ], + ], + 'opcodecache' => [ 'type' => 'ArrayCache', - 'options' => array( - ), - ), - 'search-engine' => array( + 'options' => [ + ], + ], + 'search-engine' => [ 'type' => 'Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine', - 'options' => array( - ), - ), - 'task-manager' => array( + 'options' => [ + ], + ], + 'task-manager' => [ 'options' => '', - ), + ], 'key' => null, - ), - 'binaries' => array( + ], + 'binaries' => [ 'legacy_binay' => '/path/to/legacy/binary', - ), - 'border-manager' => array( + ], + 'border-manager' => [ 'enabled' => true, - 'checkers' => array( - array( + 'checkers' => [ + [ 'type' => 'Checker\Sha256', 'enabled' => true, - ), - array( + ], + [ 'type' => 'Checker\UUID', 'enabled' => true, - ), - array( + ], + [ 'type' => 'Checker\Colorspace', 'enabled' => false, - 'options' => array( - 'colorspaces' => array( + 'options' => [ + 'colorspaces' => [ 'cmyk', 'grayscale', 'rgb', - ), - ), - ), - array( + ], + ], + ], + [ 'type' => 'Checker\Dimension', 'enabled' => false, - 'options' => array( + 'options' => [ 'width' => 80, 'height' => 160, - ), - ), - array( + ], + ], + [ 'type' => 'Checker\Extension', 'enabled' => false, - 'options' => array( - 'extensions' => array( + 'options' => [ + 'extensions' => [ 'jpg', 'jpeg', 'bmp', @@ -175,99 +175,99 @@ class Migration38Test extends AbstractSetupTester 'flv', 'mp3', 'mp2', - ), - ), - ), - array( + ], + ], + ], + [ 'type' => 'Checker\Filename', 'enabled' => false, - 'options' => array( + 'options' => [ 'sensitive' => true, - ), - ), - array( + ], + ], + [ 'type' => 'Checker\MediaType', 'enabled' => false, - 'options' => array( - 'mediatypes' => array( + 'options' => [ + 'mediatypes' => [ 'Audio', 'Document', 'Flash', 'Image', 'Video', - ), - ), - ), - ), - ), - 'authentication' => array( - 'auto-create' => array( - 'templates' => array( - ), - ), - 'captcha' => array( + ], + ], + ], + ], + ], + 'authentication' => [ + 'auto-create' => [ + 'templates' => [ + ], + ], + 'captcha' => [ 'enabled' => true, 'trials-before-display' => 9, - ), - 'providers' => array( - 'facebook' => array( + ], + 'providers' => [ + 'facebook' => [ 'enabled' => false, - 'options' => array( + 'options' => [ 'app-id' => '', 'secret' => '', - ), - ), - 'twitter' => array( + ], + ], + 'twitter' => [ 'enabled' => false, - 'options' => array( + 'options' => [ 'consumer-key' => '', 'consumer-secret' => '', - ), - ), - 'google-plus' => array( + ], + ], + 'google-plus' => [ 'enabled' => false, - 'options' => array( + 'options' => [ 'client-id' => '', 'client-secret' => '', - ), - ), - 'github' => array( + ], + ], + 'github' => [ 'enabled' => false, - 'options' => array( + 'options' => [ 'client-id' => '', 'client-secret' => '', - ), - ), - 'viadeo' => array( + ], + ], + 'viadeo' => [ 'enabled' => false, - 'options' => array( + 'options' => [ 'client-id' => '', 'client-secret' => '', - ), - ), - 'linkedin' => array( + ], + ], + 'linkedin' => [ 'enabled' => false, - 'options' => array( + 'options' => [ 'client-id' => '', 'client-secret' => '', - ), - ), - ), - ), - 'registration-fields' => array( - array( + ], + ], + ], + ], + 'registration-fields' => [ + [ 'name' => 'company', 'required' => true, - ), - array( + ], + [ 'name' => 'firstname', 'required' => true, - ), - array( + ], + [ 'name' => 'geonameid', 'required' => true, - ), - ), - ); + ], + ], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php index 17c154d2a0..53e0d3d512 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/ArchiveEditorTest.php @@ -8,15 +8,15 @@ class ArchiveEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' 0000 ', ' -', array() - ), - array(' +', [] + ], + [' 24 /path/to/hot/folder @@ -35,7 +35,7 @@ class ArchiveEditorTest extends EditorTestCase 0 0 42 -', array( +', [ 'base_id' => 24, 'hotfolder' => '/path/to/hot/folder', 'move_archived' => 1, @@ -43,9 +43,9 @@ class ArchiveEditorTest extends EditorTestCase 'delfolder' => 1, 'copy_spe' => 1, 'cold' => 77, - ) - ), - array(' + ] + ], + [' value @@ -59,9 +59,9 @@ class ArchiveEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php index 8b3d4c453f..e899302a2e 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/DefaultEditorTest.php @@ -8,24 +8,24 @@ class DefaultEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' ', ' -', array() - ), - array(' +', [] + ], + [' value ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php index 684b818b9d..e83a52f8d3 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php @@ -14,7 +14,7 @@ abstract class EditorTestCase extends \PhraseanetPHPUnitAbstract public function testThatUpdateXmlWithRequestThrowsABadRequestOnWrongXML() { $editor = $this->getEditor(); - $editor->updateXMLWithRequest(new Request(array(), array('xml' => 'invalid xml'))); + $editor->updateXMLWithRequest(new Request([], ['xml' => 'invalid xml'])); } /** @@ -23,7 +23,7 @@ abstract class EditorTestCase extends \PhraseanetPHPUnitAbstract public function testThatUpdateXmlWithRequestUpdates($expected, $xml, array $params) { $editor = $this->getEditor(); - $response = $editor->updateXMLWithRequest(new Request(array(), array_merge(array('xml' => $xml), $params))); + $response = $editor->updateXMLWithRequest(new Request([], array_merge(['xml' => $xml], $params))); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); $this->assertEquals($expected, $response->getContent()); } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php index 163698bfc3..3b9fb7e7b0 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpEditorTest.php @@ -8,24 +8,24 @@ class FtpEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' ', ' -', array() - ), - array(' +', [] + ], + [' 1234 5678 ', ' 128 -', array('proxy' => 1234, 'proxyport' => 5678) - ), - array(' +', ['proxy' => 1234, 'proxyport' => 5678] + ], + [' value @@ -34,9 +34,9 @@ class FtpEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php index 3726c1d3e7..850c702850 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/FtpPullEditorTest.php @@ -8,15 +8,15 @@ class FtpPullEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' 00 ', ' -', array() - ), - array(' +', [] + ], + [' 1234 5678 @@ -31,9 +31,9 @@ class FtpPullEditorTest extends EditorTestCase ', ' 1280021 -', array('proxy' => 1234, 'proxyport' => 5678, 'passive' => 1, 'ssl' => 1, 'password' => 'a password', 'user' => 'username', 'ftppath' => 'nice path', 'localpath' => 'path to the future', 'port' => 22, 'host' => 'example.com') - ), - array(' +', ['proxy' => 1234, 'proxyport' => 5678, 'passive' => 1, 'ssl' => 1, 'password' => 'a password', 'user' => 'username', 'ftppath' => 'nice path', 'localpath' => 'path to the future', 'port' => 22, 'host' => 'example.com'] + ], + [' value @@ -50,9 +50,9 @@ class FtpPullEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php index 29770982c7..0ac1a866c3 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/PhraseanetIndexerEditorTest.php @@ -8,15 +8,15 @@ class PhraseanetIndexerEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' 00 ', ' -', array() - ), - array(' +', [] + ], + [' cool-host 1234 @@ -34,7 +34,7 @@ class PhraseanetIndexerEditorTest extends EditorTestCase ', ' 2520000utf8 -', array( +', [ 'host' => 'cool-host', 'port' => 1234, 'base' => 'basename', @@ -48,9 +48,9 @@ class PhraseanetIndexerEditorTest extends EditorTestCase 'debugmask' => 256, 'stem' => 'stemvalue', 'sortempty' => 'asc', -) - ), - array(' +] + ], + [' value @@ -70,9 +70,9 @@ class PhraseanetIndexerEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php index 0db37c2578..1e3ca58d1f 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/RecordMoverEditorTest.php @@ -9,23 +9,23 @@ class RecordMoverEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' 0 ', ' -', array() - ), - array(' +', [] + ], + [' 1 ', ' 0 -', array('logsql' => 1) - ), - array(' +', ['logsql' => 1] + ], + [' value 0 @@ -33,9 +33,9 @@ class RecordMoverEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() @@ -57,7 +57,7 @@ class RecordMoverEditorTest extends EditorTestCase $this->markTestSkipped('Unable to get a databox'); } - $request = new Request(array(), array( + $request = new Request([], [ 'ACT' => $action, 'xml' => ' @@ -73,7 +73,7 @@ class RecordMoverEditorTest extends EditorTestCase ', - )); + ]); $editor = $this->getEditor(); $response = $editor->facility(self::$DI['app'], $request); @@ -82,6 +82,6 @@ class RecordMoverEditorTest extends EditorTestCase public function provideFacilityActions() { - return array(array('CALCTEST'), array('PLAYTEST'), array('CALCSQL')); + return [['CALCTEST'], ['PLAYTEST'], ['CALCSQL']]; } } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php index 683626a5f5..d29ae2a3e1 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/SubdefsEditorTest.php @@ -8,24 +8,24 @@ class SubdefsEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' 0 ', ' -', array() - ), - array(' +', [] + ], + [' 1 ', ' 0 -', array('embedded' => 1) - ), - array(' +', ['embedded' => 1] + ], + [' value 0 @@ -33,9 +33,9 @@ class SubdefsEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php index 7bfea2e631..5cd16f97f4 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/WriteMetadataEditorTest.php @@ -8,24 +8,24 @@ class WriteMetadataEditorTest extends EditorTestCase { public function provideDataForXMLUpdatesFromForm() { - return array( - array(' + return [ + [' 0 ', ' -', array() - ), - array(' +', [] + ], + [' 1 ', ' 0 -', array('cleardoc' => 1) - ), - array(' +', ['cleardoc' => 1] + ], + [' value 0 @@ -33,9 +33,9 @@ class WriteMetadataEditorTest extends EditorTestCase ', ' value -', array() - ), - ); +', [] + ], + ]; } protected function getEditor() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php index d8c610be54..dc6a737798 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/FactoryTest.php @@ -26,20 +26,20 @@ class FactoryTest extends \PHPUnit_Framework_TestCase public function provideValidClasses() { - return array( - array('Alchemy\Phrasea\TaskManager\Job\ArchiveJob'), - array('Alchemy\Phrasea\TaskManager\Job\BridgeJob'), - array('Alchemy\Phrasea\TaskManager\Job\NullJob'), - ); + return [ + ['Alchemy\Phrasea\TaskManager\Job\ArchiveJob'], + ['Alchemy\Phrasea\TaskManager\Job\BridgeJob'], + ['Alchemy\Phrasea\TaskManager\Job\NullJob'], + ]; } public function provideValidIds() { - return array( - array('Archive', 'Alchemy\Phrasea\TaskManager\Job\ArchiveJob'), - array('Bridge', 'Alchemy\Phrasea\TaskManager\Job\BridgeJob'), - array('Null', 'Alchemy\Phrasea\TaskManager\Job\NullJob'), - ); + return [ + ['Archive', 'Alchemy\Phrasea\TaskManager\Job\ArchiveJob'], + ['Bridge', 'Alchemy\Phrasea\TaskManager\Job\BridgeJob'], + ['Null', 'Alchemy\Phrasea\TaskManager\Job\NullJob'], + ]; } /** diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/LiveInformationTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/LiveInformationTest.php index d4202b249b..7105575f84 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/LiveInformationTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/LiveInformationTest.php @@ -15,18 +15,18 @@ class LiveInformationTest extends \PhraseanetPHPUnitAbstract $notifier->expects($this->once()) ->method('notify') ->with(Notifier::MESSAGE_INFORMATIONS) - ->will($this->returnValue(array( - 'manager' => array( + ->will($this->returnValue([ + 'manager' => [ 'process-id' => 1234, - ) - ))); + ] + ])); $live = new LiveInformation($this->createStatusMock(TaskManagerStatus::STATUS_STARTED), $notifier); - $expected = array( + $expected = [ 'configuration' => TaskManagerStatus::STATUS_STARTED, 'actual' => TaskManagerStatus::STATUS_STARTED, 'process-id' => 1234, - ); + ]; $this->assertEquals($expected, $live->getManager()); } @@ -39,11 +39,11 @@ class LiveInformationTest extends \PhraseanetPHPUnitAbstract ->will($this->returnValue(null)); $live = new LiveInformation($this->createStatusMock(TaskManagerStatus::STATUS_STARTED), $notifier); - $expected = array( + $expected = [ 'configuration' => TaskManagerStatus::STATUS_STARTED, 'actual' => TaskManagerStatus::STATUS_STOPPED, 'process-id' => null, - ); + ]; $this->assertEquals($expected, $live->getManager()); } @@ -59,24 +59,24 @@ class LiveInformationTest extends \PhraseanetPHPUnitAbstract $notifier->expects($this->once()) ->method('notify') ->with(Notifier::MESSAGE_INFORMATIONS) - ->will($this->returnValue(array( - 'manager' => array( + ->will($this->returnValue([ + 'manager' => [ 'process-id' => 1234, - ), - 'jobs' => array( - $task->getId() => array( + ], + 'jobs' => [ + $task->getId() => [ 'status' => Task::STATUS_STARTED, 'process-id' => 1235, - ) - ), - ))); + ] + ], + ])); $live = new LiveInformation($this->createStatusMock(TaskManagerStatus::STATUS_STARTED), $notifier); - $expected = array( + $expected = [ 'configuration' => Task::STATUS_STARTED, 'actual' => Task::STATUS_STARTED, 'process-id' => 1235, - ); + ]; $this->assertEquals($expected, $live->getTask($task)); } @@ -95,11 +95,11 @@ class LiveInformationTest extends \PhraseanetPHPUnitAbstract ->will($this->returnValue(null)); $live = new LiveInformation($this->createStatusMock(TaskManagerStatus::STATUS_STARTED), $notifier); - $expected = array( + $expected = [ 'configuration' => Task::STATUS_STARTED, 'actual' => Task::STATUS_STOPPED, 'process-id' => null, - ); + ]; $this->assertEquals($expected, $live->getTask($task)); } diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/NotifierTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/NotifierTest.php index 516431fb3f..9b3722c3ab 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/NotifierTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/NotifierTest.php @@ -27,14 +27,14 @@ class NotifierTest extends \PHPUnit_Framework_TestCase public function provideMessagesData() { - $managerData = array('manager' => array('process-id' => 1234), 'jobs' => array('24' => array('process-id' => 4567, 'status' => 'started'))); + $managerData = ['manager' => ['process-id' => 1234], 'jobs' => ['24' => ['process-id' => 4567, 'status' => 'started']]]; - return array( - array(Notifier::MESSAGE_CREATE, TaskManager::MESSAGE_PROCESS_UPDATE, json_encode(array('request' => TaskManager::MESSAGE_PROCESS_UPDATE, 'reply' => TaskManager::RESPONSE_OK)), TaskManager::RESPONSE_OK), - array(Notifier::MESSAGE_DELETE, TaskManager::MESSAGE_PROCESS_UPDATE, json_encode(array('request' => TaskManager::MESSAGE_PROCESS_UPDATE, 'reply' => TaskManager::RESPONSE_OK)), TaskManager::RESPONSE_OK), - array(Notifier::MESSAGE_UPDATE, TaskManager::MESSAGE_PROCESS_UPDATE, json_encode(array('request' => TaskManager::MESSAGE_PROCESS_UPDATE, 'reply' => TaskManager::RESPONSE_OK)), TaskManager::RESPONSE_OK), - array(Notifier::MESSAGE_INFORMATIONS, TaskManager::MESSAGE_STATE, json_encode(array('request' => TaskManager::MESSAGE_STATE, 'reply' => $managerData)), $managerData), - ); + return [ + [Notifier::MESSAGE_CREATE, TaskManager::MESSAGE_PROCESS_UPDATE, json_encode(['request' => TaskManager::MESSAGE_PROCESS_UPDATE, 'reply' => TaskManager::RESPONSE_OK]), TaskManager::RESPONSE_OK], + [Notifier::MESSAGE_DELETE, TaskManager::MESSAGE_PROCESS_UPDATE, json_encode(['request' => TaskManager::MESSAGE_PROCESS_UPDATE, 'reply' => TaskManager::RESPONSE_OK]), TaskManager::RESPONSE_OK], + [Notifier::MESSAGE_UPDATE, TaskManager::MESSAGE_PROCESS_UPDATE, json_encode(['request' => TaskManager::MESSAGE_PROCESS_UPDATE, 'reply' => TaskManager::RESPONSE_OK]), TaskManager::RESPONSE_OK], + [Notifier::MESSAGE_INFORMATIONS, TaskManager::MESSAGE_STATE, json_encode(['request' => TaskManager::MESSAGE_STATE, 'reply' => $managerData]), $managerData], + ]; } public function testNoresultsReturnNull() @@ -70,7 +70,7 @@ class NotifierTest extends \PHPUnit_Framework_TestCase $socket->expects($this->once()) ->method('recv') - ->will($this->returnValue(json_encode(array('request' => 'popo', 'reply' => array())))); + ->will($this->returnValue(json_encode(['request' => 'popo', 'reply' => []]))); $notifier = new Notifier($socket); $this->assertNull($notifier->notify(Notifier::MESSAGE_CREATE)); @@ -85,7 +85,7 @@ class NotifierTest extends \PHPUnit_Framework_TestCase $socket->expects($this->once()) ->method('recv') - ->will($this->returnValue(json_encode(array('request' => TaskManager::MESSAGE_PROCESS_UPDATE)))); + ->will($this->returnValue(json_encode(['request' => TaskManager::MESSAGE_PROCESS_UPDATE]))); $notifier = new Notifier($socket); $this->assertNull($notifier->notify(Notifier::MESSAGE_CREATE)); diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php index 70bc13b6dd..6dbd2a4f3c 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php @@ -24,16 +24,16 @@ class TaskManagerStatusTest extends \PHPUnit_Framework_TestCase public function provideInitialData() { - return array( - array(array()), - array(array('task-manager' => array())), - array(array('task-manager' => array('status' => TaskManagerStatus::STATUS_STARTED))), - array(array('task-manager' => array('status' => TaskManagerStatus::STATUS_STOPPED))), - array(array('key1' => 'value1')), - array(array('task-manager' => array(), 'key2' => 'value2')), - array(array('task-manager' => array('status' => TaskManagerStatus::STATUS_STARTED, 'key3' => 'value3'), 'key4' => 'value4')), - array(array('task-manager' => array('status' => TaskManagerStatus::STATUS_STOPPED, 'key5' => 'value5'), 'key6' => 'value6')), - ); + return [ + [[]], + [['task-manager' => []]], + [['task-manager' => ['status' => TaskManagerStatus::STATUS_STARTED]]], + [['task-manager' => ['status' => TaskManagerStatus::STATUS_STOPPED]]], + [['key1' => 'value1']], + [['task-manager' => [], 'key2' => 'value2']], + [['task-manager' => ['status' => TaskManagerStatus::STATUS_STARTED, 'key3' => 'value3'], 'key4' => 'value4']], + [['task-manager' => ['status' => TaskManagerStatus::STATUS_STOPPED, 'key5' => 'value5'], 'key6' => 'value6']], + ]; } /** @@ -63,13 +63,13 @@ class TaskManagerStatusTest extends \PHPUnit_Framework_TestCase public function provideConfAndStatusData() { - return array( + return [ // array(array(), TaskManagerStatus::STATUS_STARTED, true), // array(array('task-manager' => array()), TaskManagerStatus::STATUS_STARTED, true), - array(array('task-manager' => array('status' => TaskManagerStatus::STATUS_STOPPED)), TaskManagerStatus::STATUS_STOPPED, false), + [['task-manager' => ['status' => TaskManagerStatus::STATUS_STOPPED]], TaskManagerStatus::STATUS_STOPPED, false], // array(array('task-manager' => array('status' => TaskManagerStatus::STATUS_STARTED)), TaskManagerStatus::STATUS_STARTED, true), // array(array('task-manager' => array('status' => 'unknown')), TaskManagerStatus::STATUS_STARTED, true), - ); + ]; } /** @@ -85,7 +85,7 @@ class TaskManagerStatusTest extends \PHPUnit_Framework_TestCase class ConfigurationTest implements ConfigurationInterface { - private $data = array(); + private $data = []; public function __construct(array $data) { diff --git a/tests/Alchemy/Tests/Phrasea/Twig/BytesConverterTest.php b/tests/Alchemy/Tests/Phrasea/Twig/BytesConverterTest.php index bd1dd4f55f..405ff639d4 100644 --- a/tests/Alchemy/Tests/Phrasea/Twig/BytesConverterTest.php +++ b/tests/Alchemy/Tests/Phrasea/Twig/BytesConverterTest.php @@ -17,15 +17,15 @@ class BytesConverterTest extends \PHPUnit_Framework_TestCase public function convertDataProvider() { - return array( - array('', 123456789012345, '112.28 TB'), - array('Auto', 123456789012345, '112.28 TB'), - array('Human', 123456789012345, '112.28 TB'), - array('KB', 123456789012345, '120563270519.87 KB'), - array('MB', 123456789012345, '117737568.87 MB'), - array('GB', 123456789012345, '114978.09 GB'), - array('TB', 123456789012345, '112.28 TB'), - array('PB', 123456789012345, '0.11 PB'), - ); + return [ + ['', 123456789012345, '112.28 TB'], + ['Auto', 123456789012345, '112.28 TB'], + ['Human', 123456789012345, '112.28 TB'], + ['KB', 123456789012345, '120563270519.87 KB'], + ['MB', 123456789012345, '117737568.87 MB'], + ['GB', 123456789012345, '114978.09 GB'], + ['TB', 123456789012345, '112.28 TB'], + ['PB', 123456789012345, '0.11 PB'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Utilities/ComposerSetupTest.php b/tests/Alchemy/Tests/Phrasea/Utilities/ComposerSetupTest.php index 109179f58a..3d1df873d3 100644 --- a/tests/Alchemy/Tests/Phrasea/Utilities/ComposerSetupTest.php +++ b/tests/Alchemy/Tests/Phrasea/Utilities/ComposerSetupTest.php @@ -23,7 +23,7 @@ class ComposerSetupTest extends \PHPUnit_Framework_TestCase $finder = new PhpExecutableFinder(); $php = $finder->find(); - $process = ProcessBuilder::create(array($php, $target, '--version'))->getProcess(); + $process = ProcessBuilder::create([$php, $target, '--version'])->getProcess(); $process->run(); $this->assertTrue($process->isSuccessful()); diff --git a/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php b/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php index 3623d42c2e..96a1225e67 100644 --- a/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php @@ -27,6 +27,6 @@ class BuilderTest extends \PHPUnit_Framework_TestCase $builder = new Builder($compiler, $filesystem); - $builder->build(array( __FILE__ => __DIR__ . '/output.css')); + $builder->build([ __FILE__ => __DIR__ . '/output.css']); } } diff --git a/tests/Alchemy/Tests/Phrasea/Utilities/String/CamelizerTest.php b/tests/Alchemy/Tests/Phrasea/Utilities/String/CamelizerTest.php index 902eb47ec4..ea725f8af8 100644 --- a/tests/Alchemy/Tests/Phrasea/Utilities/String/CamelizerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Utilities/String/CamelizerTest.php @@ -20,11 +20,11 @@ class CamelizerTest extends \PHPUnit_Framework_TestCase public function provideStrings() { - return array( - array('string-test', '-', 'stringTest', false), - array('string test', ' ', 'stringTest', false), - array('string_test', '_', 'stringTest', false), - array('string#test', '#', 'StringTest', true), - ); + return [ + ['string-test', '-', 'stringTest', false], + ['string test', ' ', 'stringTest', false], + ['string_test', '_', 'stringTest', false], + ['string#test', '#', 'StringTest', true], + ]; } } diff --git a/tests/classes/ACLTest.php b/tests/classes/ACLTest.php index 408396061e..fa36c34daf 100644 --- a/tests/classes/ACLTest.php +++ b/tests/classes/ACLTest.php @@ -31,7 +31,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract } self::giveRightsToUser($application, self::$DI['user']); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array(self::$DI['collection_no_access']->get_base_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([self::$DI['collection_no_access']->get_base_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->set_masks_on_base(self::$DI['collection_no_access_by_status']->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); parent::tearDownAfterClass(); @@ -66,7 +66,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $template = User_Adapter::create(self::$DI['app'], 'test_phpunit2', 'blabla2', 'test2@example.com', false); $template->set_template(self::$DI['user']); - $base_ids = array(); + $base_ids = []; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); @@ -97,7 +97,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $template = User_Adapter::create(self::$DI['app'], 'test_phpunit2', 'blabla2', 'test2@example.com', false); $template->set_template(self::$DI['user']); - $base_ids = array(); + $base_ids = []; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); @@ -123,7 +123,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract } foreach ($base_ids as $base_id) { - $this->assertEquals(array('dmin' => $limit_from, 'dmax' => $limit_to), self::$DI['app']['acl']->get($cobaye)->get_limits($base_id)); + $this->assertEquals(['dmin' => $limit_from, 'dmax' => $limit_to], self::$DI['app']['acl']->get($cobaye)->get_limits($base_id)); } $template->delete(); @@ -133,13 +133,13 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testRevoke_access_from_bases() { - $base_ids = array(); + $base_ids = []; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases([$base_id]); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); $base_ids[] = $base_id; } @@ -157,7 +157,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); } } @@ -168,7 +168,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); - $base_ids = array(); + $base_ids = []; foreach ($databox->get_collections() as $collection) { $base_ids[] = $collection->get_base_id(); } @@ -176,7 +176,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases($base_ids); self::$DI['app']['acl']->get(self::$DI['user'])->revoke_unused_sbas_rights(); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_sbas($sbas_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas(array($sbas_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas([$sbas_id]); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_sbas($sbas_id)); } } @@ -185,13 +185,13 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); - $base_ids = array(); + $base_ids = []; foreach ($databox->get_collections() as $collection) { $base_ids[] = $collection->get_base_id(); } self::$DI['app']['acl']->get(self::$DI['user'])->revoke_access_from_bases($base_ids); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas(array($sbas_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas([$sbas_id]); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_sbas($sbas_id)); self::$DI['app']['acl']->get(self::$DI['user'])->revoke_unused_sbas_rights(); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_sbas($sbas_id)); @@ -210,7 +210,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $base_id = $collection->get_base_id(); $droits = 50; $restes = 40; - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); self::$DI['app']['acl']->get(self::$DI['user'])->set_quotas_on_base($base_id, $droits, $restes); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->is_restricted_download($base_id)); @@ -233,10 +233,10 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); if ($first) { - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('imgtools' => true, 'chgstatus' => true, 'canaddrecord' => true, 'canputinalbum' => true)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['imgtools' => true, 'chgstatus' => true, 'canaddrecord' => true, 'canputinalbum' => true]); $base_ref = $base_id; } else { self::$DI['app']['acl']->get(self::$DI['user'])->duplicate_right_from_bas($base_ref, $base_id); @@ -263,23 +263,23 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testHas_right_on_base() { - $rights_false = array( + $rights_false = [ 'imgtools' => false , 'chgstatus' => false , 'canaddrecord' => false , 'canputinalbum' => false - ); + ]; - $rights_true = array( + $rights_true = [ 'imgtools' => true , 'chgstatus' => true , 'canaddrecord' => true - ); + ]; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, $rights_false); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_right_on_base($base_id, 'imgtools')); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_right_on_base($base_id, 'chgstatus')); @@ -315,12 +315,12 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract } $this->assertEquals(0, count($acl->get_order_master_collections())); - $tbas = array(); + $tbas = []; foreach ($appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $bid = $collection->get_base_id(); if (!$acl->has_access_to_base($bid)) { - $acl->give_access_to_base(array($bid)); + $acl->give_access_to_base([$bid]); } $acl->set_order_master($collection, true); $tbas[] = $bid; @@ -345,7 +345,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $base_id = $collection->get_base_id(); $droits = 50; $restes = 40; - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); self::$DI['app']['acl']->get(self::$DI['user'])->set_quotas_on_base($base_id, $droits, $restes); $this->assertEquals(40, self::$DI['app']['acl']->get(self::$DI['user'])->remaining_download($base_id)); @@ -365,7 +365,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $base_id = $collection->get_base_id(); $droits = 50; $restes = 40; - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); self::$DI['app']['acl']->get(self::$DI['user'])->set_quotas_on_base($base_id, $droits, $restes); $this->assertEquals(40, self::$DI['app']['acl']->get(self::$DI['user'])->remaining_download($base_id)); @@ -387,15 +387,15 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testHas_right() { - $rights = array( + $rights = [ 'bas_modify_struct' => true - ); + ]; $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_right('bas_modify_struct')); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_right('bas_modif_th')); foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas(array($databox->get_sbas_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas([$databox->get_sbas_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_sbas($databox->get_sbas_id(), $rights); break; } @@ -407,22 +407,22 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testHas_right_on_sbas() { - $rights_false = array( + $rights_false = [ 'bas_modify_struct' => false , 'bas_manage' => false , 'bas_chupub' => false , 'bas_modif_th' => false - ); + ]; - $rights_true = array( + $rights_true = [ 'bas_modify_struct' => true , 'bas_manage' => true , 'bas_chupub' => true , 'bas_modif_th' => true - ); + ]; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas(array($databox->get_sbas_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas([$databox->get_sbas_id()]); self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_sbas($databox->get_sbas_id(), $rights_false); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_right_on_sbas($databox->get_sbas_id(), 'bas_modify_struct')); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_right_on_sbas($databox->get_sbas_id(), 'bas_manage')); @@ -447,14 +447,14 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('actif' => false)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['actif' => false]); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_and($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('mask_and' => 42)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['mask_and' => 42]); $this->assertEquals('42', self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_and($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('mask_and' => 1)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['mask_and' => 1]); $this->assertEquals('1', self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_and($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('mask_and' => 0)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['mask_and' => 0]); $this->assertEquals('0', self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_and($base_id)); } } @@ -466,15 +466,15 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base(array($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('actif' => false)); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base([$base_id]); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['actif' => false]); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_xor($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('actif' => true)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('mask_xor' => 42)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['actif' => true]); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['mask_xor' => 42]); $this->assertEquals('42', self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_xor($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('mask_xor' => 1)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['mask_xor' => 1]); $this->assertEquals('1', self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_xor($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('mask_xor' => 0)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['mask_xor' => 0]); $this->assertEquals('0', self::$DI['app']['acl']->get(self::$DI['user'])->get_mask_xor($base_id)); } } @@ -482,14 +482,14 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testHas_access_to_base() { - $base_ids = array(); + $base_ids = []; $n = 0; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_ids[] = $collection->get_base_id(); $n ++; } - self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas(array($databox->get_sbas_id())); + self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_sbas([$databox->get_sbas_id()]); } if ($n === 0) @@ -504,26 +504,26 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); foreach ($bases as $base_id) { - $stmt->execute(array(':usr_id' => self::$DI['app']['authentication']->getUser()->get_id(), ':base_id' => $base_id)); + $stmt->execute([':usr_id' => self::$DI['app']['authentication']->getUser()->get_id(), ':base_id' => $base_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $this->assertEquals(1, $row['actif']); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('actif' => false)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['actif' => false]); - $stmt->execute(array(':usr_id' => self::$DI['app']['authentication']->getUser()->get_id(), ':base_id' => $base_id)); + $stmt->execute([':usr_id' => self::$DI['app']['authentication']->getUser()->get_id(), ':base_id' => $base_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $this->assertEquals(0, $row['actif']); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('actif' => true)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['actif' => true]); - $stmt->execute(array(':usr_id' => self::$DI['app']['authentication']->getUser()->get_id(), ':base_id' => $base_id)); + $stmt->execute([':usr_id' => self::$DI['app']['authentication']->getUser()->get_id(), ':base_id' => $base_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $this->assertEquals(1, $row['actif']); $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('actif' => false)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['actif' => false]); $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_base($base_id)); } self::$DI['app']['acl']->get(self::$DI['user'])->give_access_to_base($base_ids); @@ -537,7 +537,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_granted_base() { - $base_ids = array(); + $base_ids = []; $n = 0; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { @@ -569,7 +569,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_granted_sbas() { - $sbas_ids = array(); + $sbas_ids = []; $n = 0; foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $sbas_ids[] = $databox->get_sbas_id(); @@ -597,7 +597,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { - $base_ids = array(); + $base_ids = []; foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $base_ids[] = $base_id; @@ -619,7 +619,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $base_ids[] = $base_id; - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('canreport' => true)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['canreport' => true]); $found = true; break; } @@ -631,7 +631,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->assertFalse(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_module('upload')); foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_sbas($databox->get_sbas_id(), array('bas_modif_th' => true)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_sbas($databox->get_sbas_id(), ['bas_modif_th' => true]); $found = true; } $this->assertTrue(self::$DI['app']['acl']->get(self::$DI['user'])->has_access_to_module('report')); @@ -643,7 +643,7 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); $base_ids[] = $base_id; - self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, array('canaddrecord' => true)); + self::$DI['app']['acl']->get(self::$DI['user'])->update_rights_to_base($base_id, ['canaddrecord' => true]); $found = true; break; } diff --git a/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php b/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php index ffb9ba05f4..bfeaf5a74f 100644 --- a/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php +++ b/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_AbstractTest.php @@ -8,7 +8,7 @@ class Bridge_Api_Auth_AbstractTest extends PHPUnit_Framework_TestCase public function testSet_settings() { $stub = $this->getMockForAbstractClass('Bridge_Api_Auth_Abstract'); - $setting = $this->getMock("Bridge_AccountSettings", array(), array(), '', false); + $setting = $this->getMock("Bridge_AccountSettings", [], [], '', false); $return = $stub->set_settings($setting); $this->assertEquals($stub, $return); } diff --git a/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php b/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php index a839f7dc59..42c73460a9 100644 --- a/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php +++ b/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_FlickrTest.php @@ -25,7 +25,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testConnect() { - $api = $this->getMock("Phlickr_Api", array(), array(), "", false); + $api = $this->getMock("Phlickr_Api", [], [], "", false); //mock api method $api->expects($this->once()) ->method("setAuthTokenFromFrob") @@ -39,7 +39,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase ->method("isAuthValid") ->will($this->returnValue(true)); - $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api")); + $stub = $this->getMock("Bridge_Api_Auth_Flickr", ["get_api"]); $stub->expects($this->any()) ->method("get_api") @@ -54,7 +54,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testBadConnect() { - $api = $this->getMock("Phlickr_Api", array(), array(), "", false); + $api = $this->getMock("Phlickr_Api", [], [], "", false); //mock api method $api->expects($this->once()) ->method("setAuthTokenFromFrob") @@ -64,7 +64,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase ->method("isAuthValid") ->will($this->returnValue(false)); - $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api")); + $stub = $this->getMock("Bridge_Api_Auth_Flickr", ["get_api"]); $stub->expects($this->any()) ->method("get_api") @@ -82,7 +82,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testDisconnect() { - $setting = $this->getMock("Bridge_AccountSettings", array("set"), array(), "", false); + $setting = $this->getMock("Bridge_AccountSettings", ["set"], [], "", false); $setting->expects($this->once()) ->method("set") @@ -97,7 +97,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testIs_connected() { - $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false); + $setting = $this->getMock("Bridge_AccountSettings", ["get"], [], "", false); $setting->expects($this->any()) ->method("get") @@ -113,7 +113,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testGet_auth_signatures() { - $setting = $this->getMock("Bridge_AccountSettings", array("get"), array(), "", false); + $setting = $this->getMock("Bridge_AccountSettings", ["get"], [], "", false); $setting->expects($this->once()) ->method("get") @@ -131,12 +131,12 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testSet_parameters() { - $parameters = array( + $parameters = [ "caca" => "boudain" , "sirop" => "fraise" , "choco" => "banane" , "pirouette" => "cacahuete" - ); + ]; $return = $this->object->set_parameters($parameters); @@ -146,7 +146,7 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase public function testGet_auth_url() { - $api = $this->getMock("Phlickr_Api", array(), array(), "", false); + $api = $this->getMock("Phlickr_Api", [], [], "", false); //mock api method $api->expects($this->any()) ->method("requestFrob") @@ -157,13 +157,13 @@ class Bridge_Api_Auth_FlickrTest extends PHPUnit_Framework_TestCase ->with($this->equalTo("write"), $this->equalTo("un_token")) ->will($this->returnValue("une_super_url")); - $stub = $this->getMock("Bridge_Api_Auth_Flickr", array("get_api")); + $stub = $this->getMock("Bridge_Api_Auth_Flickr", ["get_api"]); $stub->expects($this->any()) ->method("get_api") ->will($this->returnValue($api)); - $params = array("permissions" => "write"); + $params = ["permissions" => "write"]; $stub->set_parameters($params); diff --git a/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php b/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php index 93a6ee7714..eba1175e55 100644 --- a/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php +++ b/tests/classes/Bridge/Api/Auth/Bridge_Api_Auth_OAuth2Test.php @@ -15,7 +15,7 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase { $this->object = new Bridge_Api_Auth_OAuth2(); - $this->parameters = array( + $this->parameters = [ 'client_id' => "client_id" , 'client_secret' => "client_secret" , 'redirect_uri' => "redirect_uri" @@ -23,15 +23,15 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase , 'response_type' => 'code' , 'token_endpoint' => "one_token_endpoint" , 'auth_endpoint' => "one_auth_endpoint" - ); + ]; - $this->mockSettings = $this->getMock("Bridge_AccountSettings", array("get", "set"), array(), "", false); + $this->mockSettings = $this->getMock("Bridge_AccountSettings", ["get", "set"], [], "", false); } public function testParse_request_token() { $this->object->set_parameters($this->parameters); - $_GET = array("code" => "12345"); + $_GET = ["code" => "12345"]; $token = $this->object->parse_request_token(); $this->assertEquals("12345", $token); $this->parameters["response_type"] = "blabla"; @@ -105,12 +105,12 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase public function testSet_parameters() { - $parameters = array( + $parameters = [ "client_id" => "cid" , "allo" => "hello" , "yo" => "coucou" , "response_type" => "hihi" - ); + ]; $return = $this->object->set_parameters($parameters); @@ -124,10 +124,10 @@ class Bridge_Api_Auth_OAuth2Test extends PHPUnit_Framework_TestCase $expected_url = "one_auth_endpoint?response_type=code&client_id=client_id&redirect_uri=redirect_uri&scope=super_scope"; $this->assertEquals($expected_url, $this->object->get_auth_url()); - $more_params = array("test" => "test"); + $more_params = ["test" => "test"]; $this->assertEquals($expected_url . "&test=test", $this->object->get_auth_url($more_params)); - $more_params = array("response_type" => "test"); + $more_params = ["response_type" => "test"]; $this->assertNotEquals($expected_url, $this->object->get_auth_url($more_params)); } } diff --git a/tests/classes/Bridge/Api/Bridge_Api_AbstractCollectionTest.php b/tests/classes/Bridge/Api/Bridge_Api_AbstractCollectionTest.php index 94b85c0bda..ea9b4127db 100644 --- a/tests/classes/Bridge/Api/Bridge_Api_AbstractCollectionTest.php +++ b/tests/classes/Bridge/Api/Bridge_Api_AbstractCollectionTest.php @@ -116,6 +116,6 @@ class Bridge_Api_AbstractCollectionTest extends PHPUnit_Framework_TestCase public function testGet_elements() { $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $this->stub->get_elements()); - $this->assertEquals(array(), $this->stub->get_elements()); + $this->assertEquals([], $this->stub->get_elements()); } } diff --git a/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php b/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php index d8de0b8f12..21a3280407 100644 --- a/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php +++ b/tests/classes/Bridge/Api/Bridge_Api_AbstractTest.php @@ -19,7 +19,7 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAbstract { parent::setUp(); $this->auth = $this->getMock("Bridge_Api_Auth_Interface"); - $this->bridgeApi = $this->getMock('Bridge_Api_Abstract', array("is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"), array(self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], $this->auth, "Mock_Bridge_Api_Abstract")); + $this->bridgeApi = $this->getMock('Bridge_Api_Abstract', ["is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"], [self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], $this->auth, "Mock_Bridge_Api_Abstract"]); } public static function setUpBeforeClass() @@ -71,11 +71,11 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAbstract ->will($this->returnValue("token")); $this->auth->expects($this->once()) ->method('connect') - ->will($this->returnValue(array("coucou"))); + ->will($this->returnValue(["coucou"])); $return = $this->bridgeApi->connect(); - $this->assertEquals(array("coucou"), $return); + $this->assertEquals(["coucou"], $return); } public function testConnectBad() @@ -174,7 +174,7 @@ class Bridge_Api_AbstractTest extends PhraseanetWebTestCaseAbstract $this->assertTrue($this->bridgeApi->is_valid_object_id("abc")); $this->assertTrue($this->bridgeApi->is_valid_object_id(123)); $this->assertTrue($this->bridgeApi->is_valid_object_id(12.25)); - $this->assertFalse($this->bridgeApi->is_valid_object_id(array())); + $this->assertFalse($this->bridgeApi->is_valid_object_id([])); $this->assertFalse($this->bridgeApi->is_valid_object_id(true)); } diff --git a/tests/classes/Bridge/Api/Bridge_Api_ElementCollectionTest.php b/tests/classes/Bridge/Api/Bridge_Api_ElementCollectionTest.php index 00767e2f0e..c81fd18ab7 100644 --- a/tests/classes/Bridge/Api/Bridge_Api_ElementCollectionTest.php +++ b/tests/classes/Bridge/Api/Bridge_Api_ElementCollectionTest.php @@ -7,7 +7,7 @@ class Bridge_Api_ElementCollectionTest extends PHPUnit_Framework_TestCase public function testAdd_element() { - $elements = array(); + $elements = []; $collection = new Bridge_Api_ElementCollection(); $i = 0; while ($i < 5) { diff --git a/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php b/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php index d0560d1c9e..f6c449be96 100644 --- a/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php +++ b/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ContainerTest.php @@ -11,11 +11,11 @@ class Bridge_Api_Dailymotion_ContainerTest extends PHPUnit_Framework_TestCase protected function setUp() { - $this->test = array( + $this->test = [ 'id' => '01234567' , 'description' => 'one description' , 'name' => 'hello container' - ); + ]; } public function testGet_created_on() diff --git a/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php b/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php index 46e66fa345..a1d3968810 100644 --- a/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php +++ b/tests/classes/Bridge/Api/Dailymotion/Bridge_Api_Dailymotion_ElementTest.php @@ -12,7 +12,7 @@ class Bridge_Api_Dailymotion_ElementTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->test = array( + $this->test = [ 'created_time' => time() , 'description' => 'Description of a dailymotion element' , 'id' => "1" @@ -25,7 +25,7 @@ class Bridge_Api_Dailymotion_ElementTest extends PHPUnit_Framework_TestCase , 'ratings_total' => '4' , 'duration' => 80 , 'channel' => 'animation' - ); + ]; } public function testGet_created_on() diff --git a/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php b/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php index 1aeadcc45f..fa4c276727 100644 --- a/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php +++ b/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ContainerTest.php @@ -20,7 +20,7 @@ class Bridge_Api_Youtube_ContainerTest extends PHPUnit_Framework_TestCase $entry->setTitle(new Zend_Gdata_App_Extension_Title("one title")); $entry->setUpdated($updated); $entry->setPublished($published); - $entry->setLink(array(new Zend_Gdata_App_Extension_link("one url", "alternate"))); + $entry->setLink([new Zend_Gdata_App_Extension_link("one url", "alternate")]); $entry->setDescription(new Zend_Gdata_App_Extension_Summary("one description")); $this->object = new Bridge_Api_Youtube_Container($entry, 'playlist', 'my_thumbnail'); } diff --git a/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php b/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php index d4df057e9c..c3d0021e87 100644 --- a/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php +++ b/tests/classes/Bridge/Api/Youtube/Bridge_Api_Youtube_ElementTest.php @@ -22,10 +22,10 @@ class Bridge_Api_Youtube_ElementTest extends PHPUnit_Framework_TestCase $stat->setViewCount("5"); $thumb = new Zend_Gdata_Media_Extension_MediaThumbnail('une url', '120', '90'); $media = new Zend_Gdata_YouTube_Extension_MediaGroup(); - $media->setPlayer(array($player)); + $media->setPlayer([$player]); $media->setDuration($duration); $media->setVideoId($id); - $media->setThumbnail(array($thumb)); + $media->setThumbnail([$thumb]); $entry = new Zend_Gdata_YouTube_VideoEntry(); $entry->setMajorProtocolVersion(2); $entry->setMediaGroup($media); @@ -34,7 +34,7 @@ class Bridge_Api_Youtube_ElementTest extends PHPUnit_Framework_TestCase $entry->setVideoCategory("category"); $entry->setVideoDescription("one description"); $entry->setVideoPrivate(); - $entry->setVideoTags(array('tags')); + $entry->setVideoTags(['tags']); $entry->setVideoTitle("hellow"); $entry->setUpdated($updated); $entry->setPublished($published); diff --git a/tests/classes/Doctrine/Repositories/ValidationParticipantRepositoryTest.php b/tests/classes/Doctrine/Repositories/ValidationParticipantRepositoryTest.php index aabda2d894..d8fa010af5 100644 --- a/tests/classes/Doctrine/Repositories/ValidationParticipantRepositoryTest.php +++ b/tests/classes/Doctrine/Repositories/ValidationParticipantRepositoryTest.php @@ -5,9 +5,9 @@ class ValidationParticipantRepositoryTest extends PhraseanetPHPUnitAuthenticated public function testFindNotConfirmedAndNotRemindedParticipants() { - $this->insertOneValidationBasket(array( + $this->insertOneValidationBasket([ 'expires' => new \DateTime('+1 days') - )); + ]); $em = self::$DI['app']['EM']; $repo = $em->getRepository('\Alchemy\Phrasea\Model\Entities\ValidationParticipant'); diff --git a/tests/classes/PhraseanetPHPUnitAbstract.php b/tests/classes/PhraseanetPHPUnitAbstract.php index 7c0d60a896..e0632de8ae 100644 --- a/tests/classes/PhraseanetPHPUnitAbstract.php +++ b/tests/classes/PhraseanetPHPUnitAbstract.php @@ -37,7 +37,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase * @var \Pimple */ public static $DI; - protected static $testsTime = array(); + protected static $testsTime = []; protected static $records; public static $recordsInitialized = false; @@ -217,7 +217,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase }); self::$DI['client'] = self::$DI->share(function ($DI) { - return new Client($DI['app'], array()); + return new Client($DI['app'], []); }); self::$DI['user']->purgePreferences(); @@ -299,7 +299,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$DI['app']['EM'], $purger); $executor->execute($fixtureLoader->getFixtures(), $append); self::$DI['client'] = self::$DI->share(function ($DI) { - return new Client($DI['app'], array()); + return new Client($DI['app'], []); }); } @@ -310,7 +310,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase { $purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger(); $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$DI['app']['EM'], $purger); - $executor->execute(array()); + $executor->execute([]); self::$DI['app']["phraseanet.cache-service"]->flushAll(); } @@ -325,7 +325,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $app->register(new \Silex\Provider\TwigServiceProvider()); $app->setupTwig(); self::$DI['client'] = self::$DI->share(function ($DI) use ($app) { - return new Client($app, array()); + return new Client($app, []); }); } @@ -612,7 +612,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase * * @return \Alchemy\Phrasea\Model\Entities\Basket */ - protected function insertOneValidationBasket(array $parameters = array()) + protected function insertOneValidationBasket(array $parameters = []) { $em = self::$DI['app']['EM']; @@ -672,7 +672,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $basket->setOwner(self::$DI['user']); self::$DI['app']['EM']->persist($basket); - foreach (array(self::$DI['record_1'], self::$DI['record_2']) as $record) { + foreach ([self::$DI['record_1'], self::$DI['record_2']] as $record) { $basketElement = new BasketElement(); $basketElement->setRecord($record); $basketElement->setBasket($basket); @@ -688,7 +688,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $validationSession->setExpires($expires); $validationSession->setInitiator(self::$DI['user']); - foreach (array(self::$DI['user_alt1'], self::$DI['user_alt2']) as $user) { + foreach ([self::$DI['user_alt1'], self::$DI['user_alt2']] as $user) { $validationParticipant = new ValidationParticipant(); $validationParticipant->setUser($user); $validationParticipant->setSession($validationSession); @@ -766,12 +766,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase * * @return Crawler */ - protected function XMLHTTPRequest($method, $uri, array $parameters = array(), $httpAccept = 'application/json') + protected function XMLHTTPRequest($method, $uri, array $parameters = [], $httpAccept = 'application/json') { - return self::$DI['client']->request($method, $uri, $parameters, array(), array( + return self::$DI['client']->request($method, $uri, $parameters, [], [ 'HTTP_ACCEPT' => $httpAccept, 'HTTP_X-Requested-With' => 'XMLHttpRequest', - )); + ]); } /** @@ -880,22 +880,22 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { - $rights = array( + $rights = [ 'bas_manage' => '1' , 'bas_modify_struct' => '1' , 'bas_modif_th' => '1' , 'bas_chupub' => '1' - ); + ]; $app['acl']->get($user)->update_rights_to_sbas($databox->get_sbas_id(), $rights); foreach ($databox->get_collections() as $collection) { $base_id = $collection->get_base_id(); - $app['acl']->get($user)->give_access_to_base(array($base_id)); - $app['acl']->get($user)->update_rights_to_base($base_id, array('order_master' => true)); + $app['acl']->get($user)->give_access_to_base([$base_id]); + $app['acl']->get($user)->update_rights_to_base($base_id, ['order_master' => true]); - $rights = array( + $rights = [ 'canputinalbum' => '1' , 'candwnldhd' => '1' , 'candwnldsubdef' => '1' @@ -915,7 +915,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase , 'modify_struct' => '1' , 'manage' => '1' , 'bas_modify_struct' => '1' - ); + ]; $app['acl']->get($user)->update_rights_to_base($collection->get_base_id(), $rights); } @@ -963,8 +963,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $DI['user'] = $DI->share( $DI->extend('user', function ($user, $DI) use ($collection_no_acces) { - $DI['app']['acl']->get($user)->revoke_access_from_bases(array($collection_no_acces->get_base_id())); - $DI['client'] = new Client($DI['app'], array()); + $DI['app']['acl']->get($user)->revoke_access_from_bases([$collection_no_acces->get_base_id()]); + $DI['client'] = new Client($DI['app'], []); return $user; }) @@ -983,7 +983,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $DI['user'] = $DI->share( $DI->extend('user', function ($user, $DI) use ($collection_no_acces_by_status) { $DI['app']['acl']->get($user)->set_masks_on_base($collection_no_acces_by_status->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); - $DI['client'] = new Client($DI['app'], array()); + $DI['client'] = new Client($DI['app'], []); return $user; }) @@ -1006,7 +1006,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $logger = new \Monolog\Logger('tests'); $logger->pushHandler(new \Monolog\Handler\NullHandler()); - self::$recordsInitialized = array(); + self::$recordsInitialized = []; $resolvePathfile = function ($i) { $finder = new Symfony\Component\Finder\Finder(); @@ -1110,7 +1110,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase self::$DI['record_' . $i]->delete(); } - self::$recordsInitialized = array(); + self::$recordsInitialized = []; } return; @@ -1174,7 +1174,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase public function createRandomMock() { return $this->getMockBuilder('\random') - ->setMethods(array('generatePassword')) + ->setMethods(['generatePassword']) ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/classes/PhraseanetPHPUnitListener.php b/tests/classes/PhraseanetPHPUnitListener.php index 3e8c0cb2d1..03d203cb71 100644 --- a/tests/classes/PhraseanetPHPUnitListener.php +++ b/tests/classes/PhraseanetPHPUnitListener.php @@ -2,7 +2,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener { - private static $skipped = array(); + private static $skipped = []; public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) { @@ -33,7 +33,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener public static function resetSkipped() { - static::$skipped = array(); + static::$skipped = []; return; } diff --git a/tests/classes/PhraseanetWebTestCaseAuthenticatedAbstract.php b/tests/classes/PhraseanetWebTestCaseAuthenticatedAbstract.php index 79248d7f40..cd5f1cb09e 100644 --- a/tests/classes/PhraseanetWebTestCaseAuthenticatedAbstract.php +++ b/tests/classes/PhraseanetWebTestCaseAuthenticatedAbstract.php @@ -7,7 +7,7 @@ use Symfony\Component\DomCrawler\Crawler; abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPUnitAuthenticatedAbstract { protected $StubbedACL; - protected static $createdDataboxes = array(); + protected static $createdDataboxes = []; public function setUp() { @@ -21,7 +21,7 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU public function setAdmin($bool) { $stubAuthenticatedUser = $this->getMockBuilder('\User_Adapter')//, array('is_admin', 'ACL'), array(self::$DI['app']['authentication']->getUser()->get_id(), self::$DI['app'])) - ->setMethods(array('get_id')) + ->setMethods(['get_id']) ->disableOriginalConstructor() ->getMock(); @@ -67,11 +67,11 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU $this->StubbedACL->expects($this->any()) ->method('get_granted_base') - ->will($this->returnValue(array(self::$DI['collection']))); + ->will($this->returnValue([self::$DI['collection']])); $this->StubbedACL->expects($this->any()) ->method('get_granted_sbas') - ->will($this->returnValue(array(self::$DI['collection']->get_databox()))); + ->will($this->returnValue([self::$DI['collection']->get_databox()])); $aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider') ->disableOriginalConstructor() @@ -90,7 +90,7 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU self::$DI['app']['authentication']->setUser($stubAuthenticatedUser); self::$DI['client'] = self::$DI->share(function ($DI) { - return new Client($DI['app'], array()); + return new Client($DI['app'], []); }); } @@ -108,7 +108,7 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU $connexion['user'], $connexion['password'], 'unit_test_db', - array(), + [], false ); } catch (\PDOException $e) { @@ -122,12 +122,12 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU self::$createdDataboxes[] = $databox; - $rights = array( + $rights = [ 'bas_manage' => '1' , 'bas_modify_struct' => '1' , 'bas_modif_th' => '1' , 'bas_chupub' => '1' - ); + ]; self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())->update_rights_to_sbas($databox->get_sbas_id(), $rights); @@ -162,12 +162,12 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU public function provideFlashMessages() { - return array( - array('warning', 'Be careful !'), - array('error', 'An error occured'), - array('info', 'You need to do something more'), - array('success', "Success operation !"), - ); + return [ + ['warning', 'Be careful !'], + ['error', 'An error occured'], + ['info', 'You need to do something more'], + ['success', "Success operation !"], + ]; } protected function assertFormOrFlashError(Crawler $crawler, $quantity) diff --git a/tests/classes/Session/Session_LoggerTest.php b/tests/classes/Session/Session_LoggerTest.php index 97c4e720b5..1fc943eacf 100644 --- a/tests/classes/Session/Session_LoggerTest.php +++ b/tests/classes/Session/Session_LoggerTest.php @@ -37,11 +37,11 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract $sql = 'SELECT id FROM log WHERE sit_session = :ses_id AND usrid = :usr_id AND site = :site'; - $params = array( + $params = [ ':ses_id' => self::$DI['app']['session']->get('session_id') , ':usr_id' => self::$DI['app']['authentication']->getUser()->get_id() , ':site' => self::$DI['app']['configuration']['main']['key'] - ); + ]; $stmt = $this->databox->get_connection()->prepare($sql); $stmt->execute($params); @@ -56,11 +56,11 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract $sql = 'SELECT id FROM log WHERE sit_session = :ses_id AND usrid = :usr_id AND site = :site'; - $params = array( + $params = [ ':ses_id' => $ses_id , ':usr_id' => $usr_id , ':site' => self::$DI['app']['configuration']['main']['key'] - ); + ]; $stmt = $this->databox->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/tests/classes/api/oauthv2/api_oauthv2_ApplicationTest.php b/tests/classes/api/oauthv2/api_oauthv2_ApplicationTest.php index cca5f713f7..0242107a29 100644 --- a/tests/classes/api/oauthv2/api_oauthv2_ApplicationTest.php +++ b/tests/classes/api/oauthv2/api_oauthv2_ApplicationTest.php @@ -72,7 +72,7 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract public function testGet_type() { - $this->assertTrue(in_array($this->object->get_type(), array(API_OAuth2_Application::DESKTOP_TYPE, API_OAuth2_Application::WEB_TYPE))); + $this->assertTrue(in_array($this->object->get_type(), [API_OAuth2_Application::DESKTOP_TYPE, API_OAuth2_Application::WEB_TYPE])); } public function testGet_nonce() diff --git a/tests/classes/api/v1/api_v1_adapterTest.php b/tests/classes/api/v1/api_v1_adapterTest.php index 534694b31a..fc14583fc8 100644 --- a/tests/classes/api/v1/api_v1_adapterTest.php +++ b/tests/classes/api/v1/api_v1_adapterTest.php @@ -19,7 +19,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_error_code() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_error_code($request, 400); $this->assertTrue(is_array(json_decode($result->format(), true))); $this->assertEquals(400, $result->get_http_code()); @@ -53,7 +53,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_error_message() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_error_message($request, API_V1_result::ERROR_BAD_REQUEST, 'detaillage'); $this->assertTrue(is_array(json_decode($result->format(), true))); $this->assertEquals(400, $result->get_http_code()); @@ -92,7 +92,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_databoxes() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_databoxes($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -113,11 +113,11 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_record() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_record($request, self::$DI['record_1']->get_sbas_id(), "-40"); $this->assertEquals(400, $result->get_http_code()); - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_record($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -126,7 +126,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_databox_status() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $result = $this->object->get_databox_status($request, $databox->get_sbas_id()); $this->assertEquals(200, $result->get_http_code()); @@ -137,7 +137,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_databox_metadatas() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $result = $this->object->get_databox_metadatas($request, $databox->get_sbas_id()); $this->assertEquals(200, $result->get_http_code()); @@ -148,7 +148,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_databox_terms() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { $result = $this->object->get_databox_terms($request, $databox->get_sbas_id()); $this->assertEquals(200, $result->get_http_code()); @@ -163,7 +163,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $record = \record_adapter::createFromFile(BorderFile::buildFromPathfile(__DIR__ . '/../../../files/cestlafete.jpg', self::$DI['collection'], self::$DI['app']), self::$DI['app']); - $request = new Request(array('record_type' => "image", 'search_type' => 0), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(['record_type' => "image", 'search_type' => 0], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->search_records($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -186,7 +186,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSearch_withOffset() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->search_records($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -200,10 +200,10 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $total = $data['response']['total_results']; - $request = new Request(array( + $request = new Request([ 'offset_start' => 0, 'per_page' => 1, - ), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + ], [], [], [], [], ['HTTP_Accept' => 'application/json']); $resultData1 = $this->object->search_records($request); $data = json_decode($resultData1->format(), true); @@ -211,10 +211,10 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->assertCount(1, $data['response']['results']); $result1 = array_pop($data['response']['results']); - $request = new Request(array( + $request = new Request([ 'offset_start' => 1, 'per_page' => 1, - ), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + ], [], [], [], [], ['HTTP_Accept' => 'application/json']); $resultData2 = $this->object->search_records($request); $data = json_decode($resultData2->format(), true); @@ -226,10 +226,10 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->assertNotEquals($result1['record_id'], $result2['record_id']); // last item is last item - $request = new Request(array( + $request = new Request([ 'offset_start' => $total - 1, 'per_page' => 10, - ), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + ], [], [], [], [], ['HTTP_Accept' => 'application/json']); $resultData = $this->object->search_records($request); $data = json_decode($resultData->format(), true); @@ -247,7 +247,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $story->appendChild(self::$DI['record_1']); } - $request = new Request(array('search_type' => 1), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(['search_type' => 1], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->search_records($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -279,7 +279,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $story->appendChild(self::$DI['record_1']); } - $request = new Request(array('search_type' => 1), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(['search_type' => 1], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->search($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -310,7 +310,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $record = \record_adapter::createFromFile(BorderFile::buildFromPathfile(__DIR__ . '/../../../files/cestlafete.jpg', self::$DI['collection'], self::$DI['app']), self::$DI['app']); - $request = new Request(array('search_type' => 0), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(['search_type' => 0], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->search($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -349,7 +349,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract self::$DI['app']['EM']->flush($basketElement); - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_record_related($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -388,7 +388,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_record_metadatas() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_record_metadatas($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -399,7 +399,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract { $request = new Request(); - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_record_status($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -409,7 +409,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_record_embed() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_record_embed($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -419,11 +419,11 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSet_record_metadatas() { $databox = self::$DI['record_1']->get_databox(); - $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["salut" => "salut c'est la fete"], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->set_record_metadatas($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(400, $result->get_http_code()); - $request = new Request(array("metadatas" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["metadatas" => "salut c'est la fete"], [], [], [], [], ['HTTP_Accept' => 'application/json']); $this->object->set_record_metadatas($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(400, $result->get_http_code()); @@ -431,7 +431,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $caption_field_value = caption_Field_Value::create(self::$DI['app'], databox_field::get_instance(self::$DI['app'], $databox, 1), self::$DI['record_1'], 'my value'); } - $metadatas = array(); + $metadatas = []; foreach (self::$DI['record_1']->get_databox()->get_meta_structure()->get_elements() as $field) { try { @@ -442,14 +442,14 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $meta_id = null; } - $metadatas[] = array( + $metadatas[] = [ 'meta_id' => $meta_id , 'meta_struct_id' => $field->get_id() , 'value' => 'poOM POOM TCHOK ' . $field->get_id() - ); + ]; } - $request = new Request(array("metadatas" => $metadatas), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["metadatas" => $metadatas], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->set_record_metadatas($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); @@ -463,7 +463,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSet_record_status() { $app = self::$DI['app']; - $stub = $this->getMock("API_V1_adapter", array("list_record_status"), array($app)); + $stub = $this->getMock("API_V1_adapter", ["list_record_status"], [$app]); $databox = self::$DI['record_1']->get_databox(); $statusbit = null; @@ -476,17 +476,17 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->markTestSkipped('No status bit defined in databox'); } - $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["salut" => "salut c'est la fete"], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $stub->set_record_status($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(400, $result->get_http_code()); - $request = new Request(array("status" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["status" => "salut c'est la fete"], [], [], [], [], ['HTTP_Accept' => 'application/json']); $stub->set_record_status($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(400, $result->get_http_code()); - $status = array($statusbit => '1'); + $status = [$statusbit => '1']; - $request = new Request(array("status" => $status), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["status" => $status], [], [], [], [], ['HTTP_Accept' => 'application/json']); //check method use record->get_caption $stub->expects($this->once()) ->method("list_record_status") @@ -499,10 +499,10 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSet_record_collection() { $app = self::$DI['app']; - $stub = $this->getMock("API_V1_adapter", array("list_record"), array($app)); + $stub = $this->getMock("API_V1_adapter", ["list_record"], [$app]); $databox = self::$DI['record_1']->get_databox(); - $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["salut" => "salut c'est la fete"], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $stub->set_record_collection($request, self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id()); $this->assertEquals(400, $result->get_http_code()); @@ -513,7 +513,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $collection = array_shift($collections); - $request = new Request(array("base_id" => $collection->get_base_id()), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request(["base_id" => $collection->get_base_id()], [], [], [], [], ['HTTP_Accept' => 'application/json']); //check method use record->get_caption $stub->expects($this->once()) ->method("list_record") @@ -536,7 +536,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSearch_baskets() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->search_baskets($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -545,7 +545,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testCreate_basket() { - $request = new Request(array(), array(), array('name' => 'BIG BASKET'), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], ['name' => 'BIG BASKET'], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->create_basket($request); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -578,7 +578,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $em->persist($Basket); $em->flush(); - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->delete_basket($request, $Basket); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -599,7 +599,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $basket = $this->insertOneBasket(); - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->get_basket($request, $basket); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -612,7 +612,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $basket = $this->insertOneBasket(); - $request = new Request(array(), array(), array('name' => 'PROUTO'), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], ['name' => 'PROUTO'], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->set_basket_title($request, $basket); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -631,7 +631,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $basket = $this->insertOneBasket(); - $request = new Request(array(), array(), array('description' => 'une belle description'), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], ['description' => 'une belle description'], [], [], ['HTTP_Accept' => 'application/json']); $result = $this->object->set_basket_description($request, $basket); $this->assertEquals(200, $result->get_http_code()); $this->assertEquals('application/json', $result->get_content_type()); @@ -646,7 +646,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testSearch_publications() { - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $feed = $this->insertOneFeed(self::$DI['user']); $result = $this->object->search_publications($request, self::$DI['user']); $this->checkResponseField($result, "feeds", 'array'); @@ -667,7 +667,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract ->getMock(); $date = new DateTime(); - $request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); + $request = new Request([], [], [], [], [], ['HTTP_Accept' => 'application/json']); $feedItem = $this->insertOneFeedItem(self::$DI['user']); $feed = $feedItem->getEntry()->getFeed(); diff --git a/tests/classes/api/v1/api_v1_resultTest.php b/tests/classes/api/v1/api_v1_resultTest.php index f9b742a553..5271553da7 100644 --- a/tests/classes/api/v1/api_v1_resultTest.php +++ b/tests/classes/api/v1/api_v1_resultTest.php @@ -21,7 +21,7 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract $conf['main']['api-timers'] = true; self::$DI['app']['configuration']->setConfig($conf); - $this->api = $this->getMock("API_V1_adapter", array("get_version"), array(), "", false); + $this->api = $this->getMock("API_V1_adapter", ["get_version"], [], "", false); $this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0")); } @@ -34,14 +34,14 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testFormatJson() { - $server = array( + $server = [ "HTTP_ACCEPT" => "application/json" , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename' , "REQUEST_URI" => "my/base/path/my/request/uri" , 'PHP_SELF' => 'my/base/path' - ); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + ]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $return = $api_result->format(); @@ -97,14 +97,14 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testFormatYaml() { - $server = array( + $server = [ "HTTP_ACCEPT" => "application/yaml" , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename' , "REQUEST_URI" => "my/base/path/my/request/uri" , 'PHP_SELF' => 'my/base/path' - ); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + ]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $return = $api_result->format(); @@ -147,14 +147,14 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testFormatJsonP() { - $server = array( + $server = [ "HTTP_ACCEPT" => "application/yaml" , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename' , "REQUEST_URI" => "my/base/path/my/request/uri" , 'PHP_SELF' => 'my/base/path' - ); - $request = new Request(array("callback" => "my_callback_function"), array(), array(), array(), array(), $server); + ]; + $request = new Request(["callback" => "my_callback_function"], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $return = $api_result->format(); @@ -175,35 +175,35 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract */ public function testSet_datas() { - $server = array( + $server = [ "HTTP_ACCEPT" => "application/json" , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename' , "REQUEST_URI" => "my/base/path/my/request/uri" , 'PHP_SELF' => 'my/base/path' - ); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + ]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); - $api_result->set_datas(array("pirouette" => "cacahuete", "black" => true, "bob" => array("bob"))); + $api_result->set_datas(["pirouette" => "cacahuete", "black" => true, "bob" => ["bob"]]); $response = json_decode($api_result->format()); $this->checkResponseFieldResponse($response, "pirouette", "cacahuete", PHPUnit_Framework_Constraint_IsType::TYPE_STRING); $this->checkResponseFieldResponse($response, "black", true, PHPUnit_Framework_Constraint_IsType::TYPE_BOOL); - $this->checkResponseFieldResponse($response, "bob", array("bob"), PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY); + $this->checkResponseFieldResponse($response, "bob", ["bob"], PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY); } public function testGet_datas() { - $server = array( + $server = [ "HTTP_ACCEPT" => "application/json" , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename' , "REQUEST_URI" => "my/base/path/my/request/uri" , 'PHP_SELF' => 'my/base/path' - ); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + ]; + $request = new Request(["callback" => ""], [], [], [], [], $server); - $data = array("pirouette" => "cacahuete", "black" => true, "bob" => array("bob")); + $data = ["pirouette" => "cacahuete", "black" => true, "bob" => ["bob"]]; $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $api_result->set_datas($data); @@ -212,16 +212,16 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_Emptydatas() { - $server = array( + $server = [ "HTTP_ACCEPT" => "application/json" , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename' , "REQUEST_URI" => "my/base/path/my/request/uri" , 'PHP_SELF' => 'my/base/path' - ); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + ]; + $request = new Request(["callback" => ""], [], [], [], [], $server); - $data = array(); + $data = []; $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $api_result->set_datas($data); @@ -244,28 +244,28 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_content_type() { - $server = array("HTTP_ACCEPT" => "application/json"); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + $server = ["HTTP_ACCEPT" => "application/json"]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $this->assertEquals("application/json", $api_result->get_content_type()); - $server = array("HTTP_ACCEPT" => "application/yaml"); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + $server = ["HTTP_ACCEPT" => "application/yaml"]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $this->assertEquals('application/yaml', $api_result->get_content_type()); - $server = array("HTTP_ACCEPT" => "text/yaml"); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + $server = ["HTTP_ACCEPT" => "text/yaml"]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $this->assertEquals('application/yaml', $api_result->get_content_type()); - $server = array("HTTP_ACCEPT" => ""); - $request = new Request(array("callback" => "hello"), array(), array(), array(), array(), $server); + $server = ["HTTP_ACCEPT" => ""]; + $request = new Request(["callback" => "hello"], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $this->assertEquals('text/javascript', $api_result->get_content_type()); - $server = array("HTTP_ACCEPT" => "unknow"); - $request = new Request(array("callback" => ""), array(), array(), array(), array(), $server); + $server = ["HTTP_ACCEPT" => "unknow"]; + $request = new Request(["callback" => ""], [], [], [], [], $server); $api_result = new API_V1_result(self::$DI['app'], $request, $this->api); $this->assertEquals("application/json", $api_result->get_content_type()); } @@ -387,11 +387,11 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract $api_result->set_error_code(500); $this->assertEquals(500, $api_result->get_http_code()); - $api_result = new API_V1_result(self::$DI['app'], new Request(array("callback" => "my_callback")), $this->api); + $api_result = new API_V1_result(self::$DI['app'], new Request(["callback" => "my_callback"]), $this->api); $api_result->set_error_code(400); $this->assertEquals(200, $api_result->get_http_code()); - $api_result = new API_V1_result(self::$DI['app'], new Request(array("callback" => "my_callback")), $this->api); + $api_result = new API_V1_result(self::$DI['app'], new Request(["callback" => "my_callback"]), $this->api); $api_result->set_error_code(500); $this->assertEquals(500, $api_result->get_http_code()); } @@ -409,7 +409,7 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract $api_result->set_http_code(403); $this->assertEquals(403, $api_result->get_http_code()); - $api_result = new API_V1_result(self::$DI['app'], new Request(array("callback" => "my_callback")), $this->api); + $api_result = new API_V1_result(self::$DI['app'], new Request(["callback" => "my_callback"]), $this->api); $api_result->set_http_code(500); $this->assertEquals(500, $api_result->get_http_code()); diff --git a/tests/classes/caption/caption_fieldTest.php b/tests/classes/caption/caption_fieldTest.php index 328d670f68..a476767142 100644 --- a/tests/classes/caption/caption_fieldTest.php +++ b/tests/classes/caption/caption_fieldTest.php @@ -13,17 +13,17 @@ class caption_fieldTest extends \PHPUnit_Framework_TestCase public function getMultiValues() { - return array( - array(';', 'arbre;fleur-chien maison', array('arbre', 'fleur-chien maison')), - array('-', 'arbre;fleur-chien maison', array('arbre;fleur', 'chien maison')), - array(';-', 'arbre;fleur-chien maison', array('arbre','fleur', 'chien maison')), - array(';- ', 'arbre;fleur-chien maison', array('arbre','fleur', 'chien', 'maison')), - array('/', 'arbre/fleur/chien maison', array('arbre','fleur', 'chien maison')), - array('\\', 'arbre\fleur\chien maison', array('arbre','fleur', 'chien maison')), - array('|', 'arbre|fleur|chien maison', array('arbre','fleur', 'chien maison')), - array(' ', 'arbre|fleur|chien maison', array('arbre|fleur|chien','maison')), - array(' ', 'arbre\fleur|chien maison', array('arbre\fleur|chien','maison')), - ); + return [ + [';', 'arbre;fleur-chien maison', ['arbre', 'fleur-chien maison']], + ['-', 'arbre;fleur-chien maison', ['arbre;fleur', 'chien maison']], + [';-', 'arbre;fleur-chien maison', ['arbre','fleur', 'chien maison']], + [';- ', 'arbre;fleur-chien maison', ['arbre','fleur', 'chien', 'maison']], + ['/', 'arbre/fleur/chien maison', ['arbre','fleur', 'chien maison']], + ['\\', 'arbre\fleur\chien maison', ['arbre','fleur', 'chien maison']], + ['|', 'arbre|fleur|chien maison', ['arbre','fleur', 'chien maison']], + [' ', 'arbre|fleur|chien maison', ['arbre|fleur|chien','maison']], + [' ', 'arbre\fleur|chien maison', ['arbre\fleur|chien','maison']], + ]; } } diff --git a/tests/classes/caption/caption_recordTest.php b/tests/classes/caption/caption_recordTest.php index 5879bfcad7..af1bec3869 100644 --- a/tests/classes/caption/caption_recordTest.php +++ b/tests/classes/caption/caption_recordTest.php @@ -37,7 +37,7 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract foreach (self::$DI['record_1']->get_caption()->get_fields() as $field) { if ($field->get_databox_field()->is_multi()) { $tagname = $field->get_name(); - $retrieved = array(); + $retrieved = []; foreach ($sxe->description->$tagname as $value) { $retrieved[] = (string) $value; } @@ -71,7 +71,7 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract foreach (self::$DI['record_1']->get_caption()->get_fields() as $field) { if ($field->get_databox_field()->is_multi()) { $tagname = $field->get_name(); - $retrieved = array(); + $retrieved = []; foreach ($json["record"]["description"][$tagname] as $value) { $retrieved[] = $value; } @@ -109,7 +109,7 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract foreach (self::$DI['record_1']->get_caption()->get_fields() as $field) { if ($field->get_databox_field()->is_multi()) { $tagname = $field->get_name(); - $retrieved = array(); + $retrieved = []; foreach ($yaml["record"]["description"][$tagname] as $value) { $retrieved[] = (string) $value; } @@ -177,13 +177,13 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract $captionField = self::$DI['record_1']->get_caption()->get_field($field->get_name()); if (!$captionField) { - self::$DI['record_1']->set_metadatas(array( - array( + self::$DI['record_1']->set_metadatas([ + [ 'meta_id' => null, 'meta_struct_id' => $field->get_id(), - 'value' => array('HELLO MO !'), - ) - )); + 'value' => ['HELLO MO !'], + ] + ]); $value = 'HELLO MO !'; } else { $value = $captionField->get_serialized_values(); diff --git a/tests/classes/databox/databox_descriptionStructureTest.php b/tests/classes/databox/databox_descriptionStructureTest.php index e7c48efbcd..d71929e5c8 100644 --- a/tests/classes/databox/databox_descriptionStructureTest.php +++ b/tests/classes/databox/databox_descriptionStructureTest.php @@ -6,7 +6,7 @@ class databox_descriptionStructureTest extends PhraseanetPHPUnitAbstract { $structure = new \databox_descriptionStructure(); - $array = array('name1' => 'value1', 'name2' => 'value2'); + $array = ['name1' => 'value1', 'name2' => 'value2']; $element = $this->provideDataboxFieldMock(); $element->expects($this->once()) @@ -15,7 +15,7 @@ class databox_descriptionStructureTest extends PhraseanetPHPUnitAbstract $structure->add_element($element); - $this->assertEquals(array($array), $structure->toArray()); + $this->assertEquals([$array], $structure->toArray()); } private function provideDataboxFieldMock() diff --git a/tests/classes/databox/databox_fieldTest.php b/tests/classes/databox/databox_fieldTest.php index 51f248c9b1..1d57f15e06 100644 --- a/tests/classes/databox/databox_fieldTest.php +++ b/tests/classes/databox/databox_fieldTest.php @@ -355,11 +355,11 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract public function provideLanguageCodes() { - $codes = array(); + $codes = []; foreach (Application::getAvailableLanguages() as $code => $language) { $data = explode('_', $code); - $codes[] = array($data[0]); + $codes[] = [$data[0]]; } return $codes; @@ -393,13 +393,13 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract { $AddedValue = 'scalar value'; - self::$DI['record_1']->set_metadatas(array( - array( + self::$DI['record_1']->set_metadatas([ + [ 'meta_id' => null, 'meta_struct_id' => $this->object_mono->get_id(), 'value' => $AddedValue - ) - )); + ] + ]); $this->object_mono->set_name('Bonobo yoyo')->save(); @@ -410,7 +410,7 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract public function testToArray() { - foreach (array($this->object_mono, $this->object_multi) as $object) { + foreach ([$this->object_mono, $this->object_multi] as $object) { $data = $object->toArray(); $this->assertInternalType('array', $data); diff --git a/tests/classes/databox/databox_subdefTest.php b/tests/classes/databox/databox_subdefTest.php index eafa36fdbf..1977331285 100644 --- a/tests/classes/databox/databox_subdefTest.php +++ b/tests/classes/databox/databox_subdefTest.php @@ -245,10 +245,10 @@ class databox_subdefTest extends PHPUnit_Framework_TestCase $typeDocument = new \Alchemy\Phrasea\Media\Type\Document(); $typeVideo = new \Alchemy\Phrasea\Media\Type\Video(); - return array( - array(new databox_subdef($typeAudio, simplexml_load_string($xmlImage))), - array(new databox_subdef($typeDocument, simplexml_load_string($xmlImage))), - array(new databox_subdef($typeVideo, simplexml_load_string($xmlImage))), - ); + return [ + [new databox_subdef($typeAudio, simplexml_load_string($xmlImage))], + [new databox_subdef($typeDocument, simplexml_load_string($xmlImage))], + [new databox_subdef($typeVideo, simplexml_load_string($xmlImage))], + ]; } } diff --git a/tests/classes/media/media_subdefTest.php b/tests/classes/media/media_subdefTest.php index 230d437d88..820da2709e 100644 --- a/tests/classes/media/media_subdefTest.php +++ b/tests/classes/media/media_subdefTest.php @@ -191,8 +191,8 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract */ public function testGet_name() { - $this->assertTrue(in_array(self::$objectPresent->get_name(), array('thumbnail', 'preview'))); - $this->assertTrue(in_array(self::$objectNotPresent->get_name(), array('thumbnail', 'preview'))); + $this->assertTrue(in_array(self::$objectPresent->get_name(), ['thumbnail', 'preview'])); + $this->assertTrue(in_array(self::$objectNotPresent->get_name(), ['thumbnail', 'preview'])); } /** @@ -304,6 +304,6 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract $this->assertArrayHasKey(media_subdef::TC_DATA_FILESIZE, $technical_datas); $technical_datas = self::$objectNotPresent->readTechnicalDatas(self::$DI['app']['mediavorus']); - $this->assertEquals(array(), $technical_datas); + $this->assertEquals([], $technical_datas); } } diff --git a/tests/classes/module/console/module_console_aboutAuthorsTest.php b/tests/classes/module/console/module_console_aboutAuthorsTest.php index f7b375265c..2838b72ac5 100644 --- a/tests/classes/module/console/module_console_aboutAuthorsTest.php +++ b/tests/classes/module/console/module_console_aboutAuthorsTest.php @@ -20,7 +20,7 @@ class module_console_aboutAuthorsTest extends PHPUnit_Framework_TestCase $command = $application['console']->find('about:authors'); $commandTester = new CommandTester($command); - $commandTester->execute(array('command' => $command->getName())); + $commandTester->execute(['command' => $command->getName()]); $this->assertEquals( trim(file_get_contents(__DIR__ . '/../../../../AUTHORS')) diff --git a/tests/classes/module/console/module_console_aboutLicenseTest.php b/tests/classes/module/console/module_console_aboutLicenseTest.php index 098a594a26..1cc643138c 100644 --- a/tests/classes/module/console/module_console_aboutLicenseTest.php +++ b/tests/classes/module/console/module_console_aboutLicenseTest.php @@ -20,7 +20,7 @@ class module_console_aboutLicenseTest extends PHPUnit_Framework_TestCase $command = $application['console']->find('about:license'); $commandTester = new CommandTester($command); - $commandTester->execute(array('command' => $command->getName())); + $commandTester->execute(['command' => $command->getName()]); $this->assertEquals( trim(file_get_contents(__DIR__ . '/../../../../LICENSE')) diff --git a/tests/classes/module/console/module_console_systemTemplateGeneratorTest.php b/tests/classes/module/console/module_console_systemTemplateGeneratorTest.php index fd0e36dec2..fa547790ad 100644 --- a/tests/classes/module/console/module_console_systemTemplateGeneratorTest.php +++ b/tests/classes/module/console/module_console_systemTemplateGeneratorTest.php @@ -13,7 +13,7 @@ class module_console_systemTemplateGeneratorTest extends PHPUnit_Framework_TestC $command = $application['console']->find('system:templateGenerator'); $commandTester = new CommandTester($command); - $commandTester->execute(array('command' => $command->getName())); + $commandTester->execute(['command' => $command->getName()]); $data = explode("\n", trim($commandTester->getDisplay())); $last_line = array_pop($data); diff --git a/tests/classes/p4stringTest.php b/tests/classes/p4stringTest.php index 56a8672427..c28dd2c326 100644 --- a/tests/classes/p4stringTest.php +++ b/tests/classes/p4stringTest.php @@ -99,14 +99,14 @@ class p4stringTest extends PhraseanetPHPUnitAbstract { $a = new stdClass(); $a->prout = 'pue'; - $a->couleur = array('marron', 'jaune'); - $a->compteur = array('incrémental' => true, 'fiente' => 'vrai'); + $a->couleur = ['marron', 'jaune']; + $a->compteur = ['incrémental' => true, 'fiente' => 'vrai']; $this->assertEquals('{"prout":"pue","couleur":["marron","jaune"],"compteur":{"incr\u00e9mental":true,"fiente":"vrai"}}', p4string::jsonencode($a)); - $b = array('un', 'petit' => 'tout petit', 'cul', 1 => 'qui', 10 => 'roule'); + $b = ['un', 'petit' => 'tout petit', 'cul', 1 => 'qui', 10 => 'roule']; $this->assertEquals('{"0":"un","petit":"tout petit","1":"qui","10":"roule"}', p4string::jsonencode($b)); - $c = array('gros', 'chien'); + $c = ['gros', 'chien']; $this->assertEquals('["gros","chien"]', p4string::jsonencode($c)); } diff --git a/tests/classes/record/adapterTest.php b/tests/classes/record/adapterTest.php index dbde6b8d84..e668d82603 100644 --- a/tests/classes/record/adapterTest.php +++ b/tests/classes/record/adapterTest.php @@ -56,9 +56,9 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $em->persist($basket); $em->flush(); - $receveid = array(self::$DI['record_1']->get_serialize_key() => self::$DI['record_1']); + $receveid = [self::$DI['record_1']->get_serialize_key() => self::$DI['record_1']]; - self::$DI['app']['acl']->get( self::$DI['app']['authentication']->getUser())->update_rights_to_base(self::$DI['record_1']->get_base_id(), array('order_master' => true)); + self::$DI['app']['acl']->get( self::$DI['app']['authentication']->getUser())->update_rights_to_base(self::$DI['record_1']->get_base_id(), ['order_master' => true]); $eventManagerStub = $this->getMockBuilder('\eventsmanager_broker') ->disableOriginalConstructor() @@ -71,10 +71,10 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract self::$DI['app']['events-manager'] = $eventManagerStub; - self::$DI['client']->request('POST', '/prod/order/', array( + self::$DI['client']->request('POST', '/prod/order/', [ 'lst' => self::$DI['record_1']->get_serialize_key(), 'deadline' => '+10 minutes' - )); + ]); } public function testGet_creation_date() @@ -183,7 +183,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_type() { - $this->assertTrue(in_array(self::$DI['record_1']->get_type(), array('video', 'audio', 'image', 'document', 'flash', 'unknown'))); + $this->assertTrue(in_array(self::$DI['record_1']->get_type(), ['video', 'audio', 'image', 'document', 'flash', 'unknown'])); } public function testGet_formated_duration() @@ -302,10 +302,10 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $current_caption = self::$DI['record_1']->get_caption(); - $metadatas = array(); + $metadatas = []; foreach ($meta_structure_el as $meta_el) { - $current_fields = $current_caption->get_fields(array($meta_el->get_name())); + $current_fields = $current_caption->get_fields([$meta_el->get_name()]); $field = null; @@ -316,34 +316,34 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract if ($meta_el->is_multi()) { if ($field) { foreach ($field->get_values() as $value) { - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => $value->getId() , 'value' => '' - ); + ]; } } - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => null , 'value' => 'un' - ); - $metadatas[] = array( + ]; + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => null , 'value' => 'jeu' - ); - $metadatas[] = array( + ]; + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => null , 'value' => 'de' - ); - $metadatas[] = array( + ]; + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => null , 'value' => 'test' - ); + ]; } else { $meta_id = null; @@ -352,17 +352,17 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $meta_id = array_pop($values)->getId(); } - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => $meta_id , 'value' => 'un premier jeu de test' - ); + ]; - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_el->get_id() , 'meta_id' => $meta_id , 'value' => 'un second jeu de test' - ); + ]; } } @@ -371,7 +371,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $caption = self::$DI['record_1']->get_caption(); foreach ($meta_structure_el as $meta_el) { - $current_fields = $caption->get_fields(array($meta_el->get_name()), true); + $current_fields = $caption->get_fields([$meta_el->get_name()], true); $this->assertEquals(1, count($current_fields)); $field = $current_fields[0]; @@ -384,10 +384,10 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract $separator = ''; } - $multi_imploded = implode(' ' . $separator . ' ', array('un', 'jeu', 'de', 'test')); + $multi_imploded = implode(' ' . $separator . ' ', ['un', 'jeu', 'de', 'test']); if ($meta_el->is_multi()) { - $initial_values = array(); + $initial_values = []; foreach ($field->get_values() as $value) { $initial_values[] = $value->getValue(); } @@ -409,7 +409,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract AND record_id = :record_id'; $stmt = self::$DI['record_1']->get_databox()->get_connection()->prepare($sql); - $stmt->execute(array(':record_id' => self::$DI['record_1']->get_record_id())); + $stmt->execute([':record_id' => self::$DI['record_1']->get_record_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -427,7 +427,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract AND record_id = :record_id'; $stmt = self::$DI['record_1']->get_databox()->get_connection()->prepare($sql); - $stmt->execute(array(':record_id' => self::$DI['record_1']->get_record_id())); + $stmt->execute([':record_id' => self::$DI['record_1']->get_record_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/tests/classes/registryTest.php b/tests/classes/registryTest.php index 6d6fe340ed..47aff67a4e 100644 --- a/tests/classes/registryTest.php +++ b/tests/classes/registryTest.php @@ -56,7 +56,7 @@ class registryTest extends PhraseanetPHPUnitAbstract $this->object->set('key_test', '1', registry::TYPE_INTEGER); $this->assertTrue($this->object->get('key_test') === 1); - $this->object->set('key_test', array('caca'), registry::TYPE_INTEGER); + $this->object->set('key_test', ['caca'], registry::TYPE_INTEGER); $this->assertTrue($this->object->get('key_test') === 1); /** @@ -71,7 +71,7 @@ class registryTest extends PhraseanetPHPUnitAbstract $this->object->set('key_test', '1', registry::TYPE_BOOLEAN); $this->assertTrue($this->object->get('key_test') === true); - $this->object->set('key_test', array('caca'), registry::TYPE_BOOLEAN); + $this->object->set('key_test', ['caca'], registry::TYPE_BOOLEAN); $this->assertTrue($this->object->get('key_test') === true); $this->object->set('key_test', '0', registry::TYPE_BOOLEAN); @@ -90,34 +90,34 @@ class registryTest extends PhraseanetPHPUnitAbstract * Set value with type enum_multi */ $this->object->set('key_test', 'value1', registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array('value1')); + $this->assertTrue($this->object->get('key_test') === ['value1']); $this->object->set('key_test', 1, registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array(1)); + $this->assertTrue($this->object->get('key_test') === [1]); $this->object->set('key_test', '1', registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array('1')); + $this->assertTrue($this->object->get('key_test') === ['1']); - $this->object->set('key_test', array('caca'), registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array('caca')); + $this->object->set('key_test', ['caca'], registry::TYPE_ENUM_MULTI); + $this->assertTrue($this->object->get('key_test') === ['caca']); $this->object->set('key_test', '0', registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array('0')); + $this->assertTrue($this->object->get('key_test') === ['0']); $this->object->set('key_test', 0, registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array(0)); + $this->assertTrue($this->object->get('key_test') === [0]); $this->object->set('key_test', false, registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array(false)); + $this->assertTrue($this->object->get('key_test') === [false]); $this->object->set('key_test', true, registry::TYPE_ENUM_MULTI); - $this->assertTrue($this->object->get('key_test') === array(true)); + $this->assertTrue($this->object->get('key_test') === [true]); } public function testSetArrayToString() { try { - $this->object->set('key_test', array('caca'), registry::TYPE_STRING); + $this->object->set('key_test', ['caca'], registry::TYPE_STRING); if (version_compare(PHP_VERSION, '5.4', '>=')) { $this->fail('Should raise an error notice'); @@ -130,7 +130,7 @@ class registryTest extends PhraseanetPHPUnitAbstract try { - $this->object->set('key_test', array('caca'), registry::TYPE_STRING); + $this->object->set('key_test', ['caca'], registry::TYPE_STRING); if (version_compare(PHP_VERSION, '5.4', '>=')) { $this->fail('Should raise an error notice'); diff --git a/tests/classes/report/activityTest.php b/tests/classes/report/activityTest.php index d1c473dd7e..18a869fcf7 100644 --- a/tests/classes/report/activityTest.php +++ b/tests/classes/report/activityTest.php @@ -20,10 +20,10 @@ class activityTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -33,14 +33,14 @@ class activityTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array("", 1, 0, 1, 1), - 'date' => array("", 1, 0, 1, 1), - 'record_id' => array("", 1, 1, 1, 1), - 'file' => array("", 1, 0, 1, 1), - 'mime' => array("", 1, 0, 1, 1), - 'size' => array("", 1, 0, 1, 1) - ); + $conf = [ + 'user' => ["", 1, 0, 1, 1], + 'date' => ["", 1, 0, 1, 1], + 'record_id' => ["", 1, 1, 1, 1], + 'file' => ["", 1, 0, 1, 1], + 'mime' => ["", 1, 0, 1, 1], + 'size' => ["", 1, 0, 1, 1] + ]; foreach ($this->ret as $sbasid => $colllist) { $report = new module_report_activity( diff --git a/tests/classes/report/addTest.php b/tests/classes/report/addTest.php index a2e273f770..cd061beab7 100644 --- a/tests/classes/report/addTest.php +++ b/tests/classes/report/addTest.php @@ -15,10 +15,10 @@ class addReportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -39,13 +39,13 @@ class addReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array("", 1, 0, 1, 1), - 'date' => array("", 1, 0, 1, 1), - 'record_id' => array("", 1, 1, 1, 1), - 'file' => array("", 1, 0, 1, 1), - 'mime' => array("", 1, 0, 1, 1) - ); + $conf = [ + 'user' => ["", 1, 0, 1, 1], + 'date' => ["", 1, 0, 1, 1], + 'record_id' => ["", 1, 1, 1, 1], + 'file' => ["", 1, 0, 1, 1], + 'mime' => ["", 1, 0, 1, 1] + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_add( diff --git a/tests/classes/report/connexionReportTest.php b/tests/classes/report/connexionReportTest.php index 920880cbe1..e2f106e2ec 100644 --- a/tests/classes/report/connexionReportTest.php +++ b/tests/classes/report/connexionReportTest.php @@ -16,10 +16,10 @@ class connexionReportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -42,16 +42,16 @@ class connexionReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'ip' => array(_('report:: IP'), 1, 0, 0, 0), - 'appli' => array(_('report:: modules'), 1, 0, 0, 0), - 'fonction' => array(_('report::fonction'), 1, 1, 1, 1), - 'activite' => array(_('report::activite'), 1, 1, 1, 1), - 'pays' => array(_('report::pays'), 1, 1, 1, 1), - 'societe' => array(_('report::societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'ip' => [_('report:: IP'), 1, 0, 0, 0], + 'appli' => [_('report:: modules'), 1, 0, 0, 0], + 'fonction' => [_('report::fonction'), 1, 1, 1, 1], + 'activite' => [_('report::activite'), 1, 1, 1, 1], + 'pays' => [_('report::pays'), 1, 1, 1, 1], + 'societe' => [_('report::societe'), 1, 1, 1, 1] + ]; $nbResult = 0; foreach ($this->ret as $sbasid => $collections) { diff --git a/tests/classes/report/dashboardTest.php b/tests/classes/report/dashboardTest.php index 53a2c75dd7..cd31b793a7 100644 --- a/tests/classes/report/dashboardTest.php +++ b/tests/classes/report/dashboardTest.php @@ -46,9 +46,9 @@ class dashboardTest extends PhraseanetPHPUnitAuthenticatedAbstract $date2 = new DateTime($this->dashboard->dmax); $interval = $date1->diff($date2); $nbDay = $interval->format("%a"); - $int = array('nb_dl', 'nb_conn'); - $top = array('top_ten_user_doc', 'top_ten_user_poiddoc', 'top_dl_document', 'top_ten_question', 'ask', 'top_ten_added'); - $activity = array('activity', 'activity_day', 'activity_added'); + $int = ['nb_dl', 'nb_conn']; + $top = ['top_ten_user_doc', 'top_ten_user_poiddoc', 'top_dl_document', 'top_ten_question', 'ask', 'top_ten_added']; + $activity = ['activity', 'activity_day', 'activity_added']; foreach ($dashboard as $key => $dash) { if (count($dash) == 0) continue; diff --git a/tests/classes/report/downloadReportTest.php b/tests/classes/report/downloadReportTest.php index 00aa016741..1d30a3e1de 100644 --- a/tests/classes/report/downloadReportTest.php +++ b/tests/classes/report/downloadReportTest.php @@ -15,10 +15,10 @@ class downloadReportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -47,18 +47,18 @@ class downloadReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'record_id' => array(_('report:: record id'), 1, 1, 1, 1), - 'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1), - 'coll_id' => array(_('report:: collections'), 1, 0, 1, 1), - 'comment' => array(_('report:: commentaire'), 1, 0, 0, 0), - 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), - 'activite' => array(_('report:: activite'), 1, 1, 1, 1), - 'pays' => array(_('report:: pays'), 1, 1, 1, 1), - 'societe' => array(_('report:: societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('report:: utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'record_id' => [_('report:: record id'), 1, 1, 1, 1], + 'final' => [_('phrseanet:: sous definition'), 1, 0, 1, 1], + 'coll_id' => [_('report:: collections'), 1, 0, 1, 1], + 'comment' => [_('report:: commentaire'), 1, 0, 0, 0], + 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], + 'activite' => [_('report:: activite'), 1, 1, 1, 1], + 'pays' => [_('report:: pays'), 1, 1, 1, 1], + 'societe' => [_('report:: societe'), 1, 1, 1, 1] + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_download( diff --git a/tests/classes/report/editTest.php b/tests/classes/report/editTest.php index a09bc6c7d7..619761986f 100644 --- a/tests/classes/report/editTest.php +++ b/tests/classes/report/editTest.php @@ -15,10 +15,10 @@ class editTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -28,14 +28,14 @@ class editTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array("", 1, 0, 1, 1), - 'date' => array("", 1, 0, 1, 1), - 'record_id' => array("", 1, 1, 1, 1), - 'file' => array("", 1, 0, 1, 1), - 'mime' => array("", 1, 0, 1, 1), - 'size' => array("", 1, 0, 1, 1) - ); + $conf = [ + 'user' => ["", 1, 0, 1, 1], + 'date' => ["", 1, 0, 1, 1], + 'record_id' => ["", 1, 1, 1, 1], + 'file' => ["", 1, 0, 1, 1], + 'mime' => ["", 1, 0, 1, 1], + 'size' => ["", 1, 0, 1, 1] + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_edit( diff --git a/tests/classes/report/filterTest.php b/tests/classes/report/filterTest.php index 9b53cb176e..42cc811106 100644 --- a/tests/classes/report/filterTest.php +++ b/tests/classes/report/filterTest.php @@ -15,10 +15,10 @@ class filterTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -29,16 +29,16 @@ class filterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function initFilter() { - $conf = array( - 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'ip' => array(_('report:: IP'), 1, 0, 0, 0), - 'appli' => array(_('report:: modules'), 1, 0, 0, 0), - 'fonction' => array(_('report::fonction'), 1, 1, 1, 1), - 'activite' => array(_('report::activite'), 1, 1, 1, 1), - 'pays' => array(_('report::pays'), 1, 1, 1, 1), - 'societe' => array(_('report::societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'ip' => [_('report:: IP'), 1, 0, 0, 0], + 'appli' => [_('report:: modules'), 1, 0, 0, 0], + 'fonction' => [_('report::fonction'), 1, 1, 1, 1], + 'activite' => [_('report::activite'), 1, 1, 1, 1], + 'pays' => [_('report::pays'), 1, 1, 1, 1], + 'societe' => [_('report::societe'), 1, 1, 1, 1] + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_connexion( @@ -54,8 +54,8 @@ class filterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testFilter() { - $filter = new module_report_filter(self::$DI['app'], array(), $this->report->getTransQueryString()); - $this->assertEquals(array(), $filter->getTabFilter()); + $filter = new module_report_filter(self::$DI['app'], [], $this->report->getTransQueryString()); + $this->assertEquals([], $filter->getTabFilter()); $filter->addFilter('x', 'LIKE', 'y'); $filter->addFilter('x', 'LIKE', 'z'); $filter->addFilter('1', '=', '1'); diff --git a/tests/classes/report/pushTest.php b/tests/classes/report/pushTest.php index ae27b20367..2ec6adb92a 100644 --- a/tests/classes/report/pushTest.php +++ b/tests/classes/report/pushTest.php @@ -15,10 +15,10 @@ class pushReportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -39,14 +39,14 @@ class pushReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array("", 1, 0, 1, 1), - 'getter' => array("Destinataire", 1, 0, 1, 1), - 'date' => array("", 1, 0, 1, 1), - 'record_id' => array("", 1, 1, 1, 1), - 'file' => array("", 1, 0, 1, 1), - 'mime' => array("", 1, 0, 1, 1) - ); + $conf = [ + 'user' => ["", 1, 0, 1, 1], + 'getter' => ["Destinataire", 1, 0, 1, 1], + 'date' => ["", 1, 0, 1, 1], + 'record_id' => ["", 1, 1, 1, 1], + 'file' => ["", 1, 0, 1, 1], + 'mime' => ["", 1, 0, 1, 1] + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_push( diff --git a/tests/classes/report/questionReportTest.php b/tests/classes/report/questionReportTest.php index 12bf4f177d..87a5062a46 100644 --- a/tests/classes/report/questionReportTest.php +++ b/tests/classes/report/questionReportTest.php @@ -15,10 +15,10 @@ class questionReportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -45,15 +45,15 @@ class questionReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array(_('report:: utilisateur'), 1, 1, 1, 1), - 'search' => array(_('report:: question'), 1, 0, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), - 'activite' => array(_('report:: activite'), 1, 1, 1, 1), - 'pays' => array(_('report:: pays'), 1, 1, 1, 1), - 'societe' => array(_('report:: societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('report:: utilisateur'), 1, 1, 1, 1], + 'search' => [_('report:: question'), 1, 0, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], + 'activite' => [_('report:: activite'), 1, 1, 1, 1], + 'pays' => [_('report:: pays'), 1, 1, 1, 1], + 'societe' => [_('report:: societe'), 1, 1, 1, 1] + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_question( diff --git a/tests/classes/report/reportTest.php b/tests/classes/report/reportTest.php index 4161905edc..5317bb79db 100644 --- a/tests/classes/report/reportTest.php +++ b/tests/classes/report/reportTest.php @@ -28,10 +28,10 @@ class reportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -107,7 +107,7 @@ class reportTest extends PhraseanetPHPUnitAuthenticatedAbstract $bool = false; $report->setCsv($bool); $this->assertEquals($bool, $report->getCsv()); - $filter = array('test', 'array'); + $filter = ['test', 'array']; $report->setFilter($filter); $this->assertEquals($filter, $report->getTabFilter()); $periode = "2 years"; @@ -123,7 +123,7 @@ class reportTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->assertEquals($limit, $report->getNbRecord()); $report->setGroupBy($bool); $this->assertEquals($bool, $report->getGroupBy()); - $column = array('col1', 'col2'); + $column = ['col1', 'col2']; $report->setActiveColumn($column); $this->assertEquals($column, $report->getActiveColumn()); $report->setConfig($bool); @@ -132,13 +132,13 @@ class reportTest extends PhraseanetPHPUnitAuthenticatedAbstract $this->assertFalse($report->getConfig()); $this->assertFalse($report->getPrint()); $this->assertFalse($report->getHasLimit()); - $result = array('result', 'result'); + $result = ['result', 'result']; $report->setResult($result); $this->assertEquals($result, $report->getResult()); $total = 3200; $report->setTotal($total); $this->assertEquals($total, $report->getTotal()); - $default_display = array('a', 'b', 'c'); + $default_display = ['a', 'b', 'c']; $report->setDefault_display($default_display); $this->assertEquals($default_display, $report->getDefault_display()); } @@ -147,7 +147,7 @@ class reportTest extends PhraseanetPHPUnitAuthenticatedAbstract { foreach ($this->ret as $sbasid => $collections) { - $report = $this->getMock('module_report', array('buildReq', 'buildResult'), array(), '', FALSE); + $report = $this->getMock('module_report', ['buildReq', 'buildResult'], [], '', FALSE); $report->setSbas_id($sbasid); $this->assertEquals($sbasid, $report->getSbas_id()); @@ -170,7 +170,7 @@ class reportTest extends PhraseanetPHPUnitAuthenticatedAbstract ip FROM log '); $report->expects($this->any())->method('buildReq')->will($this->returnValue('')); - $report->expects($this->any())->method('buildResult')->will($this->returnValue(array())); + $report->expects($this->any())->method('buildResult')->will($this->returnValue([])); $result = $report->buildReport(false, 'user'); } diff --git a/tests/classes/report/sentTest.php b/tests/classes/report/sentTest.php index 4524232065..3b6be06d04 100644 --- a/tests/classes/report/sentTest.php +++ b/tests/classes/report/sentTest.php @@ -15,10 +15,10 @@ class sentReportTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $this->dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $this->ret = array(); + $this->ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -39,14 +39,14 @@ class sentReportTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testBuildReport() { - $conf = array( - 'user' => array("", 1, 0, 1, 1), - 'date' => array("", 1, 0, 1, 1), - 'record_id' => array("", 1, 1, 1, 1), - 'file' => array("", 1, 0, 1, 1), - 'mime' => array("", 1, 0, 1, 1), - 'comment' => array("Receiver", 1, 0, 1, 1), - ); + $conf = [ + 'user' => ["", 1, 0, 1, 1], + 'date' => ["", 1, 0, 1, 1], + 'record_id' => ["", 1, 1, 1, 1], + 'file' => ["", 1, 0, 1, 1], + 'mime' => ["", 1, 0, 1, 1], + 'comment' => ["Receiver", 1, 0, 1, 1], + ]; foreach ($this->ret as $sbasid => $collections) { $this->report = new module_report_sent( diff --git a/tests/classes/report/sqlActionTest.php b/tests/classes/report/sqlActionTest.php index 4c0cfa8ff9..0a7f54bf1f 100644 --- a/tests/classes/report/sqlActionTest.php +++ b/tests/classes/report/sqlActionTest.php @@ -9,7 +9,7 @@ class sqlActionTest extends PhraseanetPHPUnitAuthenticatedAbstract { parent::setUp(); - $this->mock = $this->getMock('module_report', array(), array(), '', false); + $this->mock = $this->getMock('module_report', [], [], '', false); $this->action = new module_report_sqlaction(self::$DI['app'], $this->mock); } diff --git a/tests/classes/report/sqlFilterTest.php b/tests/classes/report/sqlFilterTest.php index d7238404b0..539c46cea8 100644 --- a/tests/classes/report/sqlFilterTest.php +++ b/tests/classes/report/sqlFilterTest.php @@ -17,10 +17,10 @@ class sqlFilterTest extends PhraseanetPHPUnitAuthenticatedAbstract $date->modify('-6 month'); $dmin = $date->format("Y-m-d H:i:s"); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); - $ret = array(); + $ret = []; foreach ($databoxes as $databox) { $colls = $databox->get_collections(); - $rett = array(); + $rett = []; foreach ($colls as $coll) { $rett[$coll->get_coll_id()] = $coll->get_coll_id(); } @@ -41,7 +41,7 @@ class sqlFilterTest extends PhraseanetPHPUnitAuthenticatedAbstract } } - $this->report->setFilter(array(array('f' => 'user', 'o' => '=', 'v' => 'admin'), array('f' => 'ddate', 'o' => 'LIKE', 'v' => '*'), array('f' => '1', 'o' => 'OR', 'v' => '1'))); + $this->report->setFilter([['f' => 'user', 'o' => '=', 'v' => 'admin'], ['f' => 'ddate', 'o' => 'LIKE', 'v' => '*'], ['f' => '1', 'o' => 'OR', 'v' => '1']]); $this->report->setUser_id(self::$DI['user']->get_id()); $this->report->setOrder('user', 'ASC'); $this->filter = new module_report_sqlfilter(self::$DI['app'], $this->report); diff --git a/tests/classes/report/sqlTest.php b/tests/classes/report/sqlTest.php index 5a1d74fa11..c772e7df96 100644 --- a/tests/classes/report/sqlTest.php +++ b/tests/classes/report/sqlTest.php @@ -6,14 +6,14 @@ class sqlTest extends PhraseanetPHPUnitAuthenticatedAbstract public function setUp() { parent::setUp(); - $report = $this->getMock('module_report', array(), array(), '', false); + $report = $this->getMock('module_report', [], [], '', false); $this->sql = new module_report_sql(self::$DI['app'], $report); } public function testSql() { - $sqlFilter = $this->getMock('module_report_sqlfilter', array('getCorFilter'), array(), '', false); - $sqlFilter->expects($this->any())->method('getCorFilter')->will($this->onConsecutiveCalls(array(), array('hello' => 'world'))); + $sqlFilter = $this->getMock('module_report_sqlfilter', ['getCorFilter'], [], '', false); + $sqlFilter->expects($this->any())->method('getCorFilter')->will($this->onConsecutiveCalls([], ['hello' => 'world'])); $this->sql->setFilter($sqlFilter); $this->assertEquals('hello', $this->sql->getTransQuery('hello')); $this->assertEquals('world', $this->sql->getTransQuery('hello')); diff --git a/tests/classes/system/system_serverTest.php b/tests/classes/system/system_serverTest.php index 6ba3379aeb..62c9cc7c40 100644 --- a/tests/classes/system/system_serverTest.php +++ b/tests/classes/system/system_serverTest.php @@ -5,7 +5,7 @@ class system_serverTest extends PhraseanetPHPUnitAbstract /** * @var system_server */ - protected $objects = array(); + protected $objects = []; public function setUp() { diff --git a/tests/classes/unitTestsTest.php b/tests/classes/unitTestsTest.php index 89da886d56..1523a67a13 100644 --- a/tests/classes/unitTestsTest.php +++ b/tests/classes/unitTestsTest.php @@ -5,14 +5,14 @@ class unitTestsTest extends PhraseanetPHPUnitAbstract public function testFiles() { - $reserved = array( + $reserved = [ "BoilerPlate.php", "PhraseanetPHPUnitAbstract.php", "PhraseanetWebTestCaseAbstract.php", "PhraseanetPHPUnitAuthenticatedAbstract.php", "PhraseanetWebTestCaseAuthenticatedAbstract.php", "PhraseanetPHPUnitListener.php", - ); + ]; $testDir = __DIR__ . '/'; foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($testDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { diff --git a/tests/classes/userTest.php b/tests/classes/userTest.php index b6e84af395..afa779d4db 100644 --- a/tests/classes/userTest.php +++ b/tests/classes/userTest.php @@ -62,11 +62,11 @@ class userTest extends PhraseanetPHPUnitAbstract { $data = isset(self::$DI['app']['configuration']['user-settings']) ? self::$DI['app']['configuration']['user-settings'] : null; - self::$DI['app']['configuration']['user-settings'] = array( + self::$DI['app']['configuration']['user-settings'] = [ 'images_per_page' => 42, 'images_size' => 666, 'lalala' => 'didou', - ); + ]; $user = $this->get_user(); diff --git a/tests/classes/uuidTest.php b/tests/classes/uuidTest.php index 1b8d902f2d..b034b2159d 100644 --- a/tests/classes/uuidTest.php +++ b/tests/classes/uuidTest.php @@ -15,7 +15,7 @@ class uuidTest extends PhraseanetPHPUnitAbstract public function testGenerate_v3() { - $datas = array(); + $datas = []; for ($i = 0; $i < 1000; $i ++) { $uuid = uuid::generate_v4(); @@ -39,7 +39,7 @@ class uuidTest extends PhraseanetPHPUnitAbstract public function testGenerate_v4() { - $datas = array(); + $datas = []; for ($i = 0; $i < 1000; $i ++) { $uuid = uuid::generate_v4(); @@ -59,7 +59,7 @@ class uuidTest extends PhraseanetPHPUnitAbstract public function testGenerate_v5() { - $datas = array(); + $datas = []; for ($i = 0; $i < 1000; $i ++) { $uuid = uuid::generate_v4(); From 053b23a936ef19c7758df3834fa339c216ecf8d2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Nov 2013 12:12:06 +0100 Subject: [PATCH 3/3] Update compiler to use short array declaration --- lib/Alchemy/Phrasea/Core/Configuration/Compiler.php | 4 ++-- .../Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Compiler.php b/lib/Alchemy/Phrasea/Core/Configuration/Compiler.php index e337056f39..e65586b98f 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/Compiler.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/Compiler.php @@ -34,7 +34,7 @@ class Compiler private function doCompile(array $data, $offset = 0) { - $out = 'array(' . $this->addLine(); + $out = '[' . $this->addLine(); foreach ($data as $key => $value) { if (is_object($value)) { @@ -50,7 +50,7 @@ class Compiler } } - $out .= $this->addIndentation($offset) . ')'; + $out .= $this->addIndentation($offset) . ']'; return $out; } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php index 4d3a2eb29a..6670d063d4 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/CompilerTest.php @@ -15,7 +15,7 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $compiled = $compiler->compile($data); $this->assertInternalType("string", $compiled); - $this->assertSame(0, strpos($compiled, "assertSame(0, strpos($compiled, "'.$compiled); $this->assertSame($data, $result); @@ -35,7 +35,7 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $compiled = $compiler->compile($data); $this->assertInternalType("string", $compiled); - $this->assertSame(0, strpos($compiled, "assertSame(0, strpos($compiled, "'.$compiled); $this->assertSame(['key' => ['key' => 'value'], 'key2' => 'boum'], $result);