Convert array + phpDoc

Thanks for https://github.com/thomasbachem/php-short-array-syntax-converter
This commit is contained in:
Jeremy Benoist 2016-04-12 11:36:01 +02:00
parent 7eccbda99f
commit 4094ea4771
61 changed files with 596 additions and 558 deletions

View file

@ -30,7 +30,7 @@ class WallabagAnnotationController extends FOSRestController
->getRepository('WallabagAnnotationBundle:Annotation')
->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId());
$total = count($annotationRows);
$annotations = array('total' => $total, 'rows' => $annotationRows);
$annotations = ['total' => $total, 'rows' => $annotationRows];
$json = $this->get('serializer')->serialize($annotations, 'json');
@ -141,6 +141,6 @@ class WallabagAnnotationController extends FOSRestController
*/
private function renderJsonResponse($json, $code = 200)
{
return new Response($json, $code, array('application/json'));
return new Response($json, $code, ['application/json']);
}
}

View file

@ -35,13 +35,13 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
->getRepository('WallabagCoreBundle:Entry')
->findOneByUsernameAndNotArchived('admin');
$headers = array('CONTENT_TYPE' => 'application/json');
$content = json_encode(array(
$headers = ['CONTENT_TYPE' => 'application/json'];
$content = json_encode([
'text' => 'my annotation',
'quote' => 'my quote',
'ranges' => array('start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31),
));
$crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', array(), array(), $headers, $content);
'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
]);
$crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', [], [], $headers, $content);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -69,11 +69,11 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
$this->logInAs('admin');
$headers = array('CONTENT_TYPE' => 'application/json');
$content = json_encode(array(
$headers = ['CONTENT_TYPE' => 'application/json'];
$content = json_encode([
'text' => 'a modified annotation',
));
$crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
]);
$crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
@ -99,11 +99,11 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
$this->logInAs('admin');
$headers = array('CONTENT_TYPE' => 'application/json');
$content = json_encode(array(
$headers = ['CONTENT_TYPE' => 'application/json'];
$content = json_encode([
'text' => 'a modified annotation',
));
$crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
]);
$crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);

View file

@ -26,10 +26,10 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
{
$crawler = $this->client->request('GET', '/login');
$form = $crawler->filter('button[type=submit]')->form();
$data = array(
$data = [
'_username' => $username,
'_password' => 'mypassword',
);
];
$this->client->submit($form, $data);
}
@ -48,7 +48,7 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
$this->user = $userManager->findUserBy(array('username' => 'admin'));
$this->user = $userManager->findUserBy(['username' => 'admin']);
$loginManager->loginUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie

View file

@ -384,6 +384,6 @@ class WallabagRestController extends FOSRestController
*/
private function renderJsonResponse($json)
{
return new Response($json, 200, array('application/json'));
return new Response($json, 200, ['application/json']);
}
}

View file

@ -13,7 +13,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
$entry = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findOneBy(array('user' => 1, 'isArchived' => false));
->findOneBy(['user' => 1, 'isArchived' => false]);
if (!$entry) {
$this->markTestSkipped('No content found in db.');
@ -44,7 +44,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
$entry = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findOneBy(array('user' => 2, 'isArchived' => false));
->findOneBy(['user' => 2, 'isArchived' => false]);
if (!$entry) {
$this->markTestSkipped('No content found in db.');
@ -79,7 +79,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
public function testGetStarredEntries()
{
$this->client->request('GET', '/api/entries', array('star' => 1, 'sort' => 'updated'));
$this->client->request('GET', '/api/entries', ['star' => 1, 'sort' => 'updated']);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -101,7 +101,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
public function testGetArchiveEntries()
{
$this->client->request('GET', '/api/entries', array('archive' => 1));
$this->client->request('GET', '/api/entries', ['archive' => 1]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -149,10 +149,10 @@ class WallabagRestControllerTest extends WallabagApiTestCase
public function testPostEntry()
{
$this->client->request('POST', '/api/entries.json', array(
$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
'tags' => 'google',
));
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -168,11 +168,11 @@ class WallabagRestControllerTest extends WallabagApiTestCase
public function testPostSameEntry()
{
$this->client->request('POST', '/api/entries.json', array(
$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
'archive' => '1',
'tags' => 'google, apple',
));
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -187,11 +187,11 @@ class WallabagRestControllerTest extends WallabagApiTestCase
public function testPostArchivedAndStarredEntry()
{
$this->client->request('POST', '/api/entries.json', array(
$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
'archive' => '1',
'starred' => '1',
));
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -206,11 +206,11 @@ class WallabagRestControllerTest extends WallabagApiTestCase
public function testPostArchivedAndStarredEntryWithoutQuotes()
{
$this->client->request('POST', '/api/entries.json', array(
$this->client->request('POST', '/api/entries.json', [
'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
'archive' => 0,
'starred' => 1,
));
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -236,12 +236,12 @@ class WallabagRestControllerTest extends WallabagApiTestCase
// hydrate the tags relations
$nbTags = count($entry->getTags());
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array(
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
'title' => 'New awesome title',
'tags' => 'new tag '.uniqid(),
'starred' => '1',
'archive' => '0',
));
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -268,12 +268,12 @@ class WallabagRestControllerTest extends WallabagApiTestCase
// hydrate the tags relations
$nbTags = count($entry->getTags());
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array(
$this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
'title' => 'New awesome title',
'tags' => 'new tag '.uniqid(),
'starred' => 1,
'archive' => 0,
));
]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -298,9 +298,9 @@ class WallabagRestControllerTest extends WallabagApiTestCase
$this->markTestSkipped('No content found in db.');
}
$tags = array();
$tags = [];
foreach ($entry->getTags() as $tag) {
$tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug());
$tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
}
$this->client->request('GET', '/api/entries/'.$entry->getId().'/tags');
@ -323,7 +323,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
$newTags = 'tag1,tag2,tag3';
$this->client->request('POST', '/api/entries/'.$entry->getId().'/tags', array('tags' => $newTags));
$this->client->request('POST', '/api/entries/'.$entry->getId().'/tags', ['tags' => $newTags]);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -337,7 +337,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase
->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId());
$tagsInDB = array();
$tagsInDB = [];
foreach ($entryDB->getTags()->toArray() as $tag) {
$tagsInDB[$tag->getId()] = $tag->getLabel();
}

View file

@ -36,7 +36,7 @@ abstract class WallabagApiTestCase extends WebTestCase
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
$this->user = $userManager->findUserBy(array('username' => 'admin'));
$this->user = $userManager->findUserBy(['username' => 'admin']);
$loginManager->loginUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie

View file

@ -32,7 +32,7 @@ class ConfigController extends Controller
$user = $this->getUser();
// handle basic config detail (this form is defined as a service)
$configForm = $this->createForm(ConfigType::class, $config, array('action' => $this->generateUrl('config')));
$configForm = $this->createForm(ConfigType::class, $config, ['action' => $this->generateUrl('config')]);
$configForm->handleRequest($request);
if ($configForm->isValid()) {
@ -52,7 +52,7 @@ class ConfigController extends Controller
}
// handle changing password
$pwdForm = $this->createForm(ChangePasswordType::class, null, array('action' => $this->generateUrl('config').'#set4'));
$pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']);
$pwdForm->handleRequest($request);
if ($pwdForm->isValid()) {
@ -71,10 +71,10 @@ class ConfigController extends Controller
}
// handle changing user information
$userForm = $this->createForm(UserInformationType::class, $user, array(
'validation_groups' => array('Profile'),
$userForm = $this->createForm(UserInformationType::class, $user, [
'validation_groups' => ['Profile'],
'action' => $this->generateUrl('config').'#set3',
));
]);
$userForm->handleRequest($request);
if ($userForm->isValid()) {
@ -89,7 +89,7 @@ class ConfigController extends Controller
}
// handle rss information
$rssForm = $this->createForm(RssType::class, $config, array('action' => $this->generateUrl('config').'#set2'));
$rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']);
$rssForm->handleRequest($request);
if ($rssForm->isValid()) {
@ -106,7 +106,7 @@ class ConfigController extends Controller
// handle tagging rule
$taggingRule = new TaggingRule();
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, array('action' => $this->generateUrl('config').'#set5'));
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']);
$newTaggingRule->handleRequest($request);
if ($newTaggingRule->isValid()) {
@ -126,10 +126,10 @@ class ConfigController extends Controller
$newUser = $userManager->createUser();
// enable created user by default
$newUser->setEnabled(true);
$newUserForm = $this->createForm(NewUserType::class, $newUser, array(
'validation_groups' => array('Profile'),
$newUserForm = $this->createForm(NewUserType::class, $newUser, [
'validation_groups' => ['Profile'],
'action' => $this->generateUrl('config').'#set6',
));
]);
$newUserForm->handleRequest($request);
if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
@ -147,27 +147,27 @@ class ConfigController extends Controller
$this->get('session')->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.config.notice.user_added', array('%username%' => $newUser->getUsername()))
$this->get('translator')->trans('flashes.config.notice.user_added', ['%username%' => $newUser->getUsername()])
);
return $this->redirect($this->generateUrl('config').'#set6');
}
return $this->render('WallabagCoreBundle:Config:index.html.twig', array(
'form' => array(
return $this->render('WallabagCoreBundle:Config:index.html.twig', [
'form' => [
'config' => $configForm->createView(),
'rss' => $rssForm->createView(),
'pwd' => $pwdForm->createView(),
'user' => $userForm->createView(),
'new_user' => $newUserForm->createView(),
'new_tagging_rule' => $newTaggingRule->createView(),
),
'rss' => array(
],
'rss' => [
'username' => $user->getUsername(),
'token' => $config->getRssToken(),
),
],
'twofactor_auth' => $this->getParameter('twofactor_auth'),
));
]);
}
/**
@ -187,7 +187,7 @@ class ConfigController extends Controller
$em->flush();
if ($request->isXmlHttpRequest()) {
return new JsonResponse(array('token' => $config->getRssToken()));
return new JsonResponse(['token' => $config->getRssToken()]);
}
$this->get('session')->getFlashBag()->add(
@ -229,7 +229,7 @@ class ConfigController extends Controller
* Retrieve config for the current user.
* If no config were found, create a new one.
*
* @return Wallabag\CoreBundle\Entity\Config
* @return Config
*/
private function getConfig()
{

View file

@ -21,9 +21,9 @@ class DeveloperController extends Controller
{
$clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findAll();
return $this->render('WallabagCoreBundle:Developer:index.html.twig', array(
return $this->render('WallabagCoreBundle:Developer:index.html.twig', [
'clients' => $clients,
));
]);
}
/**
@ -43,7 +43,7 @@ class DeveloperController extends Controller
$clientForm->handleRequest($request);
if ($clientForm->isValid()) {
$client->setAllowedGrantTypes(array('token', 'authorization_code', 'password', 'refresh_token'));
$client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']);
$em->persist($client);
$em->flush();
@ -52,15 +52,15 @@ class DeveloperController extends Controller
'flashes.developer.notice.client_created'
);
return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', array(
return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', [
'client_id' => $client->getPublicId(),
'client_secret' => $client->getSecret(),
));
]);
}
return $this->render('WallabagCoreBundle:Developer:client.html.twig', array(
return $this->render('WallabagCoreBundle:Developer:client.html.twig', [
'form' => $clientForm->createView(),
));
]);
}
/**

View file

@ -54,10 +54,10 @@ class EntryController extends Controller
if (false !== $existingEntry) {
$this->get('session')->getFlashBag()->add(
'notice',
$this->get('translator')->trans('flashes.entry.notice.entry_already_saved', array('%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')))
$this->get('translator')->trans('flashes.entry.notice.entry_already_saved', ['%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')])
);
return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId())));
return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
}
$this->updateEntry($entry);
@ -69,9 +69,9 @@ class EntryController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', array(
return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', [
'form' => $form->createView(),
));
]);
}
/**
@ -131,12 +131,12 @@ class EntryController extends Controller
'flashes.entry.notice.entry_updated'
);
return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
return $this->render('WallabagCoreBundle:Entry:edit.html.twig', array(
return $this->render('WallabagCoreBundle:Entry:edit.html.twig', [
'form' => $form->createView(),
));
]);
}
/**
@ -257,17 +257,17 @@ class EntryController extends Controller
$entries->setCurrentPage($page);
} catch (OutOfRangeCurrentPageException $e) {
if ($page > 1) {
return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302);
return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
}
}
return $this->render(
'WallabagCoreBundle:Entry:entries.html.twig',
array(
[
'form' => $form->createView(),
'entries' => $entries,
'currentPage' => $page,
)
]
);
}
@ -286,7 +286,7 @@ class EntryController extends Controller
return $this->render(
'WallabagCoreBundle:Entry:entry.html.twig',
array('entry' => $entry)
['entry' => $entry]
);
}
@ -314,7 +314,7 @@ class EntryController extends Controller
$message
);
return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
/**
@ -394,7 +394,7 @@ class EntryController extends Controller
// to avoid redirecting to the deleted entry. Ugh.
$url = $this->generateUrl(
'view',
array('id' => $entry->getId()),
['id' => $entry->getId()],
UrlGeneratorInterface::ABSOLUTE_URL
);
@ -426,11 +426,11 @@ class EntryController extends Controller
/**
* Check for existing entry, if it exists, redirect to it with a message.
*
* @param $entry
* @param Entry $entry
*
* @return array|bool
* @return Entry|bool
*/
private function checkIfEntryAlreadyExists($entry)
private function checkIfEntryAlreadyExists(Entry $entry)
{
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
}

View file

@ -16,12 +16,15 @@ class ExportController extends Controller
/**
* Gets one entry content.
*
* @param Entry $entry
* @param Entry $entry
* @param string $format
*
* @Route("/export/{id}.{format}", name="export_entry", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv",
* "id": "\d+"
* })
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function downloadEntryAction(Entry $entry, $format)
{
@ -38,10 +41,15 @@ class ExportController extends Controller
/**
* Export all entries for current user.
*
* @param string $format
* @param string $category
*
* @Route("/export/{category}.{format}", name="export_entries", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv",
* "category": "all|unread|starred|archive"
* })
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function downloadEntriesAction($format, $category)
{

View file

@ -87,9 +87,9 @@ class RssController extends Controller
$perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit');
$entries->setMaxPerPage($perPage);
return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', [
'type' => $type,
'entries' => $entries,
));
]);
}
}

View file

@ -14,7 +14,7 @@ class StaticController extends Controller
{
return $this->render(
'WallabagCoreBundle:Static:howto.html.twig',
array()
[]
);
}
@ -25,10 +25,10 @@ class StaticController extends Controller
{
return $this->render(
'WallabagCoreBundle:Static:about.html.twig',
array(
[
'version' => $this->getParameter('wallabag_core.version'),
'paypal_url' => $this->getParameter('wallabag_core.paypal_url'),
)
]
);
}
@ -39,7 +39,7 @@ class StaticController extends Controller
{
return $this->render(
'WallabagCoreBundle:Static:quickstart.html.twig',
array()
[]
);
}
}

View file

@ -13,6 +13,7 @@ class TagController extends Controller
{
/**
* @param Request $request
* @param Entry $entry
*
* @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag")
*
@ -38,13 +39,13 @@ class TagController extends Controller
'flashes.tag.notice.tag_added'
);
return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
}
return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array(
return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', [
'form' => $form->createView(),
'entry' => $entry,
));
]);
}
/**
@ -82,9 +83,9 @@ class TagController extends Controller
return $this->render(
'WallabagCoreBundle:Tag:tags.html.twig',
array(
[
'tags' => $tags,
)
]
);
}
}

View file

@ -16,14 +16,14 @@ class LoadTaggingRuleData extends AbstractFixture implements OrderedFixtureInter
{
$tr1 = new TaggingRule();
$tr1->setRule('content matches "spurs"');
$tr1->setTags(array('sport'));
$tr1->setTags(['sport']);
$tr1->setConfig($this->getReference('admin-config'));
$manager->persist($tr1);
$tr2 = new TaggingRule();
$tr2->setRule('content matches "basket"');
$tr2->setTags(array('sport'));
$tr2->setTags(['sport']);
$tr2->setConfig($this->getReference('admin-config'));
$manager->persist($tr2);

View file

@ -36,9 +36,9 @@ class LocaleListener implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
return [
// must be registered before the default Locale listener
KernelEvents::REQUEST => array(array('onKernelRequest', 17)),
);
KernelEvents::REQUEST => [['onKernelRequest', 17]],
];
}
}

View file

@ -28,9 +28,9 @@ class RegistrationConfirmedListener implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
return [
FOSUserEvents::REGISTRATION_CONFIRMED => 'authenticate',
);
];
}
public function authenticate(FilterUserResponseEvent $event, $eventName = null, EventDispatcherInterface $eventDispatcher = null)

View file

@ -15,28 +15,28 @@ class ChangePasswordType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('old_password', PasswordType::class, array(
'constraints' => new UserPassword(array('message' => 'validator.password_wrong_value')),
->add('old_password', PasswordType::class, [
'constraints' => new UserPassword(['message' => 'validator.password_wrong_value']),
'label' => 'config.form_password.old_password_label',
))
->add('new_password', RepeatedType::class, array(
])
->add('new_password', RepeatedType::class, [
'type' => PasswordType::class,
'invalid_message' => 'validator.password_must_match',
'required' => true,
'first_options' => array('label' => 'config.form_password.new_password_label'),
'second_options' => array('label' => 'config.form_password.repeat_new_password_label'),
'constraints' => array(
new Constraints\Length(array(
'first_options' => ['label' => 'config.form_password.new_password_label'],
'second_options' => ['label' => 'config.form_password.repeat_new_password_label'],
'constraints' => [
new Constraints\Length([
'min' => 8,
'minMessage' => 'validator.password_too_short',
)),
]),
new Constraints\NotBlank(),
),
],
'label' => 'config.form_password.new_password_label',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
))
])
;
}

View file

@ -14,8 +14,8 @@ class ClientType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('redirect_uris', UrlType::class, array('required' => true, 'label' => 'developer.client.form.redirect_uris_label'))
->add('save', SubmitType::class, array('label' => 'developer.client.form.save_label'))
->add('redirect_uris', UrlType::class, ['required' => true, 'label' => 'developer.client.form.redirect_uris_label'])
->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
;
$builder->get('redirect_uris')
@ -24,7 +24,7 @@ class ClientType extends AbstractType
return $originalUri;
},
function ($submittedUri) {
return array($submittedUri);
return [$submittedUri];
}
))
;
@ -32,9 +32,9 @@ class ClientType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\ApiBundle\Entity\Client',
));
]);
}
public function getBlockPrefix()

View file

@ -10,8 +10,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ConfigType extends AbstractType
{
private $themes = array();
private $languages = array();
private $themes = [];
private $languages = [];
/**
* @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes)
@ -30,39 +30,39 @@ class ConfigType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('theme', ChoiceType::class, array(
->add('theme', ChoiceType::class, [
'choices' => array_flip($this->themes),
'choices_as_values' => true,
'label' => 'config.form_settings.theme_label',
))
->add('items_per_page', null, array(
])
->add('items_per_page', null, [
'label' => 'config.form_settings.items_per_page_label',
))
->add('reading_speed', ChoiceType::class, array(
])
->add('reading_speed', ChoiceType::class, [
'label' => 'config.form_settings.reading_speed.label',
'choices' => array(
'choices' => [
'config.form_settings.reading_speed.100_word' => '0.5',
'config.form_settings.reading_speed.200_word' => '1',
'config.form_settings.reading_speed.300_word' => '1.5',
'config.form_settings.reading_speed.400_word' => '2',
),
))
->add('language', ChoiceType::class, array(
],
])
->add('language', ChoiceType::class, [
'choices' => array_flip($this->languages),
'choices_as_values' => true,
'label' => 'config.form_settings.language_label',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
))
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Config',
));
]);
}
public function getBlockPrefix()

View file

@ -14,30 +14,30 @@ class EditEntryType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, array(
->add('title', TextType::class, [
'required' => true,
'label' => 'entry.edit.title_label',
))
->add('is_public', CheckboxType::class, array(
])
->add('is_public', CheckboxType::class, [
'required' => false,
'label' => 'entry.edit.is_public_label',
))
->add('url', TextType::class, array(
])
->add('url', TextType::class, [
'disabled' => true,
'required' => false,
'label' => 'entry.edit.url_label',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'entry.edit.save_label',
))
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Entry',
));
]);
}
public function getBlockPrefix()

View file

@ -34,28 +34,28 @@ class EntryFilterType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('readingTime', NumberRangeFilterType::class, array(
->add('readingTime', NumberRangeFilterType::class, [
'label' => 'entry.filters.reading_time.label',
))
->add('createdAt', DateRangeFilterType::class, array(
'left_date_options' => array(
'attr' => array(
])
->add('createdAt', DateRangeFilterType::class, [
'left_date_options' => [
'attr' => [
'placeholder' => 'dd/mm/yyyy',
),
],
'format' => 'dd/MM/yyyy',
'widget' => 'single_text',
),
'right_date_options' => array(
'attr' => array(
],
'right_date_options' => [
'attr' => [
'placeholder' => 'dd/mm/yyyy',
),
],
'format' => 'dd/MM/yyyy',
'widget' => 'single_text',
),
],
'label' => 'entry.filters.created_at.label',
)
]
)
->add('domainName', TextFilterType::class, array(
->add('domainName', TextFilterType::class, [
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
$value = $values['value'];
if (strlen($value) <= 2 || empty($value)) {
@ -66,14 +66,14 @@ class EntryFilterType extends AbstractType
return $filterQuery->createCondition($expression);
},
'label' => 'entry.filters.domain_label',
))
->add('isArchived', CheckboxFilterType::class, array(
])
->add('isArchived', CheckboxFilterType::class, [
'label' => 'entry.filters.archived_label',
))
->add('isStarred', CheckboxFilterType::class, array(
])
->add('isStarred', CheckboxFilterType::class, [
'label' => 'entry.filters.starred_label',
))
->add('previewPicture', CheckboxFilterType::class, array(
])
->add('previewPicture', CheckboxFilterType::class, [
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
if (false === $values['value']) {
return;
@ -84,12 +84,12 @@ class EntryFilterType extends AbstractType
return $filterQuery->createCondition($expression);
},
'label' => 'entry.filters.preview_picture_label',
))
->add('language', ChoiceFilterType::class, array(
])
->add('language', ChoiceFilterType::class, [
'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())),
'choices_as_values' => true,
'label' => 'entry.filters.language_label',
))
])
;
}
@ -100,9 +100,9 @@ class EntryFilterType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'csrf_protection' => false,
'validation_groups' => array('filtering'),
));
'validation_groups' => ['filtering'],
]);
}
}

View file

@ -12,18 +12,18 @@ class NewEntryType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('url', UrlType::class, array(
->add('url', UrlType::class, [
'required' => true,
'label' => 'entry.new.form_new.url_label',
))
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Entry',
));
]);
}
public function getBlockPrefix()

View file

@ -12,15 +12,15 @@ class NewTagType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('label', TextType::class, array('required' => true))
->add('label', TextType::class, ['required' => true])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Tag',
));
]);
}
public function getBlockPrefix()

View file

@ -17,38 +17,38 @@ class NewUserType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username', TextType::class, array(
->add('username', TextType::class, [
'required' => true,
'label' => 'config.form_new_user.username_label',
))
->add('plainPassword', RepeatedType::class, array(
])
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'invalid_message' => 'validator.password_must_match',
'first_options' => array('label' => 'config.form_new_user.password_label'),
'second_options' => array('label' => 'config.form_new_user.repeat_new_password_label'),
'constraints' => array(
new Constraints\Length(array(
'first_options' => ['label' => 'config.form_new_user.password_label'],
'second_options' => ['label' => 'config.form_new_user.repeat_new_password_label'],
'constraints' => [
new Constraints\Length([
'min' => 8,
'minMessage' => 'validator.password_too_short',
)),
]),
new Constraints\NotBlank(),
),
],
'label' => 'config.form_new_user.plain_password_label',
))
->add('email', EmailType::class, array(
])
->add('email', EmailType::class, [
'label' => 'config.form_new_user.email_label',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
))
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\UserBundle\Entity\User',
));
]);
}
public function getBlockPrefix()

View file

@ -12,20 +12,20 @@ class RssType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('rss_limit', null, array(
->add('rss_limit', null, [
'label' => 'config.form_rss.rss_limit',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
))
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\Config',
));
]);
}
public function getBlockPrefix()

View file

@ -14,19 +14,19 @@ class TaggingRuleType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('rule', TextType::class, array(
->add('rule', TextType::class, [
'required' => true,
'label' => 'config.form_rules.rule_label',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
))
])
;
$tagsField = $builder
->create('tags', TextType::class, array(
->create('tags', TextType::class, [
'label' => 'config.form_rules.tags_label',
))
])
->addModelTransformer(new StringToListTransformer(','));
$builder->add($tagsField);
@ -34,9 +34,9 @@ class TaggingRuleType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\CoreBundle\Entity\TaggingRule',
));
]);
}
public function getBlockPrefix()

View file

@ -15,19 +15,19 @@ class UserInformationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, array(
->add('name', TextType::class, [
'label' => 'config.form_user.name_label',
))
->add('email', EmailType::class, array(
])
->add('email', EmailType::class, [
'label' => 'config.form_user.email_label',
))
->add('twoFactorAuthentication', CheckboxType::class, array(
])
->add('twoFactorAuthentication', CheckboxType::class, [
'required' => false,
'label' => 'config.form_user.twoFactorAuthentication_label',
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'config.form.save',
))
])
->remove('username')
->remove('plainPassword')
;
@ -40,9 +40,9 @@ class UserInformationType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => 'Wallabag\UserBundle\Entity\User',
));
]);
}
public function getBlockPrefix()

View file

@ -82,10 +82,10 @@ class ContentProxy
try {
$this->tagger->tag($entry);
} catch (\Exception $e) {
$this->logger->error('Error while trying to automatically tag an entry.', array(
$this->logger->error('Error while trying to automatically tag an entry.', [
'entry_url' => $url,
'error_msg' => $e->getMessage(),
));
]);
}
return $entry;

View file

@ -18,10 +18,10 @@ class EntriesExport
private $wallabagUrl;
private $logoPath;
private $title = '';
private $entries = array();
private $authors = array('wallabag');
private $entries = [];
private $authors = ['wallabag'];
private $language = '';
private $tags = array();
private $tags = [];
private $footerTemplate = '<div style="text-align:center;">
<p>Produced by wallabag with %EXPORT_METHOD%</p>
<p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p>
@ -41,12 +41,14 @@ class EntriesExport
* Define entries.
*
* @param array|Entry $entries An array of entries or one entry
*
* @return EntriesExport
*/
public function setEntries($entries)
{
if (!is_array($entries)) {
$this->language = $entries->getLanguage();
$entries = array($entries);
$entries = [$entries];
}
$this->entries = $entries;
@ -62,6 +64,8 @@ class EntriesExport
* Sets the category of which we want to get articles, or just one entry.
*
* @param string $method Method to get articles
*
* @return EntriesExport
*/
public function updateTitle($method)
{
@ -78,6 +82,8 @@ class EntriesExport
* Sets the output format.
*
* @param string $format
*
* @return Response
*/
public function exportAs($format)
{
@ -91,6 +97,8 @@ class EntriesExport
/**
* Use PHPePub to dump a .epub file.
*
* @return Response
*/
private function produceEpub()
{
@ -162,17 +170,19 @@ class EntriesExport
return Response::create(
$book->getBook(),
200,
array(
[
'Content-Description' => 'File Transfer',
'Content-type' => 'application/epub+zip',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"',
'Content-Transfer-Encoding' => 'binary',
)
]
);
}
/**
* Use PHPMobi to dump a .mobi file.
*
* @return Response
*/
private function produceMobi()
{
@ -211,18 +221,20 @@ class EntriesExport
return Response::create(
$mobi->toString(),
200,
array(
[
'Accept-Ranges' => 'bytes',
'Content-Description' => 'File Transfer',
'Content-type' => 'application/x-mobipocket-ebook',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"',
'Content-Transfer-Encoding' => 'binary',
)
]
);
}
/**
* Use TCPDF to dump a .pdf file.
*
* @return Response
*/
private function producePdf()
{
@ -266,17 +278,19 @@ class EntriesExport
return Response::create(
$pdf->Output('', 'S'),
200,
array(
[
'Content-Description' => 'File Transfer',
'Content-type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"',
'Content-Transfer-Encoding' => 'binary',
)
]
);
}
/**
* Inspired from CsvFileDumper.
*
* @return Response
*/
private function produceCsv()
{
@ -284,20 +298,20 @@ class EntriesExport
$enclosure = '"';
$handle = fopen('php://memory', 'rb+');
fputcsv($handle, array('Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'), $delimiter, $enclosure);
fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'], $delimiter, $enclosure);
foreach ($this->entries as $entry) {
fputcsv(
$handle,
array(
[
$entry->getTitle(),
$entry->getURL(),
// remove new line to avoid crazy results
str_replace(array("\r\n", "\r", "\n"), '', $entry->getContent()),
str_replace(["\r\n", "\r", "\n"], '', $entry->getContent()),
implode(', ', $entry->getTags()->toArray()),
$entry->getMimetype(),
$entry->getLanguage(),
),
],
$delimiter,
$enclosure
);
@ -310,40 +324,55 @@ class EntriesExport
return Response::create(
$output,
200,
array(
[
'Content-type' => 'application/csv',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"',
'Content-Transfer-Encoding' => 'UTF-8',
)
]
);
}
/**
* Dump a JSON file.
*
* @return Response
*/
private function produceJson()
{
return Response::create(
$this->prepareSerializingContent('json'),
200,
array(
[
'Content-type' => 'application/json',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"',
'Content-Transfer-Encoding' => 'UTF-8',
)
]
);
}
/**
* Dump a XML file.
*
* @return Response
*/
private function produceXml()
{
return Response::create(
$this->prepareSerializingContent('xml'),
200,
array(
[
'Content-type' => 'application/xml',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"',
'Content-Transfer-Encoding' => 'UTF-8',
)
]
);
}
/**
* Dump a TXT file.
*
* @return Response
*/
private function produceTxt()
{
$content = '';
@ -356,11 +385,11 @@ class EntriesExport
return Response::create(
$content,
200,
array(
[
'Content-type' => 'text/plain',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
'Content-Transfer-Encoding' => 'UTF-8',
)
]
);
}
@ -378,7 +407,7 @@ class EntriesExport
return $serializer->serialize(
$this->entries,
$format,
SerializationContext::create()->setGroups(array('entries_for_user'))
SerializationContext::create()->setGroups(['entries_for_user'])
);
}

View file

@ -54,7 +54,7 @@ class RuleBasedTagger
public function tagAllForUser(User $user)
{
$rules = $this->getRulesForUser($user);
$entries = array();
$entries = [];
foreach ($rules as $rule) {
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());

View file

@ -157,7 +157,7 @@ class EntryRepository extends EntityRepository
->getQuery()
->getResult();
$languages = array();
$languages = [];
foreach ($results as $result) {
$languages[$result['language']] = $result['language'];
}
@ -233,7 +233,7 @@ class EntryRepository extends EntityRepository
* @param $url
* @param $userId
*
* @return array|bool
* @return Entry|bool
*/
public function findByUrlAndUserId($url, $userId)
{

View file

@ -27,7 +27,7 @@ class TablePrefixSubscriber implements EventSubscriber
public function getSubscribedEvents()
{
return array('loadClassMetadata');
return ['loadClassMetadata'];
}
public function loadClassMetadata(LoadClassMetadataEventArgs $args)

View file

@ -37,11 +37,11 @@ class InstallCommandTest extends WallabagCoreTestCase
$application = new Application(static::$kernel);
$application->setAutoExit(false);
$code = $application->run(new ArrayInput(array(
$code = $application->run(new ArrayInput([
'command' => 'doctrine:fixtures:load',
'--no-interaction' => true,
'--env' => 'test',
)), new NullOutput());
]), new NullOutput());
}
public function testRunInstallCommand()
@ -63,9 +63,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
));
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
@ -93,10 +93,10 @@ class InstallCommandTest extends WallabagCoreTestCase
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
'--reset' => true,
));
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
@ -116,10 +116,10 @@ class InstallCommandTest extends WallabagCoreTestCase
// drop database first, so the install command won't ask to reset things
$command = $application->find('doctrine:database:drop');
$command->run(new ArrayInput(array(
$command->run(new ArrayInput([
'command' => 'doctrine:database:drop',
'--force' => true,
)), new NullOutput());
]), new NullOutput());
// start a new application to avoid lagging connexion to pgsql
$client = static::createClient();
@ -140,9 +140,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
));
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
@ -178,9 +178,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
));
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
@ -201,19 +201,19 @@ class InstallCommandTest extends WallabagCoreTestCase
// drop database first, so the install command won't ask to reset things
$command = new DropDatabaseDoctrineCommand();
$command->setApplication($application);
$command->run(new ArrayInput(array(
$command->run(new ArrayInput([
'command' => 'doctrine:database:drop',
'--force' => true,
)), new NullOutput());
]), new NullOutput());
$this->getClient()->getContainer()->get('doctrine')->getConnection()->close();
$command = new CreateDatabaseDoctrineCommand();
$command->setApplication($application);
$command->run(new ArrayInput(array(
$command->run(new ArrayInput([
'command' => 'doctrine:database:create',
'--env' => 'test',
)), new NullOutput());
]), new NullOutput());
$command = $application->find('wallabag:install');
@ -233,9 +233,9 @@ class InstallCommandTest extends WallabagCoreTestCase
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
));
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());
@ -265,10 +265,10 @@ class InstallCommandTest extends WallabagCoreTestCase
$command->getHelperSet()->set($question, 'question');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
'--no-interaction' => true,
));
]);
$this->assertContains('Checking system requirements.', $tester->getDisplay());
$this->assertContains('Setting up database.', $tester->getDisplay());

View file

@ -21,9 +21,9 @@ class TagAllCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:tag:all');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
));
]);
}
public function testRunTagAllCommandWithBadUsername()
@ -34,10 +34,10 @@ class TagAllCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:tag:all');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
'username' => 'unknown',
));
]);
$this->assertContains('User "unknown" not found', $tester->getDisplay());
}
@ -50,10 +50,10 @@ class TagAllCommandTest extends WallabagCoreTestCase
$command = $application->find('wallabag:tag:all');
$tester = new CommandTester($command);
$tester->execute(array(
$tester->execute([
'command' => $command->getName(),
'username' => 'admin',
));
]);
$this->assertContains('Tagging entries for user « admin »... Done', $tester->getDisplay());
}

View file

@ -43,12 +43,12 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=config_save]')->form();
$data = array(
$data = [
'config[theme]' => 'baggy',
'config[items_per_page]' => '30',
'config[reading_speed]' => '0.5',
'config[language]' => 'en',
);
];
$client->submit($form, $data);
@ -56,19 +56,19 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.config_saved', $alert[0]);
}
public function dataForUpdateFailed()
{
return array(
array(array(
return [
[[
'config[theme]' => 'baggy',
'config[items_per_page]' => '',
'config[language]' => 'en',
)),
);
]],
];
}
/**
@ -89,46 +89,46 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains('This value should not be blank', $alert[0]);
}
public function dataForChangePasswordFailed()
{
return array(
array(
array(
return [
[
[
'change_passwd[old_password]' => 'material',
'change_passwd[new_password][first]' => '',
'change_passwd[new_password][second]' => '',
),
],
'validator.password_wrong_value',
),
array(
array(
],
[
[
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => '',
'change_passwd[new_password][second]' => '',
),
],
'This value should not be blank',
),
array(
array(
],
[
[
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'hop',
'change_passwd[new_password][second]' => '',
),
],
'validator.password_must_match',
),
array(
array(
],
[
[
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'hop',
'change_passwd[new_password][second]' => 'hop',
),
],
'validator.password_too_short',
),
);
],
];
}
/**
@ -149,7 +149,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
@ -164,11 +164,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=change_passwd_save]')->form();
$data = array(
$data = [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'mypassword',
'change_passwd[new_password][second]' => 'mypassword',
);
];
$client->submit($form, $data);
@ -176,28 +176,28 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.password_updated', $alert[0]);
}
public function dataForUserFailed()
{
return array(
array(
array(
return [
[
[
'update_user[name]' => '',
'update_user[email]' => '',
),
],
'fos_user.email.blank',
),
array(
array(
],
[
[
'update_user[name]' => '',
'update_user[email]' => 'test',
),
],
'fos_user.email.invalid',
),
);
],
];
}
/**
@ -218,7 +218,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
@ -233,10 +233,10 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=update_user_save]')->form();
$data = array(
$data = [
'update_user[name]' => 'new name',
'update_user[email]' => 'admin@wallabag.io',
);
];
$client->submit($form, $data);
@ -244,59 +244,59 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.config.notice.user_updated', $alert[0]);
}
public function dataForNewUserFailed()
{
return array(
array(
array(
return [
[
[
'new_user[username]' => '',
'new_user[plainPassword][first]' => '',
'new_user[plainPassword][second]' => '',
'new_user[email]' => '',
),
],
'fos_user.username.blank',
),
array(
array(
],
[
[
'new_user[username]' => 'a',
'new_user[plainPassword][first]' => 'mypassword',
'new_user[plainPassword][second]' => 'mypassword',
'new_user[email]' => '',
),
],
'fos_user.username.short',
),
array(
array(
],
[
[
'new_user[username]' => 'wallace',
'new_user[plainPassword][first]' => 'mypassword',
'new_user[plainPassword][second]' => 'mypassword',
'new_user[email]' => 'test',
),
],
'fos_user.email.invalid',
),
array(
array(
],
[
[
'new_user[username]' => 'admin',
'new_user[plainPassword][first]' => 'wallacewallace',
'new_user[plainPassword][second]' => 'wallacewallace',
'new_user[email]' => 'wallace@wallace.me',
),
],
'fos_user.username.already_used',
),
array(
array(
],
[
[
'new_user[username]' => 'wallace',
'new_user[plainPassword][first]' => 'mypassword1',
'new_user[plainPassword][second]' => 'mypassword2',
'new_user[email]' => 'wallace@wallace.me',
),
],
'validator.password_must_match',
),
);
],
];
}
/**
@ -317,7 +317,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
@ -332,12 +332,12 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=new_user_save]')->form();
$data = array(
$data = [
'new_user[username]' => 'wallace',
'new_user[plainPassword][first]' => 'wallace1',
'new_user[plainPassword][second]' => 'wallace1',
'new_user[email]' => 'wallace@wallace.me',
);
];
$client->submit($form, $data);
@ -345,7 +345,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.user_added', $alert[0]);
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
@ -381,7 +381,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('config.form_rss.no_token', $body[0]);
$client->request('GET', '/generate-token');
@ -389,7 +389,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertNotContains('config.form_rss.no_token', $body[0]);
}
@ -401,9 +401,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
$client->request(
'GET',
'/generate-token',
array(),
array(),
array('HTTP_X-Requested-With' => 'XMLHttpRequest')
[],
[],
['HTTP_X-Requested-With' => 'XMLHttpRequest']
);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
@ -422,9 +422,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=rss_config_save]')->form();
$data = array(
$data = [
'rss_config[rss_limit]' => 12,
);
];
$client->submit($form, $data);
@ -432,26 +432,26 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.rss_updated', $alert[0]);
}
public function dataForRssFailed()
{
return array(
array(
array(
return [
[
[
'rss_config[rss_limit]' => 0,
),
],
'This value should be 1 or more.',
),
array(
array(
],
[
[
'rss_config[rss_limit]' => 1000000000000,
),
],
'validator.rss_limit_too_hight',
),
);
],
];
}
/**
@ -472,7 +472,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
}
@ -487,10 +487,10 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
$data = array(
$data = [
'tagging_rule[rule]' => 'readingTime <= 3',
'tagging_rule[tags]' => 'short reading',
);
];
$client->submit($form, $data);
@ -498,7 +498,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.tagging_rules_updated', $alert[0]);
$deleteLink = $crawler->filter('.delete')->last()->link();
@ -507,34 +507,34 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text']));
$this->assertContains('flashes.config.notice.tagging_rules_deleted', $alert[0]);
}
public function dataForTaggingRuleFailed()
{
return array(
array(
array(
return [
[
[
'tagging_rule[rule]' => 'unknownVar <= 3',
'tagging_rule[tags]' => 'cool tag',
),
array(
],
[
'The variable',
'does not exist.',
),
),
array(
array(
],
],
[
[
'tagging_rule[rule]' => 'length(domainName) <= 42',
'tagging_rule[tags]' => 'cool tag',
),
array(
],
[
'The operator',
'does not exist.',
),
),
);
],
],
];
}
/**
@ -555,7 +555,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
foreach ($messages as $message) {
$this->assertContains($message, $body[0]);
@ -574,7 +574,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId());
$this->assertEquals(403, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('You can not access this tagging rule', $body[0]);
}
@ -593,11 +593,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=change_passwd_save]')->form();
$data = array(
$data = [
'change_passwd[old_password]' => 'mypassword',
'change_passwd[new_password][first]' => 'mypassword',
'change_passwd[new_password][second]' => 'mypassword',
);
];
$client->submit($form, $data);

View file

@ -28,7 +28,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('quickstart.intro.paragraph_1', $body[0]);
// Test if quickstart is disabled when user has 1 entry
@ -38,16 +38,16 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('form[name=entry]')->form();
$data = array(
$data = [
'entry[url]' => $this->url,
);
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/unread/list');
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('entry.list.number_on_the_page', $body[0]);
}
@ -74,7 +74,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertCount(4, $crawler->filter('div[class=entry]'));
// Good URL
$client->request('GET', '/bookmarklet', array('url' => $this->url));
$client->request('GET', '/bookmarklet', ['url' => $this->url]);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/');
@ -103,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->submit($form);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text')));
$this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text']));
$this->assertEquals('This value should not be blank.', $alert[0]);
}
@ -121,9 +121,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('form[name=entry]')->form();
$data = array(
$data = [
'entry[url]' => $this->url,
);
];
$client->submit($form, $data);
@ -150,9 +150,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('form[name=entry]')->form();
$data = array(
$data = [
'entry[url]' => $this->url,
);
];
$client->submit($form, $data);
@ -174,9 +174,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('form[name=entry]')->form();
$data = array(
$data = [
'entry[url]' => $url = 'https://github.com/wallabag/wallabag',
);
];
$client->submit($form, $data);
@ -245,7 +245,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/view/'.$content->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains($content->getTitle(), $body[0]);
}
@ -315,9 +315,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[type=submit]')->form();
$data = array(
$data = [
'entry[title]' => 'My updated title hehe :)',
);
];
$client->submit($form, $data);
@ -325,7 +325,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(array('_text')));
$this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text']));
$this->assertContains('My updated title hehe :)', $alert[0]);
}
@ -461,10 +461,10 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
$data = [
'entry_filter[readingTime][right_number]' => 11,
'entry_filter[readingTime][left_number]' => 11,
);
];
$crawler = $client->submit($form, $data);
@ -480,28 +480,28 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
$data = [
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')),
);
];
$crawler = $client->submit($form, $data);
$this->assertCount(5, $crawler->filter('div[class=entry]'));
$data = array(
$data = [
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
'entry_filter[createdAt][right_date]' => date('d/m/Y'),
);
];
$crawler = $client->submit($form, $data);
$this->assertCount(5, $crawler->filter('div[class=entry]'));
$data = array(
$data = [
'entry_filter[createdAt][left_date]' => '01/01/1970',
'entry_filter[createdAt][right_date]' => '01/01/1970',
);
];
$crawler = $client->submit($form, $data);
@ -516,9 +516,9 @@ class EntryControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('button[id=config_save]')->form();
$data = array(
$data = [
'config[items_per_page]' => '1',
);
];
$client->submit($form, $data);
@ -531,9 +531,9 @@ class EntryControllerTest extends WallabagCoreTestCase
// reset pagination
$crawler = $client->request('GET', '/config');
$form = $crawler->filter('button[id=config_save]')->form();
$data = array(
$data = [
'config[items_per_page]' => '12',
);
];
$client->submit($form, $data);
}
@ -544,17 +544,17 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
$data = [
'entry_filter[domainName]' => 'domain',
);
];
$crawler = $client->submit($form, $data);
$this->assertCount(5, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
$data = [
'entry_filter[domainName]' => 'wallabag',
);
];
$crawler = $client->submit($form, $data);
$this->assertCount(0, $crawler->filter('div[class=entry]'));
@ -601,17 +601,17 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
$data = [
'entry_filter[language]' => 'fr',
);
];
$crawler = $client->submit($form, $data);
$this->assertCount(2, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
$data = [
'entry_filter[language]' => 'en',
);
];
$crawler = $client->submit($form, $data);
$this->assertCount(2, $crawler->filter('div[class=entry]'));

View file

@ -34,17 +34,17 @@ class RssControllerTest extends WallabagCoreTestCase
public function dataForBadUrl()
{
return array(
array(
return [
[
'/admin/YZIOAUZIAO/unread.xml',
),
array(
],
[
'/wallace/YZIOAUZIAO/starred.xml',
),
array(
],
[
'/wallace/YZIOAUZIAO/archives.xml',
),
);
],
];
}
/**

View file

@ -13,7 +13,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
$client->followRedirects();
$crawler = $client->request('GET', '/config');
$this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(array('_text'))[0]);
$this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]);
}
public function testLoginWith2Factor()
@ -38,7 +38,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
$this->logInAs('admin');
$crawler = $client->request('GET', '/config');
$this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(array('_text'))[0]);
$this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
// restore user
$user = $em

View file

@ -32,9 +32,9 @@ class TagControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('form[name=tag]')->form();
$data = array(
$data = [
'tag[label]' => $this->tagName,
);
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
@ -53,9 +53,9 @@ class TagControllerTest extends WallabagCoreTestCase
$this->assertEquals(1, count($newEntry->getTags()));
# tag already exists but still not assigned to this entry
$data = array(
$data = [
'tag[label]' => 'foo',
);
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
@ -82,9 +82,9 @@ class TagControllerTest extends WallabagCoreTestCase
$form = $crawler->filter('form[name=tag]')->form();
$data = array(
$data = [
'tag[label]' => 'foo2, bar2',
);
];
$client->submit($form, $data);
$this->assertEquals(302, $client->getResponse()->getStatusCode());

View file

@ -18,12 +18,12 @@ class StringToListTransformerTest extends \PHPUnit_Framework_TestCase
public function transformProvider()
{
return array(
array(null, ''),
array(array(), ''),
array(array('single value'), 'single value'),
array(array('first value', 'second value'), 'first value,second value'),
);
return [
[null, ''],
[[], ''],
[['single value'], 'single value'],
[['first value', 'second value'], 'first value,second value'],
];
}
/**
@ -38,13 +38,13 @@ class StringToListTransformerTest extends \PHPUnit_Framework_TestCase
public function reverseTransformProvider()
{
return array(
array(null, null),
array('', array()),
array('single value', array('single value')),
array('first value,second value', array('first value', 'second value')),
array('first value, second value', array('first value', 'second value')),
array('first value, , second value', array('first value', 'second value')),
);
return [
[null, null],
['', []],
['single value', ['single value']],
['first value,second value', ['first value', 'second value']],
['first value, second value', ['first value', 'second value']],
['first value, , second value', ['first value', 'second value']],
];
}
}

View file

@ -17,19 +17,19 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
->setMethods(array('fetchContent'))
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
->willReturn(array(
->willReturn([
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
));
]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80');
@ -51,19 +51,19 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
->setMethods(array('fetchContent'))
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
->willReturn(array(
->willReturn([
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
));
]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
@ -85,23 +85,23 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
->setMethods(array('fetchContent'))
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
->willReturn(array(
->willReturn([
'html' => false,
'title' => '',
'url' => '',
'content_type' => '',
'language' => '',
'open_graph' => array(
'open_graph' => [
'og_title' => 'my title',
'og_description' => 'desc',
),
));
],
]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
@ -123,24 +123,24 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
->method('tag');
$graby = $this->getMockBuilder('Graby\Graby')
->setMethods(array('fetchContent'))
->setMethods(['fetchContent'])
->disableOriginalConstructor()
->getMock();
$graby->expects($this->any())
->method('fetchContent')
->willReturn(array(
->willReturn([
'html' => str_repeat('this is my content', 325),
'title' => 'this is my title',
'url' => 'http://1.1.1.1',
'content_type' => 'text/html',
'language' => 'fr',
'open_graph' => array(
'open_graph' => [
'og_title' => 'my OG title',
'og_description' => 'OG desc',
'og_image' => 'http://3.3.3.3/cover.jpg',
),
));
],
]);
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger());
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
@ -217,7 +217,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->assignTagsToEntry($entry, array(' tag1', 'tag2 '));
$proxy->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
$this->assertCount(2, $entry->getTags());
$this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
@ -253,7 +253,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$entry = new Entry(new User());
$proxy->assignTagsToEntry($entry, array());
$proxy->assignTagsToEntry($entry, []);
$this->assertCount(0, $entry->getTags());
}
@ -299,7 +299,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
private function getTaggerMock()
{
return $this->getMockBuilder('Wallabag\CoreBundle\Helper\RuleBasedTagger')
->setMethods(array('tag'))
->setMethods(['tag'])
->disableOriginalConstructor()
->getMock();
}

View file

@ -36,7 +36,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
public function testTagWithNoMatchingRule()
{
$taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar'));
$taggingRule = $this->getTaggingRule('rule as string', ['foo', 'bar']);
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
@ -53,7 +53,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
public function testTagWithAMatchingRule()
{
$taggingRule = $this->getTaggingRule('rule as string', array('foo', 'bar'));
$taggingRule = $this->getTaggingRule('rule as string', ['foo', 'bar']);
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
@ -74,8 +74,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
public function testTagWithAMixOfMatchingRules()
{
$taggingRule = $this->getTaggingRule('bla bla', array('hey'));
$otherTaggingRule = $this->getTaggingRule('rule as string', array('foo'));
$taggingRule = $this->getTaggingRule('bla bla', ['hey']);
$otherTaggingRule = $this->getTaggingRule('rule as string', ['foo']);
$user = $this->getUser([$taggingRule, $otherTaggingRule]);
$entry = new Entry($user);
@ -94,7 +94,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
public function testWhenTheTagExists()
{
$taggingRule = $this->getTaggingRule('rule as string', array('foo'));
$taggingRule = $this->getTaggingRule('rule as string', ['foo']);
$user = $this->getUser([$taggingRule]);
$entry = new Entry($user);
$tag = new Tag();
@ -122,8 +122,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
public function testSameTagWithDifferentfMatchingRules()
{
$taggingRule = $this->getTaggingRule('bla bla', array('hey'));
$otherTaggingRule = $this->getTaggingRule('rule as string', array('hey'));
$taggingRule = $this->getTaggingRule('bla bla', ['hey']);
$otherTaggingRule = $this->getTaggingRule('rule as string', ['hey']);
$user = $this->getUser([$taggingRule, $otherTaggingRule]);
$entry = new Entry($user);
@ -142,7 +142,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
public function testTagAllEntriesForAUser()
{
$taggingRule = $this->getTaggingRule('bla bla', array('hey'));
$taggingRule = $this->getTaggingRule('bla bla', ['hey']);
$user = $this->getUser([$taggingRule]);
@ -152,7 +152,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
$this->rulerz
->method('filter')
->willReturn(array(new Entry($user), new Entry($user)));
->willReturn([new Entry($user), new Entry($user)]);
$entries = $this->tagger->tagAllForUser($user);

View file

@ -15,7 +15,7 @@ use Wallabag\CoreBundle\Command\InstallCommand;
*/
class InstallCommandMock extends InstallCommand
{
protected function runCommand($command, $parameters = array())
protected function runCommand($command, $parameters = [])
{
return $this;
}

View file

@ -11,7 +11,7 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
{
public function testSupportsWithNoRegistry()
{
$params = new ParamConverter(array());
$params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter();
$this->assertFalse($converter->supports($params));
@ -25,9 +25,9 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
$registry->expects($this->once())
->method('getManagers')
->will($this->returnValue(array()));
->will($this->returnValue([]));
$params = new ParamConverter(array());
$params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter($registry);
$this->assertFalse($converter->supports($params));
@ -41,9 +41,9 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
$registry->expects($this->once())
->method('getManagers')
->will($this->returnValue(array('default' => null)));
->will($this->returnValue(['default' => null]));
$params = new ParamConverter(array());
$params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter($registry);
$this->assertFalse($converter->supports($params));
@ -74,14 +74,14 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
$registry->expects($this->once())
->method('getManagers')
->will($this->returnValue(array('default' => null)));
->will($this->returnValue(['default' => null]));
$registry->expects($this->once())
->method('getManagerForClass')
->with('superclass')
->will($this->returnValue($em));
$params = new ParamConverter(array('class' => 'superclass'));
$params = new ParamConverter(['class' => 'superclass']);
$converter = new UsernameRssTokenConverter($registry);
$this->assertFalse($converter->supports($params));
@ -112,14 +112,14 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
$registry->expects($this->once())
->method('getManagers')
->will($this->returnValue(array('default' => null)));
->will($this->returnValue(['default' => null]));
$registry->expects($this->once())
->method('getManagerForClass')
->with('WallabagUserBundle:User')
->will($this->returnValue($em));
$params = new ParamConverter(array('class' => 'WallabagUserBundle:User'));
$params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
$converter = new UsernameRssTokenConverter($registry);
$this->assertTrue($converter->supports($params));
@ -131,7 +131,7 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
*/
public function testApplyEmptyRequest()
{
$params = new ParamConverter(array());
$params = new ParamConverter([]);
$converter = new UsernameRssTokenConverter();
$converter->apply(new Request(), $params);
@ -170,9 +170,9 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
->with('WallabagUserBundle:User')
->will($this->returnValue($em));
$params = new ParamConverter(array('class' => 'WallabagUserBundle:User'));
$params = new ParamConverter(['class' => 'WallabagUserBundle:User']);
$converter = new UsernameRssTokenConverter($registry);
$request = new Request(array(), array(), array('username' => 'test', 'token' => 'test'));
$request = new Request([], [], ['username' => 'test', 'token' => 'test']);
$converter->apply($request, $params);
}
@ -208,9 +208,9 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
->with('WallabagUserBundle:User')
->will($this->returnValue($em));
$params = new ParamConverter(array('class' => 'WallabagUserBundle:User', 'name' => 'user'));
$params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']);
$converter = new UsernameRssTokenConverter($registry);
$request = new Request(array(), array(), array('username' => 'test', 'token' => 'test'));
$request = new Request([], [], ['username' => 'test', 'token' => 'test']);
$converter->apply($request, $params);

View file

@ -11,23 +11,23 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
{
public function dataForPrefix()
{
return array(
array('wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
array('wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '`wallabag_user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
array('wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
return [
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '`wallabag_user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'wallabag_user', '"wallabag_user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
array('wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
array('wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
array('wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['wallabag_', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'wallabag_user', 'wallabag_user', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
array('', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
array('', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '`user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
array('', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '`user`', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', '`user`', 'user', 'user', '"user"', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
array('', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()),
array('', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\MySqlPlatform()),
array('', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\SqlitePlatform()),
);
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\PostgreSqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\MySqlPlatform()],
['', 'Wallabag\UserBundle\Entity\User', 'user', 'user', 'user', 'user', new \Doctrine\DBAL\Platforms\SqlitePlatform()],
];
}
/**
@ -42,7 +42,7 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
$subscriber = new TablePrefixSubscriber($prefix);
$metaClass = new ClassMetadata($entityName);
$metaClass->setPrimaryTable(array('name' => $tableName));
$metaClass->setPrimaryTable(['name' => $tableName]);
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
@ -64,7 +64,7 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
->getMock();
$metaClass = new ClassMetadata($entityName);
$metaClass->setPrimaryTable(array('name' => $tableName));
$metaClass->setPrimaryTable(['name' => $tableName]);
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
@ -88,18 +88,18 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
$subscriber = new TablePrefixSubscriber('yo_');
$metaClass = new ClassMetadata('Wallabag\UserBundle\Entity\Entry');
$metaClass->setPrimaryTable(array('name' => 'entry'));
$metaClass->mapManyToMany(array(
$metaClass->setPrimaryTable(['name' => 'entry']);
$metaClass->mapManyToMany([
'fieldName' => 'tags',
'joinTable' => array('name' => null, 'schema' => null),
'joinTable' => ['name' => null, 'schema' => null],
'targetEntity' => 'Tag',
'mappedBy' => null,
'inversedBy' => 'entries',
'cascade' => array('persist'),
'cascade' => ['persist'],
'indexBy' => null,
'orphanRemoval' => false,
'fetch' => 2,
));
]);
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);

View file

@ -24,10 +24,10 @@ abstract class WallabagCoreTestCase extends WebTestCase
{
$crawler = $this->client->request('GET', '/login');
$form = $crawler->filter('button[type=submit]')->form();
$data = array(
$data = [
'_username' => $username,
'_password' => 'mypassword',
);
];
$this->client->submit($form, $data);
}

View file

@ -16,7 +16,7 @@ class Utils
$token = substr(base64_encode(random_bytes($length)), 0, $length);
// remove character which can broken the url
return str_replace(array('+', '/'), '', $token);
return str_replace(['+', '/'], '', $token);
}
/**

View file

@ -6,9 +6,9 @@ class WallabagExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
new \Twig_SimpleFilter('removeWww', array($this, 'removeWww')),
);
return [
new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']),
];
}
public function removeWww($url)

View file

@ -17,10 +17,10 @@ class PocketController extends Controller
{
$pocket = $this->get('wallabag_import.pocket.import');
$form = $this->createFormBuilder($pocket)
->add('mark_as_read', CheckboxType::class, array(
->add('mark_as_read', CheckboxType::class, [
'label' => 'import.form.mark_as_read_label',
'required' => false,
))
])
->getForm();
return $this->render('WallabagImportBundle:Pocket:index.html.twig', [
@ -36,7 +36,7 @@ class PocketController extends Controller
public function authAction(Request $request)
{
$requestToken = $this->get('wallabag_import.pocket.import')
->getRequestToken($this->generateUrl('import', array(), UrlGeneratorInterface::ABSOLUTE_URL));
->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL));
if (false === $requestToken) {
$this->get('session')->getFlashBag()->add(
@ -51,7 +51,7 @@ class PocketController extends Controller
$this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
return $this->redirect(
'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL),
'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
301
);
}
@ -79,10 +79,10 @@ class PocketController extends Controller
if (true === $pocket->setMarkAsRead($markAsRead)->import()) {
$summary = $pocket->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', array(
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
));
]);
}
$this->get('session')->getFlashBag()->add(

View file

@ -55,10 +55,10 @@ abstract class WallabagController extends Controller
if (true === $res) {
$summary = $wallabag->getSummary();
$message = $this->get('translator')->trans('flashes.import.notice.summary', array(
$message = $this->get('translator')->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
));
]);
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
}

View file

@ -13,16 +13,16 @@ class UploadImportType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('file', FileType::class, array(
->add('file', FileType::class, [
'label' => 'import.form.file_label',
))
->add('mark_as_read', CheckboxType::class, array(
])
->add('mark_as_read', CheckboxType::class, [
'label' => 'import.form.mark_as_read_label',
'required' => false,
))
->add('save', SubmitType::class, array(
])
->add('save', SubmitType::class, [
'label' => 'import.form.save_label',
))
])
;
}

View file

@ -29,9 +29,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
$data = array(
$data = [
'upload_import_file[file]' => $file,
);
];
$client->submit($form, $data);
@ -54,7 +54,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$this->assertTrue($content->getTags()->contains($tag));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
}
@ -68,10 +68,10 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json');
$data = array(
$data = [
'upload_import_file[file]' => $file,
'upload_import_file[mark_as_read]' => 1,
);
];
$client->submit($form, $data);
@ -99,7 +99,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$this->assertTrue($content2->isArchived());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
}
@ -113,9 +113,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
$data = array(
$data = [
'upload_import_file[file]' => $file,
);
];
$client->submit($form, $data);
@ -123,7 +123,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.failed', $body[0]);
}
}

View file

@ -29,9 +29,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
$data = array(
$data = [
'upload_import_file[file]' => $file,
);
];
$client->submit($form, $data);
@ -39,7 +39,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.summary', $body[0]);
$content = $client->getContainer()
@ -79,9 +79,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
$data = array(
$data = [
'upload_import_file[file]' => $file,
);
];
$client->submit($form, $data);
@ -89,7 +89,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
$crawler = $client->followRedirect();
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('flashes.import.notice.failed', $body[0]);
}
}

View file

@ -25,7 +25,7 @@ class ImportCompilerPassTest extends \PHPUnit_Framework_TestCase
$container
->register('foo')
->addTag('wallabag_import.import', array('alias' => 'pocket'))
->addTag('wallabag_import.import', ['alias' => 'pocket'])
;
$this->process($container);

View file

@ -73,7 +73,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
);
$this->logHandler = new TestHandler();
$logger = new Logger('test', array($this->logHandler));
$logger = new Logger('test', [$this->logHandler]);
$pocket->setLogger($logger);
return $pocket;

View file

@ -30,7 +30,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
$wallabag = new WallabagV1Import($this->em, $this->contentProxy);
$this->logHandler = new TestHandler();
$logger = new Logger('test', array($this->logHandler));
$logger = new Logger('test', [$this->logHandler]);
$wallabag->setLogger($logger);
if (false === $unsetUser) {

View file

@ -30,7 +30,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
$wallabag = new WallabagV2Import($this->em, $this->contentProxy);
$this->logHandler = new TestHandler();
$logger = new Logger('test', array($this->logHandler));
$logger = new Logger('test', [$this->logHandler]);
$wallabag->setLogger($logger);
if (false === $unsetUser) {

View file

@ -88,7 +88,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
{
parent::__construct();
$this->entries = new ArrayCollection();
$this->roles = array('ROLE_USER');
$this->roles = ['ROLE_USER'];
}
/**

View file

@ -27,9 +27,9 @@ class PasswordResettingListener implements EventSubscriberInterface
*/
public static function getSubscribedEvents()
{
return array(
return [
FOSUserEvents::RESETTING_RESET_SUCCESS => 'onPasswordResettingSuccess',
);
];
}
public function onPasswordResettingSuccess(FormEvent $event)

View file

@ -82,7 +82,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface
{
$template = $this->twig->loadTemplate('WallabagUserBundle:TwoFactor:email_auth_code.html.twig');
$subject = $template->renderBlock('subject', array());
$subject = $template->renderBlock('subject', []);
$bodyHtml = $template->renderBlock('body_html', [
'user' => $user->getName(),
'code' => $user->getEmailAuthCode(),

View file

@ -43,7 +43,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
{% block body_text %}text body {{ support_url }}{% endblock %}
TWIG;
$this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate)));
$this->twig = new \Twig_Environment(new \Twig_Loader_Array(['WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate]));
$this->config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config')
->disableOriginalConstructor()
@ -76,7 +76,7 @@ TWIG;
$msg = $this->spool->getMessages()[0];
$this->assertArrayHasKey('test@wallabag.io', $msg->getTo());
$this->assertEquals(array('nobody@test.io' => 'wallabag test'), $msg->getFrom());
$this->assertEquals(['nobody@test.io' => 'wallabag test'], $msg->getFrom());
$this->assertEquals('subject', $msg->getSubject());
$this->assertContains('text body http://0.0.0.0/support', $msg->toString());
$this->assertContains('html body 666666', $msg->toString());