diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index d3dd96bab5..fe22798f42 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -311,7 +311,7 @@ class Application extends SilexApplication $this->register(new SessionHandlerServiceProvider()); $this->register(new SessionServiceProvider(), [ 'session.test' => $this->getEnvironment() === static::ENV_TEST, - 'session.storage.options' => array('cookie_lifetime' => 0) + 'session.storage.options' => ['cookie_lifetime' => 0] ]); $this['session.storage.test'] = $this->share(function ($app) { @@ -467,7 +467,7 @@ class Application extends SilexApplication $this['dispatcher'] = $this->share( $this->extend('dispatcher', function ($dispatcher, Application $app) { - $dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128); + $dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128); $dispatcher->addSubscriber($app['phraseanet.logout-subscriber']); $dispatcher->addSubscriber($app['phraseanet.locale-subscriber']); $dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']); @@ -649,8 +649,8 @@ class Application extends SilexApplication })); $twig->addFilter(new \Twig_SimpleFilter('highlight', function (\Twig_Environment $twig, $string) { - return str_replace(array('[[em]]', '[[/em]]'), array('', ''), $string); - }, array('needs_environment' => true,'is_safe' => array('html')))); + return str_replace(['[[em]]', '[[/em]]'], ['', ''], $string); + }, ['needs_environment' => true,'is_safe' => ['html']])); $twig->addFilter(new \Twig_SimpleFilter('linkify', function (\Twig_Environment $twig, $string) { return preg_replace( @@ -658,7 +658,7 @@ class Application extends SilexApplication , '$1 $2  $7' , $string ); - }, array('needs_environment' => true, 'is_safe' => array('html')))); + }, ['needs_environment' => true, 'is_safe' => ['html']])); $twig->addFilter(new \Twig_SimpleFilter('bounce', function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) { // bounce value if it is present in thesaurus as well @@ -670,7 +670,7 @@ class Application extends SilexApplication . $fieldValue . ""; - }, array('needs_environment' => true, 'is_safe' => array('html')))); + }, ['needs_environment' => true, 'is_safe' => ['html']])); $twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) { return str_replace('"', '\"', $value); diff --git a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php index ea57fc67ff..221bc2bd44 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php +++ b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php @@ -342,10 +342,10 @@ class RegenerateSqliteDb extends Command $event = new WebhookEvent(); $event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setType(WebhookEvent::FEED_ENTRY_TYPE); - $event->setData(array( + $event->setData([ 'feed_id' => $DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => $DI['feed_public_entry']->getId() - )); + ]); $em->persist($event); $DI['event_webhook_1'] = $event; @@ -353,10 +353,10 @@ class RegenerateSqliteDb extends Command $event2 = new WebhookEvent(); $event2->setName(WebhookEvent::NEW_FEED_ENTRY); $event2->setType(WebhookEvent::FEED_ENTRY_TYPE); - $event2->setData(array( + $event2->setData([ 'feed_id' => $DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => $DI['feed_public_entry']->getId() - )); + ]); $event2->setProcessed(true); $em->persist($event2); } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index 9464111cc3..b785a6f196 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -254,11 +254,11 @@ 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', [ diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index 5d61aa41fc..b0effb8232 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -530,7 +530,7 @@ class Users implements ControllerProviderInterface ]; $nbUsrToAdd = 0; - $lines = array(); + $lines = []; $app['csv.interpreter']->addObserver(function (array $row) use (&$lines) { $lines[] = $row; }); diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php index 6908ee6566..4bda86f07c 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php @@ -1431,7 +1431,7 @@ class V1 implements ControllerProviderInterface public function get_publications(Application $app, Request $request) { $user = $app['authentication']->getUser(); - $restrictions = (array) ($request->get('feeds') ? : array()); + $restrictions = (array) ($request->get('feeds') ? : []); $feed = Aggregate::createFromUser($app, $user, $restrictions); diff --git a/lib/Alchemy/Phrasea/Controller/Datafiles.php b/lib/Alchemy/Phrasea/Controller/Datafiles.php index a8b2cc2167..52e6722296 100644 --- a/lib/Alchemy/Phrasea/Controller/Datafiles.php +++ b/lib/Alchemy/Phrasea/Controller/Datafiles.php @@ -72,11 +72,10 @@ class Datafiles extends AbstractDelivery ->get_subdef_structure() ->get_subdef($record->get_type(), $subdef) ->get_class(); - } catch(\Exception_Databox_SubdefNotFound $e) { + } catch (\Exception_Databox_SubdefNotFound $e) { } - if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['acl']->get($app['authentication']->getUser())->has_preview_grant($record)) { $watermark = false; } elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $app['acl']->get($app['authentication']->getUser())->has_hd_grant($record)) { diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index 28ad989498..585e71c0d0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -217,9 +217,9 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $arguments = array( + $arguments = [ 'basket' => $Basket->getId(), - ); + ]; if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) { $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver); @@ -412,14 +412,14 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $arguments = array( + $arguments = [ 'basket' => $Basket->getId(), - ); + ]; if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) { $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $participant_user); } - + $url = $app->url('lightbox_validation', $arguments); $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : ''; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Records.php b/lib/Alchemy/Phrasea/Controller/Prod/Records.php index c8237742af..40b02a4ecb 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Records.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Records.php @@ -135,7 +135,7 @@ class Records implements ControllerProviderInterface 'record' => $record ]), "pos" => $record->get_number(), - "title" => str_replace(array('[[em]]', '[[/em]]'), array('', ''), $record->get_title($query, $searchEngine)) + "title" => str_replace(['[[em]]', '[[/em]]'], ['', ''], $record->get_title($query, $searchEngine)) ]); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php index f2047b7e14..f4e983d132 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php @@ -99,10 +99,10 @@ class Tooltip implements ControllerProviderInterface public function displayPreview(Application $app, $sbas_id, $record_id) { - return $app['twig']->render('prod/Tooltip/Preview.html.twig', array( + return $app['twig']->render('prod/Tooltip/Preview.html.twig', [ 'record' => new \record_adapter($app, $sbas_id, $record_id), 'not_wrapped' => true - )); + ]); } public function displayCaption(Application $app, $sbas_id, $record_id, $context) diff --git a/lib/Alchemy/Phrasea/Controller/Report/Activity.php b/lib/Alchemy/Phrasea/Controller/Report/Activity.php index 031195c6bf..fbcd11a2cb 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Activity.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Activity.php @@ -217,18 +217,18 @@ class Activity implements ControllerProviderInterface $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 - )); + ]); } /** @@ -276,18 +276,18 @@ class Activity implements ControllerProviderInterface $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 - )); + ]); } /** @@ -320,18 +320,18 @@ class Activity implements ControllerProviderInterface $report = $activity->getActivityPerHours(); - 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 - )); + ]); } /** @@ -380,18 +380,18 @@ class Activity implements ControllerProviderInterface $report = $activity->getDownloadByBaseByDay($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 - )); + ]); } /** @@ -852,7 +852,7 @@ class Activity implements ControllerProviderInterface private function getCSVResponse(Application $app, \module_report $report, $type) { // set headers - $headers = array(); + $headers = []; foreach (array_keys($report->getDisplay()) as $k) { $headers[$k] = $k; } diff --git a/lib/Alchemy/Phrasea/Controller/Report/Informations.php b/lib/Alchemy/Phrasea/Controller/Report/Informations.php index 85fdc46895..9dd99d5596 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Informations.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Informations.php @@ -471,7 +471,6 @@ class Informations implements ControllerProviderInterface $reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false); if ($request->request->get('printcsv') == 'on' && isset($download)) { - return $this->getCSVResponse($app, $info, 'info_user'); } @@ -512,7 +511,7 @@ class Informations implements ControllerProviderInterface private function getCSVResponse(Application $app, \module_report $report, $type) { // set headers - $headers = array(); + $headers = []; foreach (array_keys($report->getDisplay()) as $k) { $headers[$k] = $k; } diff --git a/lib/Alchemy/Phrasea/Controller/Report/Root.php b/lib/Alchemy/Phrasea/Controller/Report/Root.php index dbf5b0ac76..721bff0c84 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Root.php @@ -482,7 +482,7 @@ class Root implements ControllerProviderInterface ]; if ($request->request->get('printcsv') == 'on') { - $result = array(); + $result = []; $result[] = array_keys($conf_nav); foreach ($report['nav']['result'] as $row) { @@ -677,7 +677,7 @@ class Root implements ControllerProviderInterface private function getCSVResponse(Application $app, \module_report $report, $type) { // set headers - $headers = array(); + $headers = []; foreach (array_keys($report->getDisplay()) as $k) { $headers[$k] = $k; } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index d84f52d9b3..7121836282 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -25,7 +25,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Account implements ControllerProviderInterface { diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php index b6b440c384..2ef31ce6ce 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php @@ -18,7 +18,6 @@ use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class Developers implements ControllerProviderInterface { @@ -116,7 +115,6 @@ class Developers implements ControllerProviderInterface return $app->json(['success' => true]); } - /** * Change application webhook * @@ -137,7 +135,7 @@ class Developers implements ControllerProviderInterface return $app->json(['success' => false]); } - return $app->json(array('success' => true)); + return $app->json(['success' => true]); } /** @@ -159,7 +157,7 @@ class Developers implements ControllerProviderInterface $app->abort(404, sprintf('Account not found for application %s', $application->getName())); } - if(null !== $devToken = $app['repo.api-oauth-tokens']->findDeveloperToken($account)) { + if (null !== $devToken = $app['repo.api-oauth-tokens']->findDeveloperToken($account)) { $app['manipulator.api-oauth-token']->renew($devToken); } else { // dev tokens do not expires diff --git a/lib/Alchemy/Phrasea/Controller/Root/Session.php b/lib/Alchemy/Phrasea/Controller/Root/Session.php index 4826f49140..71f1019ecc 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Session.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Session.php @@ -52,12 +52,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()->getId(); @@ -86,9 +86,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('\Entities\Basket')->findUnreadActiveByUser($app['authentication']->getUser()); @@ -96,7 +96,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['phraseanet.configuration']['main']['maintenance']) { $ret['message'] .= _('The application is going down for maintenance, please logout.'); } diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php index 0a4354644d..d75bbc4fc1 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php @@ -753,7 +753,7 @@ class Xmlhttp implements ControllerProviderInterface $lcoll = ''; $collections = $app['authentication']->getUser()->ACL() - ->get_granted_base(array(), array($sbid)); // array(), $sbid); + ->get_granted_base([], [$sbid]); // array(), $sbid); foreach ($collections as $collection) { $lcoll .= ($lcoll?",":"") . $collection->get_coll_id(); } @@ -779,7 +779,7 @@ class Xmlhttp implements ControllerProviderInterface FROM (thit AS t INNER JOIN record AS r USING(record_id)) INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0'; - $sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); + $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id]; $stmt = $connbas->prepare($sql); $stmt->execute($sqlparm); @@ -797,10 +797,10 @@ class Xmlhttp implements ControllerProviderInterface INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0 GROUP BY k'; - $sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); + $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id]; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -816,7 +816,7 @@ class Xmlhttp implements ControllerProviderInterface INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0 GROUP BY k'; - $sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); + $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id]; $stmt = $connbas->prepare($sql); $stmt->execute($sqlparm); @@ -834,7 +834,7 @@ class Xmlhttp implements ControllerProviderInterface INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0 GROUP BY k'; - $sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); + $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id]; $stmt = $connbas->prepare($sql); $stmt->execute($sqlparm); diff --git a/lib/Alchemy/Phrasea/Core/Event/InstallFinishEvent.php b/lib/Alchemy/Phrasea/Core/Event/InstallFinishEvent.php index b3a4ec1ccf..9844682bb9 100644 --- a/lib/Alchemy/Phrasea/Core/Event/InstallFinishEvent.php +++ b/lib/Alchemy/Phrasea/Core/Event/InstallFinishEvent.php @@ -11,7 +11,6 @@ namespace Alchemy\Phrasea\Core\Event; -use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\User; use Symfony\Component\EventDispatcher\Event as SfEvent; diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiCorsSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiCorsSubscriber.php index f1f4ab2e3b..c172607f69 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiCorsSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiCorsSubscriber.php @@ -25,12 +25,12 @@ class ApiCorsSubscriber implements EventSubscriberInterface /** * Simple headers as defined in the spec should always be accepted */ - protected static $simpleHeaders = array( + protected static $simpleHeaders = [ 'accept', 'accept-language', 'content-language', 'origin', - ); + ]; private $app; private $options; @@ -42,9 +42,9 @@ class ApiCorsSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 128), - ); + return [ + KernelEvents::REQUEST => ['onKernelRequest', 128], + ]; } public function onKernelRequest(GetResponseEvent $event) @@ -66,15 +66,15 @@ class ApiCorsSubscriber implements EventSubscriberInterface return; } - $options = array_merge(array( + $options = array_merge([ 'allow_credentials'=> false, - 'allow_origin'=> array(), - 'allow_headers'=> array(), - 'allow_methods'=> array(), - 'expose_headers'=> array(), + 'allow_origin'=> [], + 'allow_headers'=> [], + 'allow_methods'=> [], + 'expose_headers'=> [], 'max_age'=> 0, - 'hosts'=> array(), - ), $this->app['phraseanet.configuration']['api_cors']); + 'hosts'=> [], + ], $this->app['phraseanet.configuration']['api_cors']); // skip if the host is not matching if (!$this->checkHost($request, $options)) { @@ -87,13 +87,13 @@ class ApiCorsSubscriber implements EventSubscriberInterface return; } if (!$this->checkOrigin($request, $options)) { - $response = new Response('', 403, array('Access-Control-Allow-Origin' => 'null')); + $response = new Response('', 403, ['Access-Control-Allow-Origin' => 'null']); $event->setResponse($response); return; } - $this->app['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse')); + $this->app['dispatcher']->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']); $this->options = $options; } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/SessionManagerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/SessionManagerSubscriber.php index bde9eece04..a101810ce8 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/SessionManagerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/SessionManagerSubscriber.php @@ -32,12 +32,12 @@ class SessionManagerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('initSession', Application::EARLY_EVENT), - array('checkSessionActivity', Application::LATE_EVENT) - ) - ); + return [ + KernelEvents::REQUEST => [ + ['initSession', Application::EARLY_EVENT], + ['checkSessionActivity', Application::LATE_EVENT] + ] + ]; } public function initSession(GetResponseEvent $event) @@ -60,14 +60,14 @@ class SessionManagerSubscriber implements EventSubscriberInterface /**log real human activity on application, to keep session alive*/ public function checkSessionActivity(GetResponseEvent $event) { - $modulesIds = array( + $modulesIds = [ "prod" => 1, "client" => 2, "admin" => 3, "thesaurus" => 5, "report" => 10, "lightbox" => 6, - ); + ]; $pathInfo = array_filter(explode('/', $event->getRequest()->getPathInfo())); @@ -101,7 +101,7 @@ class SessionManagerSubscriber implements EventSubscriberInterface if ($event->getRequest()->isXmlHttpRequest()) { $response = new Response("End-Session", 403); } else { - $response = new RedirectResponse($this->app["url_generator"]->generate("homepage", array("redirect"=>'..' . $event->getRequest()->getPathInfo()))); + $response = new RedirectResponse($this->app["url_generator"]->generate("homepage", ["redirect"=>'..' . $event->getRequest()->getPathInfo()])); } $response->headers->set('X-Phraseanet-End-Session', '1'); @@ -124,7 +124,7 @@ class SessionManagerSubscriber implements EventSubscriberInterface if ($event->getRequest()->isXmlHttpRequest()) { $response = new Response("End-Session", 403); } else { - $response = new RedirectResponse($this->app["url_generator"]->generate("homepage", array("redirect"=>'..' . $event->getRequest()->getPathInfo()))); + $response = new RedirectResponse($this->app["url_generator"]->generate("homepage", ["redirect"=>'..' . $event->getRequest()->getPathInfo()])); } $response->headers->set('X-Phraseanet-End-Session', '1'); diff --git a/lib/Alchemy/Phrasea/Core/Provider/CSVServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/CSVServiceProvider.php index 540224149f..6f92ded40d 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/CSVServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/CSVServiceProvider.php @@ -61,7 +61,7 @@ class CSVServiceProvider implements ServiceProviderInterface $app['csv.response'] = $app->protect(function ($callback) use ($app) { // set headers to fix ie issues - $response = new StreamedResponse($callback, 200, array( + $response = new StreamedResponse($callback, 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', @@ -70,7 +70,7 @@ class CSVServiceProvider implements ServiceProviderInterface 'Content-Type' => 'text/csv', '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, diff --git a/lib/Alchemy/Phrasea/Core/Provider/ConvertersServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ConvertersServiceProvider.php index 100d608696..7229a3a6d8 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ConvertersServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ConvertersServiceProvider.php @@ -27,7 +27,7 @@ class ConvertersServiceProvider implements ServiceProviderInterface return new TaskConverter($app['repo.tasks']); }); - $app['converter.task-callback'] = $app->protect(function($id) use ($app) { + $app['converter.task-callback'] = $app->protect(function ($id) use ($app) { return $app['converter.task']->convert($id); }); diff --git a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php index b6decfe294..1fa0951d2c 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php @@ -25,7 +25,6 @@ use Alchemy\Phrasea\TaskManager\LiveInformation; use Alchemy\Phrasea\TaskManager\TaskManagerStatus; use Alchemy\Phrasea\TaskManager\Log\LogFileFactory; use Alchemy\Phrasea\TaskManager\Notifier; -use Alchemy\Phrasea\Webhook\EventProcessorFactory; use Silex\Application; use Silex\ServiceProviderInterface; diff --git a/lib/Alchemy/Phrasea/Core/Response/CSVFileResponse.php b/lib/Alchemy/Phrasea/Core/Response/CSVFileResponse.php index da223582a7..03610411b6 100644 --- a/lib/Alchemy/Phrasea/Core/Response/CSVFileResponse.php +++ b/lib/Alchemy/Phrasea/Core/Response/CSVFileResponse.php @@ -15,11 +15,11 @@ use Symfony\Component\HttpFoundation\ResponseHeaderBag; class CSVFileResponse extends StreamedResponse { - public function __construct($filename, $callback = null, $status = 200, $headers = array()) + public function __construct($filename, $callback = null, $status = 200, $headers = []) { parent::__construct($callback, $status, array_merge( // set some headers to fix ie issues - array( + [ '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', @@ -27,7 +27,7 @@ class CSVFileResponse extends StreamedResponse 'Pragma' => 'no-cache', 'Cache-Control' => 'max-age=3600, must-revalidate', 'Content-Disposition' => 'max-age=3600, must-revalidate', - ), + ], $headers )); diff --git a/lib/Alchemy/Phrasea/Form/Configuration/EmailFormType.php b/lib/Alchemy/Phrasea/Form/Configuration/EmailFormType.php index 56a6413dc2..c4e3344f58 100644 --- a/lib/Alchemy/Phrasea/Form/Configuration/EmailFormType.php +++ b/lib/Alchemy/Phrasea/Form/Configuration/EmailFormType.php @@ -45,9 +45,9 @@ class EmailFormType extends AbstractType ]); $builder->add('hidden-password', 'password', [ 'label' => false, - 'attr' => array( + 'attr' => [ 'style' => 'display:none' - ) + ] ]); $builder->add('smtp-password', 'password', [ 'label' => 'SMTP password', diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php index ac8d529845..e40edd2bf9 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php @@ -46,20 +46,20 @@ class PhraseaAuthenticationForm extends AbstractType ]); if ($this->app['phraseanet.configuration']['session']['idle'] < 1) { - $builder->add('remember-me', 'checkbox' , array( + $builder->add('remember-me', 'checkbox' , [ 'label' => _('Remember me'), 'mapped' => false, 'required' => false, - 'attr' => array( + 'attr' => [ 'value' => '1', - ) - )); + ] + ]); } else { - $builder->add('remember-me', 'hidden' , array( + $builder->add('remember-me', 'hidden' , [ 'label' => '', 'mapped' => false, 'required' => false - )); + ]); } $builder->add('redirect', 'hidden', [ diff --git a/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php b/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php index d2ef390c0a..90cdc4a17c 100644 --- a/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php +++ b/lib/Alchemy/Phrasea/Helper/DatabaseHelper.php @@ -11,9 +11,6 @@ namespace Alchemy\Phrasea\Helper; -use Doctrine\DBAL\DBALException; -use Alchemy\Phrasea\Core\Connection\ConnectionProvider; - class DatabaseHelper extends Helper { public function checkConnection() @@ -75,12 +72,12 @@ class DatabaseHelper extends Helper } } - return array( + return [ 'connection' => $connection_ok, 'database' => $db_ok, 'is_empty' => $empty, 'is_appbox' => $is_appbox, 'is_databox' => $is_databox - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Helper/PathHelper.php b/lib/Alchemy/Phrasea/Helper/PathHelper.php index 2093a5f2fe..42de7e1d8e 100644 --- a/lib/Alchemy/Phrasea/Helper/PathHelper.php +++ b/lib/Alchemy/Phrasea/Helper/PathHelper.php @@ -17,18 +17,18 @@ class PathHelper extends Helper { public function checkPath() { - return array( + return [ 'exists' => file_exists($this->request->query->get('path')), 'file' => is_file($this->request->query->get('path')), 'dir' => is_dir($this->request->query->get('path')), 'readable' => is_readable($this->request->query->get('path')), 'writeable' => is_writable($this->request->query->get('path')), 'executable' => is_executable($this->request->query->get('path')), - ); + ]; } public function checkUrl() { - return array('code' => \http_query::getHttpCodeFromUrl($this->request->query->get('url'))); + return ['code' => \http_query::getHttpCodeFromUrl($this->request->query->get('url'))]; } } diff --git a/lib/Alchemy/Phrasea/Model/Converter/BasketConverter.php b/lib/Alchemy/Phrasea/Model/Converter/BasketConverter.php index d9ef7abfdb..4871ef3a45 100644 --- a/lib/Alchemy/Phrasea/Model/Converter/BasketConverter.php +++ b/lib/Alchemy/Phrasea/Model/Converter/BasketConverter.php @@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Model\Converter; use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Repositories\BasketRepository; -use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class BasketConverter implements ConverterInterface diff --git a/lib/Alchemy/Phrasea/Model/Converter/TaskConverter.php b/lib/Alchemy/Phrasea/Model/Converter/TaskConverter.php index e5174994a0..ce4c9043fd 100644 --- a/lib/Alchemy/Phrasea/Model/Converter/TaskConverter.php +++ b/lib/Alchemy/Phrasea/Model/Converter/TaskConverter.php @@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Model\Converter; use Alchemy\Phrasea\Model\Entities\Task; use Alchemy\Phrasea\Model\Repositories\TaskRepository; -use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class TaskConverter implements ConverterInterface diff --git a/lib/Alchemy/Phrasea/Model/Entities/ApiOauthToken.php b/lib/Alchemy/Phrasea/Model/Entities/ApiOauthToken.php index 6bbcd7a288..2e2823c3c8 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ApiOauthToken.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ApiOauthToken.php @@ -208,7 +208,7 @@ class ApiOauthToken } /** - * @param \DateTime $lastUsed + * @param \DateTime $lastUsed * * @return ApiOauthToken */ diff --git a/lib/Alchemy/Phrasea/Model/Entities/WebhookEvent.php b/lib/Alchemy/Phrasea/Model/Entities/WebhookEvent.php index 5776008506..9b1f86894f 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/WebhookEvent.php +++ b/lib/Alchemy/Phrasea/Model/Entities/WebhookEvent.php @@ -53,12 +53,12 @@ class WebhookEvent public static function types() { - return array(self::FEED_ENTRY_TYPE); + return [self::FEED_ENTRY_TYPE]; } public static function events() { - return array(self::NEW_FEED_ENTRY); + return [self::NEW_FEED_ENTRY]; } /** diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiAccountManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiAccountManipulator.php index 8c03eefcf0..d00d8855f6 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiAccountManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiAccountManipulator.php @@ -12,7 +12,6 @@ namespace Alchemy\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiApplication; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php index 3408075e85..7d45988f20 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiApplicationManipulator.php @@ -12,11 +12,9 @@ namespace Alchemy\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\User; -use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; use RandomLib\Generator; @@ -58,7 +56,7 @@ class ApiApplicationManipulator implements ManipulatorInterface $this->om->remove($application); $this->om->flush(); } - + public function update(ApiApplication $application) { $this->om->persist($application); diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiLogManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiLogManipulator.php index 40046edca4..0ec1cdbd4d 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiLogManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiLogManipulator.php @@ -11,11 +11,8 @@ namespace Alchemy\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiLog; -use Alchemy\Phrasea\Model\Entities\User; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; use Symfony\Component\HttpFoundation\Request; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthCodeManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthCodeManipulator.php index 1b80a5e041..5f8d204af2 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthCodeManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthCodeManipulator.php @@ -11,14 +11,10 @@ namespace Alchemy\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiOauthCode; use Alchemy\Phrasea\Model\Entities\ApiApplication; -use Alchemy\Phrasea\Model\Entities\User; -use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; use RandomLib\Generator; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthRefreshTokenManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthRefreshTokenManipulator.php index ee35f1327f..57239f03c5 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthRefreshTokenManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthRefreshTokenManipulator.php @@ -11,12 +11,8 @@ namespace Alchemy\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiOauthRefreshtoken; -use Alchemy\Phrasea\Model\Entities\User; -use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; use RandomLib\Generator; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthTokenManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthTokenManipulator.php index d556c3e3e8..9c492bbc14 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthTokenManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ApiOauthTokenManipulator.php @@ -11,13 +11,8 @@ namespace Alchemy\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiOauthToken; -use Alchemy\Phrasea\Model\Entities\Session; -use Alchemy\Phrasea\Model\Entities\User; -use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; use RandomLib\Generator; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulator.php index 4a8bef1440..a58abc0f12 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulator.php @@ -12,17 +12,11 @@ namespace Alchemy\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; -use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiApplication; -use Alchemy\Phrasea\Model\Entities\ApiLog; -use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\WebhookEvent; use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; class WebhookEventDeliveryManipulator implements ManipulatorInterface { diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php index 21a7d87011..9fe2c59779 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/WebhookEventManipulator.php @@ -11,16 +11,9 @@ namespace Alchemy\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Authentication\ACLProvider; -use Alchemy\Phrasea\Model\Entities\ApiAccount; -use Alchemy\Phrasea\Model\Entities\ApiLog; -use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\WebhookEvent; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityRepository; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; class WebhookEventManipulator implements ManipulatorInterface { diff --git a/lib/Alchemy/Phrasea/Model/Repositories/WebhookEventRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/WebhookEventRepository.php index eb29814d8d..aa2d778423 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/WebhookEventRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/WebhookEventRepository.php @@ -11,7 +11,6 @@ namespace Alchemy\Phrasea\Model\Repositories; -use Alchemy\Phrasea\Model\Entities\WebhookEvent; use Doctrine\ORM\EntityRepository; /** diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php index a14cbbc6f1..86a4cb3c5a 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php @@ -623,7 +623,7 @@ class PhraseaEngine implements SearchEngineInterface $sxe = @simplexml_load_string($res['xml']); foreach ($fields as $name => $field) { - $newValues = array(); + $newValues = []; if ($sxe && $sxe->description && $sxe->description->{$name}) { foreach ($sxe->description->{$name} as $value) { $newValues[(string) $value['meta_id']] = (string) $value; diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php index a9e72e5e51..4eb9c78618 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php @@ -519,7 +519,7 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null) { - return array(); + return []; } /** diff --git a/lib/Alchemy/Phrasea/Security/Firewall.php b/lib/Alchemy/Phrasea/Security/Firewall.php index 2528a1331a..058dc81523 100644 --- a/lib/Alchemy/Phrasea/Security/Firewall.php +++ b/lib/Alchemy/Phrasea/Security/Firewall.php @@ -113,7 +113,7 @@ class Firewall public function requireAuthentication(Request $request = null) { - $params = array(); + $params = []; if (null !== $request) { $params['redirect'] = '..' . $request->getPathInfo(); } diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/WebhookJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/WebhookJob.php index 4c4c45eda7..e76d0a1aa2 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/WebhookJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/WebhookJob.php @@ -25,11 +25,9 @@ use Guzzle\Plugin\Backoff\BackoffPlugin; use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy; use Guzzle\Plugin\Backoff\CallbackBackoffStrategy; use Guzzle\Plugin\Backoff\CurlBackoffStrategy; -use Guzzle\Plugin\Backoff\ExponentialBackoffStrategy; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Translation\TranslatorInterface; -use Guzzle\Http\Exception\MultiTransferException; class WebhookJob extends AbstractJob { @@ -94,7 +92,7 @@ class WebhookJob extends AbstractJob // set max retries new TruncatedBackoffStrategy(WebhookEventDelivery::MAX_DELIVERY_TRIES, // set callback which logs success or failure - new CallbackBackoffStrategy(function($retries, $request, $response, $e) use ($app, $that) { + new CallbackBackoffStrategy(function ($retries, $request, $response, $e) use ($app, $that) { $retry = true; if ($response && (null !== $deliverId = parse_url($request->getUrl(), PHP_URL_FRAGMENT))) { $delivery = $app['repo.webhook-delivery']->find($deliverId); @@ -153,9 +151,9 @@ class WebhookJob extends AbstractJob $uniqueUrl = $this->getUrl($thirdPartyApplication, $delivery); // create http request with data as request body - $batch->add($this->httpClient->createRequest('POST', $uniqueUrl, array( + $batch->add($this->httpClient->createRequest('POST', $uniqueUrl, [ 'Content-Type' => 'application/vnd.phraseanet.event+json' - ), json_encode($data))); + ], json_encode($data))); } $batch->flush(); diff --git a/lib/Alchemy/Phrasea/Twig/Fit.php b/lib/Alchemy/Phrasea/Twig/Fit.php index a4bb2c1bba..b8b4f0741a 100644 --- a/lib/Alchemy/Phrasea/Twig/Fit.php +++ b/lib/Alchemy/Phrasea/Twig/Fit.php @@ -21,9 +21,9 @@ class Fit extends \Twig_Extension public function getFunctions() { - return array( + return [ 'fitIn' => new \Twig_Function_Method($this, 'fitIn') - ); + ]; } public function fitIn(array $content, array $box) @@ -79,11 +79,11 @@ class Fit extends \Twig_Extension } } - return array( + return [ 'width' => round($width), 'height' => round($height), 'top' => round($top), 'left' => round($left) - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php b/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php index 35ea6c9b14..4ace803674 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/FeedEntryProcessor.php @@ -30,43 +30,43 @@ class FeedEntryProcessor extends AbstractProcessor implements ProcessorInterface ->email_not_null(true); if ($feed->getCollection($this->app)) { - $query->on_base_ids(array($feed->getCollection($this->app)->get_base_id())); + $query->on_base_ids([$feed->getCollection($this->app)->get_base_id()]); } $start = 0; $perLoop = 100; - $users = array(); + $users = []; do { $results = $query->limit($start, $perLoop)->execute()->get_results(); foreach ($results as $user) { - $users[] = array( + $users[] = [ 'email' => $user->getEmail(), 'firstname' => $user->getFirstname() ?: null, 'lastname' => $user->getLastname() ?: null, - ); + ]; } $start += $perLoop; } while (count($results) > 0); - return array( + return [ 'event' => $this->event->getName(), 'users_were_notified' => isset($data->{'notify_email'}) ?: !!$data->{"notify_email"}, - 'feed' => array( + 'feed' => [ 'id' => $feed->getId(), 'title' => $feed->getTitle(), 'description' => $feed->getSubtitle(), - ), - 'entry' => array( + ], + 'entry' => [ 'id' => $entry->getId(), - 'author' => array( + 'author' => [ 'name' => $entry->getAuthorName(), 'email' => $entry->getAuthorEmail() - ), + ], 'title' => $entry->getTitle(), 'description' => $entry->getSubtitle(), - ), + ], 'users' => $users - ); + ]; } -} \ No newline at end of file +} diff --git a/lib/Alchemy/Phrasea/Webhook/Processor/ProcessorInterface.php b/lib/Alchemy/Phrasea/Webhook/Processor/ProcessorInterface.php index 4d354e04c1..3cb0a0d045 100644 --- a/lib/Alchemy/Phrasea/Webhook/Processor/ProcessorInterface.php +++ b/lib/Alchemy/Phrasea/Webhook/Processor/ProcessorInterface.php @@ -5,4 +5,4 @@ namespace Alchemy\Phrasea\Webhook\Processor; interface ProcessorInterface { public function process(); -} \ No newline at end of file +} diff --git a/lib/classes/API/OAuth2/Adapter.php b/lib/classes/API/OAuth2/Adapter.php index d74020ea4d..89114b0002 100644 --- a/lib/classes/API/OAuth2/Adapter.php +++ b/lib/classes/API/OAuth2/Adapter.php @@ -279,7 +279,7 @@ class API_OAuth2_Adapter extends OAuth2 /** * * Overrides OAuth2::setAuthCode(). - * + * * @param $oauthCode * @param $accountId * @param $redirectUri @@ -421,7 +421,7 @@ class API_OAuth2_Adapter extends OAuth2 /** * At least one of: existing redirect URI or input redirect URI must be specified */ - if ( ! $redirectUri && ! $input["redirect_uri"]) { + if (! $redirectUri && ! $input["redirect_uri"]) { $this->errorJsonResponse(OAUTH2_HTTP_FOUND, OAUTH2_ERROR_INVALID_REQUEST); } @@ -642,7 +642,7 @@ class API_OAuth2_Adapter extends OAuth2 $input = filter_input_array(INPUT_POST, $filters); // Grant Type must be specified. - if ( ! $input["grant_type"]) { + if (! $input["grant_type"]) { $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'Invalid grant_type parameter or parameter missing'); } @@ -669,7 +669,7 @@ class API_OAuth2_Adapter extends OAuth2 // Do the granting switch ($input["grant_type"]) { case OAUTH2_GRANT_TYPE_AUTH_CODE: - if ( ! $input["code"] || ! $input["redirect_uri"]) { + if (! $input["code"] || ! $input["redirect_uri"]) { $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST); } $stored = $this->getAuthCode($input["code"]); @@ -690,7 +690,7 @@ class API_OAuth2_Adapter extends OAuth2 $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_UNSUPPORTED_GRANT_TYPE, 'Password grant type is not enable for your client'); } - if ( ! $input["username"] || ! $input["password"]) { + if (! $input["username"] || ! $input["password"]) { $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'Missing parameters. "username" and "password" required'); } @@ -701,7 +701,7 @@ class API_OAuth2_Adapter extends OAuth2 } break; case OAUTH2_GRANT_TYPE_ASSERTION: - if ( ! $input["assertion_type"] || ! $input["assertion"]) { + if (! $input["assertion_type"] || ! $input["assertion"]) { $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST); } @@ -713,7 +713,7 @@ class API_OAuth2_Adapter extends OAuth2 break; case OAUTH2_GRANT_TYPE_REFRESH_TOKEN: - if ( ! $input["refresh_token"]) { + if (! $input["refresh_token"]) { $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'No "refresh_token" parameter found'); } @@ -744,7 +744,7 @@ class API_OAuth2_Adapter extends OAuth2 $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_SCOPE); } - if ( ! $input["scope"]) { + if (! $input["scope"]) { $input["scope"] = null; } diff --git a/lib/classes/API/Webhook.php b/lib/classes/API/Webhook.php index 413ff913a9..08389682e9 100644 --- a/lib/classes/API/Webhook.php +++ b/lib/classes/API/Webhook.php @@ -29,7 +29,7 @@ class API_Webhook FROM api_webhooks WHERE id = :id'; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $id)); + $stmt->execute([':id' => $id]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); if (!$row) { @@ -48,7 +48,7 @@ class API_Webhook $sql = 'DELETE FROM api_webhooks WHERE id = :id'; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -60,10 +60,10 @@ class API_Webhook VALUES (null, :type, :data, NOW())'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ 'type' => $type, 'data' => json_encode($data), - )); + ]); $stmt->closeCursor(); return new API_Webhook($appbox, $appbox->get_connection()->lastInsertId()); diff --git a/lib/classes/caption/Field/Value.php b/lib/classes/caption/Field/Value.php index 46a4b118c7..5eea6200ed 100644 --- a/lib/classes/caption/Field/Value.php +++ b/lib/classes/caption/Field/Value.php @@ -64,7 +64,7 @@ class caption_Field_Value implements cache_cacheableInterface */ protected $isThesaurusValue; - protected static $localCache = array(); + protected static $localCache = []; /** * @@ -396,7 +396,7 @@ class caption_Field_Value implements cache_cacheableInterface } if ($bestnode) { - list($term, $context) = $this->splitTermAndContext(str_replace(array("[[em]]", "[[/em]]"), array("", ""), $value)); + list($term, $context) = $this->splitTermAndContext(str_replace(["[[em]]", "[[/em]]"], ["", ""], $value)); // a value has been found in thesaurus, update value & set the query to bounce to the value $this->value = $bestnode->getAttribute('v'); $this->qjs = $term . ($context ? '['.$context.']' : ''); diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index 310de1fc18..f3f56773d3 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -174,24 +174,24 @@ class caption_record implements caption_interface, cache_cacheableInterface */ public function get_highlight_fields($highlight = '', Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false, SearchEngineOptions $options = null) { - $fields = array(); + $fields = []; foreach ($this->get_fields($grep_fields, $includeBusiness) as $meta_struct_id => $field) { - $values = array(); + $values = []; foreach ($field->get_values() as $metaId => $v) { - $values[$metaId] = array( + $values[$metaId] = [ 'value' => $v->getValue(), 'from_thesaurus' => $highlight ? $v->isThesaurusValue() : false, 'qjs' => $v->getQjs(), - ); + ]; } - $fields[$field->get_name()] = array( + $fields[$field->get_name()] = [ 'values' => $values, 'name' => $field->get_name(), 'label' => $field->get_databox_field()->get_label($this->app['locale']), 'separator' => $field->get_databox_field()->get_separator(), 'sbas_id' => $field->get_databox_field()->get_databox()->get_sbas_id() - ); + ]; } if ($searchEngine instanceof SearchEngineInterface) { diff --git a/lib/classes/databox/status.php b/lib/classes/databox/status.php index 2117b2ae72..0aeddff4fb 100644 --- a/lib/classes/databox/status.php +++ b/lib/classes/databox/status.php @@ -63,11 +63,11 @@ class databox_status return; } - $uniqid = md5(implode('-', array( + $uniqid = md5(implode('-', [ $sbas_params[$sbas_id]["host"], $sbas_params[$sbas_id]["port"], $sbas_params[$sbas_id]["dbname"] - ))); + ])); $path = $this->path = $app['root.path'] . "/config/status/" . $uniqid; $url = $this->url = "/custom/status/" . $uniqid; diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php index 0e6d1e01de..ac5dc3a4f9 100644 --- a/lib/classes/eventsmanager/notify/feed.php +++ b/lib/classes/eventsmanager/notify/feed.php @@ -63,7 +63,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract $this->app['manipulator.webhook-event']->create( WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, - array_merge(array('feed_id' => $entry->getFeed()->getId()), $params) + array_merge(['feed_id' => $entry->getFeed()->getId()], $params) ); $Query = new \User_Query($this->app); diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php index 2a7af2739a..1db86c6d87 100644 --- a/lib/classes/media/subdef.php +++ b/lib/classes/media/subdef.php @@ -741,7 +741,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface return; } - if ($this->app['phraseanet.h264-factory']->isH264Enabled() && in_array($this->mime, array('video/mp4'))) { + if ($this->app['phraseanet.h264-factory']->isH264Enabled() && in_array($this->mime, ['video/mp4'])) { if (null !== $url = $this->app['phraseanet.h264']->getUrl($this->get_pathfile())) { $this->url = $url; diff --git a/lib/classes/patch/370alpha3a.php b/lib/classes/patch/370alpha3a.php index 094e797f4b..059df55520 100644 --- a/lib/classes/patch/370alpha3a.php +++ b/lib/classes/patch/370alpha3a.php @@ -11,7 +11,6 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\ApiApplication; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class patch_370alpha3a extends patchAbstract { diff --git a/lib/classes/patch/3715alpha1a.php b/lib/classes/patch/3715alpha1a.php index 719f638eec..fc1bf468f8 100644 --- a/lib/classes/patch/3715alpha1a.php +++ b/lib/classes/patch/3715alpha1a.php @@ -11,7 +11,6 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\ApiApplication; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class patch_3715alpha1a extends patchAbstract { diff --git a/lib/classes/patch/384alpha2a.php b/lib/classes/patch/384alpha2a.php index b4b9ef434a..54f84e583e 100644 --- a/lib/classes/patch/384alpha2a.php +++ b/lib/classes/patch/384alpha2a.php @@ -19,7 +19,7 @@ class patch_384alpha2a implements patchInterface private $release = '3.8.4-alpha.2'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/384alpha3a.php b/lib/classes/patch/384alpha3a.php index 8e485a1492..40be3cabd0 100644 --- a/lib/classes/patch/384alpha3a.php +++ b/lib/classes/patch/384alpha3a.php @@ -17,7 +17,7 @@ class patch_384alpha3a implements patchInterface private $release = '3.8.4-alpha.3'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -58,16 +58,16 @@ class patch_384alpha3a implements patchInterface { $config = $app['phraseanet.configuration']->getConfig(); - $config['api_cors'] = array( + $config['api_cors'] = [ 'enabled' => false, 'allow_credentials' => false, - 'allow_origin' => array(), - 'allow_headers' => array(), - 'allow_methods' => array(), - 'expose_headers' => array(), + 'allow_origin' => [], + 'allow_headers' => [], + 'allow_methods' => [], + 'expose_headers' => [], 'max_age' => 0, - 'hosts' => array(), - ); + 'hosts' => [], + ]; $app['phraseanet.configuration']->setConfig($config); diff --git a/lib/classes/patch/384alpha4a.php b/lib/classes/patch/384alpha4a.php index 2748fe8420..d5e14c721d 100644 --- a/lib/classes/patch/384alpha4a.php +++ b/lib/classes/patch/384alpha4a.php @@ -17,7 +17,7 @@ class patch_384alpha4a implements patchInterface private $release = '3.8.4-alpha.4'; /** @var array */ - private $concern = array(base::APPLICATION_BOX); + private $concern = [base::APPLICATION_BOX]; /** * {@inheritdoc} @@ -58,10 +58,10 @@ class patch_384alpha4a implements patchInterface { $config = $app['phraseanet.configuration']->getConfig(); - $config['session'] = array( + $config['session'] = [ 'idle' => 0, 'lifetime' => 604800, - ); + ]; $app['phraseanet.configuration']->setConfig($config); diff --git a/lib/classes/patch/384alpha5a.php b/lib/classes/patch/384alpha5a.php index f477899aaa..4a94a0379c 100644 --- a/lib/classes/patch/384alpha5a.php +++ b/lib/classes/patch/384alpha5a.php @@ -17,7 +17,7 @@ class patch_384alpha5a implements patchInterface private $release = '3.8.4-alpha.5'; /** @var array */ - private $concern = array(base::DATA_BOX); + private $concern = [base::DATA_BOX]; /** * {@inheritdoc} diff --git a/lib/classes/patch/390alpha17a.php b/lib/classes/patch/390alpha17a.php index 1307d3c08f..80264940ee 100644 --- a/lib/classes/patch/390alpha17a.php +++ b/lib/classes/patch/390alpha17a.php @@ -185,7 +185,6 @@ class patch_390alpha17a extends patchAbstract ); } - private function fillOauthTokenTable(EntityManager $em) { if (false === $this->tableExists($em, 'api_oauth_tokens')) { diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index d7f855ee67..89a1894a11 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -896,7 +896,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface 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 $value) { foreach ($value['values'] as $v) { $titles[] = $v['value']; diff --git a/lib/classes/set/export.php b/lib/classes/set/export.php index f93e263b96..68f8556f26 100644 --- a/lib/classes/set/export.php +++ b/lib/classes/set/export.php @@ -761,7 +761,7 @@ class set_export extends set_abstract $tmplog = []; $files = $list['files']; - $event_name = in_array($type, array(Session_Logger::EVENT_EXPORTMAIL,Session_Logger::EVENT_EXPORTDOWNLOAD)) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD; + $event_name = in_array($type, [Session_Logger::EVENT_EXPORTMAIL,Session_Logger::EVENT_EXPORTDOWNLOAD]) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD; foreach ($files as $record) { foreach ($record["subdefs"] as $o => $obj) { diff --git a/lib/conf.d/minifyGroupsConfig.php b/lib/conf.d/minifyGroupsConfig.php index 11a0902a1b..40f5711ee9 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( - 'account' => array( +$groups = [ + 'account' => [ '//include/jslibs/jquery.contextmenu_scroll.js', '//assets/jquery.cookie/jquery.cookie.js', '//include/jquery.common.js', '//skins/account/account.js' - ), - 'authentication_css' => array( + ], + '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' => [ '//assets/modernizr/modernizr.js', '//assets/requirejs/require.js', @@ -150,6 +150,6 @@ $groups = array( '//include/jslibs/SWFUpload/swfupload.js' , '//include/jslibs/SWFUpload/plugins/swfupload.queue.js' ] -); +]; return $groups; diff --git a/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php b/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php index 88716c0900..d6a4edaf26 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/LightboxTest.php @@ -173,9 +173,9 @@ class LightboxTest extends \PhraseanetAuthenticatedWebTestCase { $this->authenticate(self::$DI['app']); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4); - $path = self::$DI['app']['url_generator']->generate('lightbox_validation', array( + $path = self::$DI['app']['url_generator']->generate('lightbox_validation', [ 'basket' => $basket->getId() - )); + ]); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); self::$DI['client']->request('GET', $path); @@ -225,9 +225,9 @@ class LightboxTest extends \PhraseanetAuthenticatedWebTestCase { $this->authenticate(self::$DI['app']); $entry = self::$DI['app']['EM']->find('Phraseanet:Feed', 1)->getEntries()->first(); - $path = self::$DI['app']['url_generator']->generate('lightbox_feed_entry', array( + $path = self::$DI['app']['url_generator']->generate('lightbox_feed_entry', [ 'entry_id' => $entry->getId() - )); + ]); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); self::$DI['client']->request('GET', $path); diff --git a/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php b/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php index d371c63799..dfa57c34fc 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php @@ -27,11 +27,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase self::$DI['app']['acl'] = $aclProvider; - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'subdef' => $subdef, - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -44,11 +44,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase public function testDatafilesNonExistentSubdef() { - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'subdef' => 'unknown_preview', - )); + ]); self::$DI['client']->request('GET', $path); $this->assertNotFoundResponse(self::$DI['client']->getResponse()); @@ -73,11 +73,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase self::$DI['app']['acl'] = $aclProvider; - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'subdef' => 'preview', - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -94,11 +94,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase public function testDatafilesRouteNotAuthenticated() { self::$DI['app']['authentication']->closeAccount(); - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'subdef' => 'preview', - )); + ]); self::$DI['client']->request('GET', $path); $this->assertForbiddenResponse(self::$DI['client']->getResponse()); @@ -108,11 +108,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase { self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock(); self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']); - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => self::$DI['record_5']->get_sbas_id(), 'record_id' => self::$DI['record_5']->get_record_id(), 'subdef' => 'preview', - )); + ]); self::$DI['client']->request('GET', $path); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); @@ -122,11 +122,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase public function testDatafilesRouteNotAuthenticatedUnknownSubdef() { self::$DI['app']['authentication']->closeAccount(); - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'subdef' => 'preview', - )); + ]); self::$DI['client']->request('GET', $path); $this->assertForbiddenResponse(self::$DI['client']->getResponse()); @@ -145,25 +145,25 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); - $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,array( + $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,[ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'label' => 'whatever.jpg', 'subdef' => 'preview', 'token' => $token, 'download' => '1' - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $this->assertRegExp('/^attachment;/', $response->headers->get('content-disposition', '')); - $url = self::$DI['app']['url_generator']->generate('permalinks_caption', array( + $url = self::$DI['app']['url_generator']->generate('permalinks_caption', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'token' => $token, - ), true); + ], true); $this->assertEquals($url, $response->headers->get("Link")); } @@ -193,11 +193,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase public function testCaptionWithaWrongToken() { $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); - $path = self::$DI['app']['url_generator']->generate('permalinks_caption', array( + $path = self::$DI['app']['url_generator']->generate('permalinks_caption', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'token' => 'unexisting_token', - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -208,11 +208,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase public function testCaptionWithaWrongRecord() { $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); - $path = self::$DI['app']['url_generator']->generate('permalinks_caption', array( + $path = self::$DI['app']['url_generator']->generate('permalinks_caption', [ 'sbas_id' => 0, 'record_id' => 4, 'token' => 'unexisting_token', - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -246,11 +246,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase self::$DI['app']['subdef.substituer']->substitute($story, $name, $media); - $path = self::$DI['app']['url_generator']->generate('datafile', array( + $path = self::$DI['app']['url_generator']->generate('datafile', [ 'sbas_id' => $story->get_sbas_id(), 'record_id' => $story->get_record_id(), 'subdef' => $name, - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -260,11 +260,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase private function get_a_caption(array $headers = []) { - $path = self::$DI['app']['url_generator']->generate('permalinks_caption', array( + $path = self::$DI['app']['url_generator']->generate('permalinks_caption', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'token' => self::$DI['record_1']->get_thumbnail()->get_permalink()->get_token(), - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -288,13 +288,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); - $path = self::$DI['app']['url_generator']->generate('permalinks_permalink_old' ,array( + $path = self::$DI['app']['url_generator']->generate('permalinks_permalink_old' ,[ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'label' => 'whatever', 'subdef' => 'preview', 'token' => $token - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -303,11 +303,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase $this->assertEquals($value, $response->headers->get($name)); } - $url = self::$DI['app']['url_generator']->generate('permalinks_caption', array( + $url = self::$DI['app']['url_generator']->generate('permalinks_caption', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'token' => $token, - ), true); + ], true); $this->assertEquals($url, $response->headers->get("Link")); $this->assertTrue($response->isOk()); } @@ -318,11 +318,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase $entry = $feed->getEntries()->first(); $item = $entry->getItems()->first(); - $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', array( + $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', [ 'sbas_id' => $item->getRecord(self::$DI['app'])->get_sbas_id(), 'record_id' => $item->getRecord(self::$DI['app'])->get_record_id(), 'subdef' => 'preview', - )); + ]); self::$DI['app']['authentication']->closeAccount(); self::$DI['client']->request('GET', $path); @@ -333,13 +333,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase private function get_a_permaviewBCcompatibility(array $headers = []) { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); - $path = self::$DI['app']['url_generator']->generate('permalinks_permaview_old' ,array( + $path = self::$DI['app']['url_generator']->generate('permalinks_permaview_old' ,[ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'label' => 'whatever', 'subdef' => 'preview', 'token' => $token - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -354,13 +354,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); - $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,array( + $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,[ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'label' => 'whatever.jpg', 'subdef' => 'preview', 'token' => $token - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); @@ -370,11 +370,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase $this->assertEquals($value, $response->headers->get($name)); } - $url = self::$DI['app']['url_generator']->generate('permalinks_caption', array( + $url = self::$DI['app']['url_generator']->generate('permalinks_caption', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'token' => $token, - ), true); + ], true); $this->assertEquals($url, $response->headers->get("Link")); $this->assertTrue($response->isOk()); @@ -389,12 +389,12 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase { $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); - $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', array( + $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', [ 'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'record_id' => self::$DI['record_1']->get_record_id(), 'subdef' => 'preview', 'token' => $token - )); + ]); self::$DI['client']->request('GET', $path); $response = self::$DI['client']->getResponse(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php index 4c32410b04..92d401a199 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/FieldsTest.php @@ -123,10 +123,10 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase { $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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase '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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase '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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase $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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase $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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase '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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase '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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase $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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase $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 FieldsTest extends \PhraseanetAuthenticatedWebTestCase private function assertField($field) { - $properties = array( + $properties = [ 'name', 'multi', 'thumbtitle', @@ -361,7 +361,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase 'dces-element', 'vocabulary-type', 'vocabulary-restricted' - ); + ]; foreach ($properties as $property) { $this->assertArrayHasKey($property, $field); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php index 5e320c5147..83fe13cf83 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/RootTest.php @@ -24,13 +24,13 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase { $connexion = self::$DI['app']['phraseanet.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(); @@ -49,13 +49,13 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase public function testRouteMysqlFailed() { $connexion = self::$DI['app']['phraseanet.configuration']['main']['database']; - $params = array( + $params = [ "hostname" => $connexion['host'], "port" => $connexion['port'], "user" => $connexion['user'] . 'fake', "password" => $connexion['password'], "dbname" => $connexion['dbname'], - ); + ]; self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); $response = self::$DI['client']->getResponse(); @@ -75,13 +75,13 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase { $connexion = self::$DI['app']['phraseanet.configuration']['main']['database']; - $params = array( + $params = [ "hostname" => $connexion['host'], "port" => $connexion['port'], "user" => $connexion['user'], "password" => $connexion['password'], "dbname" => "fake-database-name" - ); + ]; self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); $response = self::$DI['client']->getResponse(); @@ -104,7 +104,7 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase 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()); @@ -120,7 +120,7 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase 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/Controller/Admin/UsersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php index bb79b1fe74..be4b6316cd 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php @@ -48,7 +48,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test', 'titi@titi.fr'); - self::giveRightsToUser(self::$DI['app'], self::$DI['app']['authentication']->getUser(), array(self::$DI['collection']->get_base_id()), true); + self::giveRightsToUser(self::$DI['app'], self::$DI['app']['authentication']->getUser(), [self::$DI['collection']->get_base_id()], true); self::$DI['client']->request('POST', '/admin/users/rights/apply/', [ 'users' => $user->getId(), @@ -432,7 +432,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase // create a template if (null === self::$DI['app']['repo.users']->findByLogin('csv_template')) { $user = self::$DI['app']['manipulator.user']->createTemplate('csv_template', self::$DI['app']['authentication']->getUser()); - self::$DI['app']['acl']->get($user)->update_rights_to_base(self::$DI['collection']->get_base_id(), array('actif'=> 1)); + self::$DI['app']['acl']->get($user)->update_rights_to_base(self::$DI['collection']->get_base_id(), ['actif'=> 1]); } $nativeQueryMock = $this->getMockBuilder('Alchemy\Phrasea\Model\NativeQueryProvider') @@ -456,11 +456,11 @@ CSV; $filepath = sys_get_temp_dir().'/user.csv'; file_put_contents($filepath,$data); - $files = array( + $files = [ 'files' => new \Symfony\Component\HttpFoundation\File\UploadedFile($filepath, 'user.csv') - ); + ]; - $crawler = self::$DI['client']->request('POST', '/admin/users/import/file/', array(), $files); + $crawler = self::$DI['client']->request('POST', '/admin/users/import/file/', [], $files); $this->assertGreaterThan(0, $crawler->filter('html:contains("4 Users")')->count()); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php b/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php index a4549bd2b2..3544b181f2 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php @@ -7,7 +7,6 @@ use Alchemy\Phrasea\Border\File; use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Authentication\Context; -use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\Task; use Alchemy\Phrasea\Model\Entities\User; use Doctrine\Common\Collections\ArrayCollection; @@ -52,7 +51,6 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase $this->adminAccessToken = current($tokens); } - if (null === $this->userAccessToken) { $tokens = self::$DI['app']['repo.api-oauth-tokens']->findOauthTokens(self::$DI['oauth2-app-acc-user-not-admin']); if (count($tokens) === 0) { diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Api/OAuth2Test.php b/tests/Alchemy/Tests/Phrasea/Controller/Api/OAuth2Test.php index f074e48d30..2cf52b1961 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Api/OAuth2Test.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Api/OAuth2Test.php @@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Controller\Api; use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Authentication\Context; -use Alchemy\Phrasea\Model\Entities\ApiApplication; class OAuth2Test extends \PhraseanetAuthenticatedWebTestCase { diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php index ccf1ffcb5d..9d834752e6 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/BridgeTest.php @@ -44,7 +44,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 1); - self::$DI['client']->request('POST', '/prod/bridge/manager/', array('ssel' => $basket->getId())); + self::$DI['client']->request('POST', '/prod/bridge/manager/', ['ssel' => $basket->getId()]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } @@ -135,7 +135,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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()); } @@ -144,7 +144,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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()); @@ -156,7 +156,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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); @@ -166,7 +166,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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()); @@ -177,7 +177,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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); @@ -188,7 +188,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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); @@ -222,14 +222,14 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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) { @@ -240,14 +240,14 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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()); } @@ -255,11 +255,11 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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()); } @@ -268,7 +268,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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()); } @@ -277,7 +277,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase 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')); } @@ -286,17 +286,17 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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()); } @@ -315,7 +315,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase $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')); } @@ -328,12 +328,12 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase $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()); } @@ -341,16 +341,16 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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()); } @@ -365,22 +365,22 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase { 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/PropertyTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php index d20d4e46c4..fa2f8d5563 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php @@ -61,7 +61,6 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase $story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']); $story->appendChild($record2); - $acl = $this->getMockBuilder('ACL') ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php index 6a82252c06..4c019d6040 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php @@ -93,7 +93,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); $this->assertTrue($record->get_thumbnail()->is_physically_present()); - $field = array_pop($record->get_caption()->get_fields(array('FileName'))); + $field = array_pop($record->get_caption()->get_fields(['FileName'])); $this->assertEquals($field->get_serialized_values(), 'KIKOO.JPG'); } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php index 967bb21d54..e8d5bd8c96 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php @@ -3,7 +3,6 @@ namespace Alchemy\Tests\Phrasea\Controller\Root; use Alchemy\Phrasea\Model\Entities\ApiApplication; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase { diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php index 68abb32e94..c102bb8072 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php @@ -1779,10 +1779,10 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase public function testLoginPageWithIdleSessionTime() { $this->logout(self::$DI['app']); - self::$DI['app']['phraseanet.configuration']['session'] = array( + self::$DI['app']['phraseanet.configuration']['session'] = [ 'idle' =>10, 'lifetime' => 60475, - ); + ]; $crawler = self::$DI['client']->request('GET', '/login/'); @@ -1793,10 +1793,10 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase public function testLoginPageWithNoIdleSessionTime() { $this->logout(self::$DI['app']); - self::$DI['app']['phraseanet.configuration']['session'] = array( + self::$DI['app']['phraseanet.configuration']['session'] = [ 'idle' => 0, 'lifetime' => 60475, - ); + ]; $crawler = self::$DI['client']->request('GET', '/login/'); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiCorsSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiCorsSubscriberTest.php index f4d63635ba..a0afb4adf8 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiCorsSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/ApiCorsSubscriberTest.php @@ -12,17 +12,17 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase public function testHostRestriction() { - $response = $this->request(array('enabled' => true, 'hosts' => array('http://api.domain.com'))); + $response = $this->request(['enabled' => true, 'hosts' => ['http://api.domain.com']]); $this->assertArrayNotHasKey('access-control-allow-origin', $response->headers->all()); - $response = $this->request(array('enabled' => true, 'hosts' => array('localhost'))); + $response = $this->request(['enabled' => true, 'hosts' => ['localhost']]); $this->assertArrayHasKey('access-control-allow-origin', $response->headers->all()); } public function testExposeHeaders() { $response = $this->request( - array('enabled' => true, 'allow_origin' => array('*'), 'expose_headers' => array('HTTP_X_CUSTOM')), + ['enabled' => true, 'allow_origin' => ['*'], 'expose_headers' => ['HTTP_X_CUSTOM']], 'GET' ); $this->assertArrayHasKey('access-control-expose-headers', $response->headers->all()); @@ -32,17 +32,17 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase public function testAllowMethods() { $response = $this->request( - array('enabled' => true, 'allow_origin' => array('*'), 'allow_methods' => array('GET', 'POST', 'PUT')), + ['enabled' => true, 'allow_origin' => ['*'], 'allow_methods' => ['GET', 'POST', 'PUT']], 'OPTIONS' ); $this->assertArrayHasKey('access-control-allow-methods', $response->headers->all()); - $this->assertEquals(implode(', ', array('GET', 'POST', 'PUT')), $response->headers->get('access-control-allow-methods')); + $this->assertEquals(implode(', ', ['GET', 'POST', 'PUT']), $response->headers->get('access-control-allow-methods')); } public function testAllowHeaders() { $response = $this->request( - array('enabled' => true, 'allow_origin' => array('*'), 'allow_headers' => array('HTTP_X_CUSTOM')), + ['enabled' => true, 'allow_origin' => ['*'], 'allow_headers' => ['HTTP_X_CUSTOM']], 'OPTIONS' ); $this->assertArrayHasKey('access-control-allow-headers', $response->headers->all()); @@ -51,26 +51,26 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase public function testCORSIsEnable() { - $response = $this->request(array('enabled' => true)); + $response = $this->request(['enabled' => true]); $this->assertArrayHasKey('access-control-allow-origin', $response->headers->all()); } public function testCORSIsDisable() { - $response = $this->request(array('enabled' => false)); + $response = $this->request(['enabled' => false]); $this->assertArrayNotHasKey('access-control-allow-origin', $response->headers->all()); } public function testAllowOrigin() { - $response = $this->request(array('enabled' => true, 'allow_origin' => array('*'))); + $response = $this->request(['enabled' => true, 'allow_origin' => ['*']]); $this->assertArrayHasKey('access-control-allow-origin', $response->headers->all()); $this->assertEquals($this->origin, $response->headers->get('access-control-allow-origin')); } public function testCredentialIsEnabled() { - $response = $this->request(array('enabled' => true, 'allow_credentials' => true, 'allow_origin' => array('*'))); + $response = $this->request(['enabled' => true, 'allow_credentials' => true, 'allow_origin' => ['*']]); $this->assertArrayHasKey('access-control-allow-credentials', $response->headers->all()); } @@ -81,7 +81,7 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase * * @return \Symfony\Component\HttpFoundation\Response */ - private function request(array $conf, $method = 'GET', array $extraHeaders = array()) + private function request(array $conf, $method = 'GET', array $extraHeaders = []) { $app = new Application('test'); $app['phraseanet.configuration']['api_cors'] = $conf; @@ -91,13 +91,13 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase }); $client = new Client($app); $client->request($method, '/api/v1/test-route', - array(), - array(), + [], + [], array_merge( $extraHeaders, - array( + [ 'HTTP_Origin' => $this->origin, - ) + ] ) ); diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/SessionManagerSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/SessionManagerSubscriberTest.php index b948cdc645..50c835c205 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/SessionManagerSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/SessionManagerSubscriberTest.php @@ -13,10 +13,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase { $app = new Application('test'); $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app)); - $app['phraseanet.configuration']['session'] = array( + $app['phraseanet.configuration']['session'] = [ 'idle' => 0, 'lifetime' => 60475, - ); + ]; $app->get('/login', function () { return ''; @@ -39,10 +39,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase { $app = new Application('test'); $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app)); - $app['phraseanet.configuration']['session'] = array( + $app['phraseanet.configuration']['session'] = [ 'idle' => 0, 'lifetime' => 60475, - ); + ]; $app->get('/login', function () { return ''; @@ -53,11 +53,11 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase }); $client = new Client($app); - $client->request('GET', '/prod', array(), array(), array( + $client->request('GET', '/prod', [], [], [ 'HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest', - )); + ]); $this->assertTrue($client->getResponse()->isClientError()); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); @@ -79,10 +79,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase $app['EM']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null)); - $app['phraseanet.configuration']['session'] = array( + $app['phraseanet.configuration']['session'] = [ 'idle' => 0, 'lifetime' => 60475, - ); + ]; $app->get('/login', function () { return ''; })->bind("homepage"); @@ -114,10 +114,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase $app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null)); - $app['phraseanet.configuration']['session'] = array( + $app['phraseanet.configuration']['session'] = [ 'idle' => 10, 'lifetime' => 60475, - ); + ]; $app->get('/login', function () { return ''; })->bind("homepage"); @@ -152,10 +152,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase $app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null)); - $app['phraseanet.configuration']['session'] = array( + $app['phraseanet.configuration']['session'] = [ 'idle' => 10, 'lifetime' => 60475, - ); + ]; $app->get('/login', function () { return ''; })->bind("homepage"); @@ -165,10 +165,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase }); $client = new Client($app); - $client->request('GET', '/prod', array(), array(), array( + $client->request('GET', '/prod', [], [], [ 'HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest', - )); + ]); $this->assertTrue($client->getResponse()->isClientError()); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); @@ -216,18 +216,18 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase }); $client = new Client($app); - $client->request('GET', $route, array(), array(), array( + $client->request('GET', $route, [], [], [ 'HTTP_CONTENT-TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest', - )); + ]); } public function forbiddenRouteProvider() { - return array( - array('/admin/databox/17/informations/documents/'), - array('/admin/task-manager/tasks/'), - ); + return [ + ['/admin/databox/17/informations/documents/'], + ['/admin/task-manager/tasks/'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiAccountManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiAccountManipulatorTest.php index 90e7da671f..3664a74fb9 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiAccountManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiAccountManipulatorTest.php @@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Model\Manipulator\ApiAccountManipulator; -use Alchemy\Phrasea\Model\Entities\ApiApplication; class ApiAccountManipulatorTest extends \PhraseanetTestCase { diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiLogManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiLogManipulatorTest.php index 6ea7d2c164..14f0ef9190 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiLogManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiLogManipulatorTest.php @@ -24,7 +24,7 @@ class ApiLogManipulatorTest extends \PhraseanetTestCase */ public function testsLogHydration($path, $expected) { - $emMock = $this->getMock('\Doctrine\ORM\EntityManager', array('persist', 'flush'), array(), '', false); + $emMock = $this->getMock('\Doctrine\ORM\EntityManager', ['persist', 'flush'], [], '', false); $account = $this->getMock('\Alchemy\Phrasea\Model\Entities\ApiAccount'); $manipulator = new ApiLogManipulator($emMock, self::$DI['app']['repo.api-logs']); $log = $manipulator->create($account, Request::create($path, 'POST'), new Response()); diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthCodeManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthCodeManipulatorTest.php index 73e2fe906c..00364ccc66 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthCodeManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthCodeManipulatorTest.php @@ -2,11 +2,8 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator; - use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Model\Manipulator\ApiOauthCodeManipulator; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; class ApiOauthCodeManipulatorTest extends \PhraseanetTestCase { diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthTokenManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthTokenManipulatorTest.php index 6096b6ae66..ee06b5278d 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthTokenManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ApiOauthTokenManipulatorTest.php @@ -2,10 +2,7 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Model\Manipulator\ApiLogManipulator; use Alchemy\Phrasea\Model\Manipulator\ApiOauthTokenManipulator; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; class ApiOauthTokenManipulatorTest extends \PhraseanetTestCase { diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulatorTest.php index a61880afea..ca1570bbe4 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventDeliveryManipulatorTest.php @@ -2,9 +2,7 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator; -use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Model\Manipulator\WebhookEventDeliveryManipulator; -use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery; use Alchemy\Phrasea\Model\Manipulator\ApiApplicationManipulator; use Alchemy\Phrasea\Model\Entities\ApiApplication; diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php index 789184c9c0..e0b4dabdbd 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/WebhookEventManipulatorTest.php @@ -3,7 +3,6 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator; use Alchemy\Phrasea\Model\Manipulator\WebhookEventManipulator; -use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery; use Alchemy\Phrasea\Model\Entities\WebhookEvent; class WebhookEventManipulatorTest extends \PhraseanetTestCase @@ -12,18 +11,18 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase { $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-delivery']); $nbEvents = count(self::$DI['app']['repo.webhook-event']->findAll()); - $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( + $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() - )); + ]); $this->assertGreaterThan($nbEvents, count(self::$DI['app']['repo.webhook-event']->findAll())); } public function testDelete() { $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']); - $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( + $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() - )); + ]); $countBefore = count(self::$DI['app']['repo.webhook-event']->findAll()); $manipulator->delete($event); $this->assertGreaterThan(count(self::$DI['app']['repo.webhook-event']->findAll()), $countBefore); @@ -32,9 +31,9 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase public function testUpdate() { $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']); - $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( + $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() - )); + ]); $event->setProcessed(true); $manipulator->update($event); $event = self::$DI['app']['repo.webhook-event']->find($event->getId()); @@ -44,9 +43,9 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase public function testProcessed() { $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']); - $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( + $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() - )); + ]); $manipulator->processed($event); $this->assertTrue($event->isProcessed()); } diff --git a/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthCodeRepositoryTest.php b/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthCodeRepositoryTest.php index e75d5e2bac..808e407ec1 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthCodeRepositoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthCodeRepositoryTest.php @@ -2,8 +2,6 @@ namespace Alchemy\Tests\Phrasea\Model\Repositories; -use Alchemy\Phrasea\Model\Entities\ApiApplication; - class ApiOauthCodeRepositoryTest extends \PhraseanetTestCase { public function testFindByAccount() diff --git a/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthTokenRepositoryTest.php b/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthTokenRepositoryTest.php index 5de03d5525..2bdf64a154 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthTokenRepositoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Repositories/ApiOauthTokenRepositoryTest.php @@ -2,8 +2,6 @@ namespace Alchemy\Tests\Phrasea\Model\Repositories; -use Alchemy\Phrasea\Model\Entities\ApiApplication; - class ApiOauthTokenRepositoryTest extends \PhraseanetTestCase { public function testFindDeveloperToken() diff --git a/tests/Alchemy/Tests/Phrasea/Notification/Mail/MailTestCase.php b/tests/Alchemy/Tests/Phrasea/Notification/Mail/MailTestCase.php index 24dfc7d66c..26844b725f 100644 --- a/tests/Alchemy/Tests/Phrasea/Notification/Mail/MailTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/Notification/Mail/MailTestCase.php @@ -3,7 +3,6 @@ namespace Alchemy\Tests\Phrasea\Notification\Mail; use Alchemy\Phrasea\Notification\Mail\MailInterface; -use Symfony\Component\Routing\RequestContext; abstract class MailTestCase extends \PhraseanetTestCase { diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php index 19a65eab86..8711f54534 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SearchEngineAbstractTest.php @@ -735,17 +735,17 @@ abstract class SearchEngineAbstractTest extends \PhraseanetAuthenticatedTestCase foreach ($foundRecord->get_caption()->get_fields() as $field) { foreach ($field->get_values() as $metaId => $v) { - $values[$metaId] = array( + $values[$metaId] = [ 'value' => $v->getValue(), 'from_thesaurus' => false, 'qjs' => null, - ); + ]; } - $fields[$field->get_name()] = array( + $fields[$field->get_name()] = [ 'values' => $values, 'separator' => ';', - ); + ]; } $found = false; diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WebhookJobTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WebhookJobTest.php index bc09dd07c5..00293e4cc8 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WebhookJobTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Job/WebhookJobTest.php @@ -4,7 +4,7 @@ namespace Alchemy\Tests\Phrasea\TaskManager\Job; use Alchemy\Phrasea\TaskManager\Job\WebhookJob; -class WebhookJobTestJobTest extends JobTestCase +class WebhookJobTest extends JobTestCase { protected function getJob() { diff --git a/tests/Alchemy/Tests/Phrasea/Webhook/EventProcessorFactoryTest.php b/tests/Alchemy/Tests/Phrasea/Webhook/EventProcessorFactoryTest.php index b1007679d8..52908582c1 100644 --- a/tests/Alchemy/Tests/Phrasea/Webhook/EventProcessorFactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Webhook/EventProcessorFactoryTest.php @@ -30,8 +30,8 @@ class EventProcessorFactoryTest extends \PhraseanetTestCase public function eventProvider() { - return array( - array(WebhookEvent::FEED_ENTRY_TYPE, 'Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor'), - ); + return [ + [WebhookEvent::FEED_ENTRY_TYPE, 'Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor'], + ]; } } diff --git a/tests/Alchemy/Tests/Phrasea/Webhook/Processor/FeedEntryProcessorTest.php b/tests/Alchemy/Tests/Phrasea/Webhook/Processor/FeedEntryProcessorTest.php index 9a54f3690d..9b4655d9ab 100644 --- a/tests/Alchemy/Tests/Phrasea/Webhook/Processor/FeedEntryProcessorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Webhook/Processor/FeedEntryProcessorTest.php @@ -11,10 +11,10 @@ class FeedEntryProcessorTest extends \PhraseanetTestCase public function testProcessWithNoFeedId() { $event = new WebhookEvent(); - $event->setData(array( + $event->setData([ 'feed_id' => 0, 'entry_id' => 0 - )); + ]); $event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setType(WebhookEvent::FEED_ENTRY_TYPE); $processor = new FeedEntryProcessor($event, self::$DI['app']); @@ -24,23 +24,22 @@ class FeedEntryProcessorTest extends \PhraseanetTestCase public function testProcessWithMissingDataProperty() { $event = new WebhookEvent(); - $event->setData(array( + $event->setData([ 'feed_id' => 0, - )); + ]); $event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setType(WebhookEvent::FEED_ENTRY_TYPE); $processor = new FeedEntryProcessor($event, self::$DI['app']); $this->assertEquals($processor->process(), null); } - public function testProcess() { $event = new WebhookEvent(); - $event->setData(array( + $event->setData([ 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() - )); + ]); $event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setType(WebhookEvent::FEED_ENTRY_TYPE); $processor = new FeedEntryProcessor($event, self::$DI['app']); diff --git a/tests/classes/PhraseanetPHPUnitListener.php b/tests/classes/PhraseanetPHPUnitListener.php index ec5931fb7f..d582f2850b 100644 --- a/tests/classes/PhraseanetPHPUnitListener.php +++ b/tests/classes/PhraseanetPHPUnitListener.php @@ -115,6 +115,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener private static function generateName(PHPUnit_Framework_Test $test) { $reflect = new \ReflectionClass($test); + return $reflect->getShortName() . '::' . $test->getName(); } }