Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 3.3 #3376

Merged
merged 3 commits into from Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/DoctrineMigrations/Version20161001072726.php
Expand Up @@ -28,7 +28,7 @@ public function setContainer(ContainerInterface $container = null)
*/
public function up(Schema $schema)
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
$this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');

// remove all FK from entry_tag
switch ($this->connection->getDatabasePlatform()->getName()) {
Expand Down
4 changes: 2 additions & 2 deletions app/DoctrineMigrations/Version20161022134138.php
Expand Up @@ -27,7 +27,7 @@ public function setContainer(ContainerInterface $container = null)
*/
public function up(Schema $schema)
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');

$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');

Expand Down Expand Up @@ -58,7 +58,7 @@ public function up(Schema $schema)
*/
public function down(Schema $schema)
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');

$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');

Expand Down
2 changes: 1 addition & 1 deletion app/DoctrineMigrations/Version20161024212538.php
Expand Up @@ -55,7 +55,7 @@ public function down(Schema $schema)

$clientsTable->dropColumn('user_id', 'integer');

if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) {
$clientsTable->removeForeignKey($this->constraintName);
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/DoctrineMigrations/Version20170510082609.php
Expand Up @@ -34,7 +34,7 @@ public function setContainer(ContainerInterface $container = null)
*/
public function up(Schema $schema)
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');

foreach ($this->fields as $field) {
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
Expand All @@ -46,7 +46,7 @@ public function up(Schema $schema)
*/
public function down(Schema $schema)
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');

foreach ($this->fields as $field) {
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
Expand Down
2 changes: 1 addition & 1 deletion app/DoctrineMigrations/Version20170719231144.php
Expand Up @@ -27,7 +27,7 @@ public function setContainer(ContainerInterface $container = null)
*/
public function up(Schema $schema)
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
$this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');

// Find tags which need to be merged
$dupTags = $this->connection->query('
Expand Down
7 changes: 7 additions & 0 deletions app/config/config.yml
Expand Up @@ -350,3 +350,10 @@ fos_js_routing:
- howto
- fos_user_security_logout
- new

jms_serializer:
handlers:
# to be removed if we switch to (default) ISO8601 datetime instead of ATOM
# see: https://github.com/schmittjoh/JMSSerializerBundle/pull/494
datetime:
default_format: "Y-m-d\\TH:i:sO" # ATOM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be used only for the RSS/Atom feed, not the XML exports or other things.

Copy link
Member Author

@j0k3r j0k3r Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep but should we use the default one or keep the old one?

14 changes: 7 additions & 7 deletions composer.json
Expand Up @@ -43,23 +43,23 @@
"ext-iconv": "*",
"ext-tokenizer": "*",
"ext-pdo": "*",
"symfony/symfony": "3.2.*",
"symfony/symfony": "3.3.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"twig/extensions": "~1.0",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^3.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"sensio/framework-extra-bundle": "^3.0",
"incenteev/composer-parameter-handler": "^2.0",
"nelmio/cors-bundle": "~1.4.0",
"nelmio/cors-bundle": "~1.4",
"friendsofsymfony/rest-bundle": "~2.1",
"jms/serializer-bundle": "~1.1",
"jms/serializer-bundle": "~2.2",
"nelmio/api-doc-bundle": "~2.7",
"mgargano/simplehtmldom": "~1.5",
"wallabag/tcpdf": "^6.2",
"simplepie/simplepie": "~1.3.1",
"simplepie/simplepie": "~1.5",
"willdurand/hateoas-bundle": "~1.0",
"liip/theme-bundle": "~1.1",
"lexik/form-filter-bundle": "~5.0",
Expand Down Expand Up @@ -89,12 +89,12 @@
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "~2.2",
"doctrine/data-fixtures": "~1.1.1",
"doctrine/data-fixtures": "~1.1",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.3",
"friendsofphp/php-cs-fixer": "~2.0",
"m6web/redis-mock": "^2.0",
"dama/doctrine-test-bundle": "^1.0"
"dama/doctrine-test-bundle": "^3.0"
},
"scripts": {
"post-cmd": [
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -32,6 +32,6 @@
</filter>

<listeners>
<listener class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitStaticDbConnectionListener" />
<listener class="\DAMA\DoctrineTestBundle\PHPUnit\LegacyPHPUnitListener" />
</listeners>
</phpunit>
Expand Up @@ -31,7 +31,7 @@ public function getAnnotationsAction(Entry $entry)
$total = count($annotationRows);
$annotations = ['total' => $total, 'rows' => $annotationRows];

$json = $this->get('serializer')->serialize($annotations, 'json');
$json = $this->get('jms_serializer')->serialize($annotations, 'json');

return (new JsonResponse())->setJson($json);
}
Expand Down Expand Up @@ -64,7 +64,7 @@ public function postAnnotationAction(Request $request, Entry $entry)
$em->persist($annotation);
$em->flush();

$json = $this->get('serializer')->serialize($annotation, 'json');
$json = $this->get('jms_serializer')->serialize($annotation, 'json');

return JsonResponse::fromJsonString($json);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public function putAnnotationAction(Annotation $annotation, Request $request)
$em->persist($annotation);
$em->flush();

$json = $this->get('serializer')->serialize($annotation, 'json');
$json = $this->get('jms_serializer')->serialize($annotation, 'json');

return JsonResponse::fromJsonString($json);
}
Expand All @@ -124,7 +124,7 @@ public function deleteAnnotationAction(Annotation $annotation)
$em->remove($annotation);
$em->flush();

$json = $this->get('serializer')->serialize($annotation, 'json');
$json = $this->get('jms_serializer')->serialize($annotation, 'json');

return (new JsonResponse())->setJson($json);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/ApiBundle/Controller/EntryRestController.php
Expand Up @@ -752,7 +752,7 @@ private function sendResponse($data)
$context = new SerializationContext();
$context->setSerializeNull(true);

$json = $this->get('serializer')->serialize($data, 'json', $context);
$json = $this->get('jms_serializer')->serialize($data, 'json', $context);

return (new JsonResponse())->setJson($json);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Wallabag/ApiBundle/Controller/TagRestController.php
Expand Up @@ -25,7 +25,7 @@ public function getTagsAction()
->getRepository('WallabagCoreBundle:Tag')
->findAllTags($this->getUser()->getId());

$json = $this->get('serializer')->serialize($tags, 'json');
$json = $this->get('jms_serializer')->serialize($tags, 'json');

return (new JsonResponse())->setJson($json);
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public function deleteTagLabelAction(Request $request)

$this->cleanOrphanTag($tag);

$json = $this->get('serializer')->serialize($tag, 'json');
$json = $this->get('jms_serializer')->serialize($tag, 'json');

return (new JsonResponse())->setJson($json);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public function deleteTagsLabelAction(Request $request)

$this->cleanOrphanTag($tags);

$json = $this->get('serializer')->serialize($tags, 'json');
$json = $this->get('jms_serializer')->serialize($tags, 'json');

return (new JsonResponse())->setJson($json);
}
Expand All @@ -126,7 +126,7 @@ public function deleteTagAction(Tag $tag)

$this->cleanOrphanTag($tag);

$json = $this->get('serializer')->serialize($tag, 'json');
$json = $this->get('jms_serializer')->serialize($tag, 'json');

return (new JsonResponse())->setJson($json);
}
Expand All @@ -145,7 +145,7 @@ private function cleanOrphanTag($tags)
$em = $this->getDoctrine()->getManager();

foreach ($tags as $tag) {
if (count($tag->getEntries()) === 0) {
if (0 === count($tag->getEntries())) {
$em->remove($tag);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Wallabag/ApiBundle/Controller/UserRestController.php
Expand Up @@ -46,7 +46,7 @@ public function getUserAction()
public function putUserAction(Request $request)
{
if (!$this->getParameter('fosuser_registration') || !$this->get('craue_config')->get('api_user_registration')) {
$json = $this->get('serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json');
$json = $this->get('jms_serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json');

return (new JsonResponse())
->setJson($json)
Expand Down Expand Up @@ -92,7 +92,7 @@ public function putUserAction(Request $request)
$errors['password'] = $this->translateErrors($data['plainPassword']['children']['first']['errors']);
}

$json = $this->get('serializer')->serialize(['error' => $errors], 'json');
$json = $this->get('jms_serializer')->serialize(['error' => $errors], 'json');

return (new JsonResponse())
->setJson($json)
Expand Down Expand Up @@ -127,7 +127,7 @@ public function putUserAction(Request $request)
*/
private function sendUser(User $user, $group = 'user_api', $status = JsonResponse::HTTP_OK)
{
$json = $this->get('serializer')->serialize(
$json = $this->get('jms_serializer')->serialize(
$user,
'json',
SerializationContext::create()->setGroups([$group])
Expand Down
Expand Up @@ -19,7 +19,7 @@ class WallabagRestController extends FOSRestController
public function getVersionAction()
{
$version = $this->container->getParameter('wallabag_core.version');
$json = $this->get('serializer')->serialize($version, 'json');
$json = $this->get('jms_serializer')->serialize($version, 'json');

return (new JsonResponse())->setJson($json);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Command/ListUserCommand.php
Expand Up @@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'%s/%s%s user(s) displayed.',
count($users),
$nbUsers,
$input->getArgument('search') === null ? '' : ' (filtered)'
null === $input->getArgument('search') ? '' : ' (filtered)'
)
);

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Command/ShowUserCommand.php
Expand Up @@ -56,7 +56,7 @@ private function showUser(User $user)
sprintf('Email: %s', $user->getEmail()),
sprintf('Display name: %s', $user->getName()),
sprintf('Creation date: %s', $user->getCreatedAt()->format('Y-m-d H:i:s')),
sprintf('Last login: %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
sprintf('Last login: %s', null !== $user->getLastLogin() ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Controller/ConfigController.php
Expand Up @@ -348,7 +348,7 @@ private function removeAllTagsByStatusAndUserId($tags, $userId)
$em = $this->getDoctrine()->getManager();

foreach ($tags as $tag) {
if (count($tag->getEntries()) === 0) {
if (0 === count($tag->getEntries())) {
$em->remove($tag);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Controller/EntryController.php
Expand Up @@ -195,7 +195,7 @@ public function showAllAction(Request $request, $page)
public function showUnreadAction(Request $request, $page)
{
// load the quickstart if no entry in database
if ((int) $page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
if (1 === (int) $page && 0 === $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId())) {
return $this->redirect($this->generateUrl('quickstart'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Controller/ExportController.php
Expand Up @@ -59,7 +59,7 @@ public function downloadEntriesAction(Request $request, $format, $category)
$methodBuilder = 'getBuilderFor' . $method . 'ByUser';
$repository = $this->get('wallabag_core.entry_repository');

if ($category === 'tag_entries') {
if ('tag_entries' === $category) {
$tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));

$entries = $repository->findAllByTagId(
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Controller/TagController.php
Expand Up @@ -65,7 +65,7 @@ public function removeTagFromEntry(Request $request, Entry $entry, Tag $tag)
$em->flush();

// remove orphan tag in case no entries are associated to it
if (count($tag->getEntries()) === 0) {
if (0 === count($tag->getEntries())) {
$em->remove($tag);
$em->flush();
}
Expand Down
Expand Up @@ -42,7 +42,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args)
$classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);

foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
if (ClassMetadataInfo::MANY_TO_MANY === $mapping['type'] && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
}
Expand Down
Expand Up @@ -48,7 +48,7 @@ public function transform($list)
*/
public function reverseTransform($string)
{
if ($string === null) {
if (null === $string) {
return;
}

Expand Down
Expand Up @@ -58,7 +58,7 @@ public function buildForHost($host)
{
// required by credentials below
$host = strtolower($host);
if (substr($host, 0, 4) === 'www.') {
if ('www.' === substr($host, 0, 4)) {
$host = substr($host, 4);
}

Expand Down Expand Up @@ -113,7 +113,7 @@ protected function processExtraFields($extraFieldsStrings)

$extraFields = [];
foreach ($extraFieldsStrings as $extraField) {
if (strpos($extraField, '=') === false) {
if (false === strpos($extraField, '=')) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Helper/ContentProxy.php
Expand Up @@ -125,7 +125,7 @@ public function updatePublishedAt(Entry $entry, $value)
$date = $value;

// is it a timestamp?
if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
if (false !== filter_var($date, FILTER_VALIDATE_INT)) {
$date = '@' . $date;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
Expand Up @@ -16,7 +16,7 @@ class Matches
{
public function __invoke($subject, $pattern)
{
if ($pattern[0] === "'") {
if ("'" === $pattern[0]) {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Operator/Doctrine/NotMatches.php
Expand Up @@ -16,7 +16,7 @@ class NotMatches
{
public function __invoke($subject, $pattern)
{
if ($pattern[0] === "'") {
if ("'" === $pattern[0]) {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Operator/PHP/Matches.php
Expand Up @@ -16,6 +16,6 @@ class Matches
{
public function __invoke($subject, $pattern)
{
return stripos($subject, $pattern) !== false;
return false !== stripos($subject, $pattern);
}
}
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Operator/PHP/NotMatches.php
Expand Up @@ -16,6 +16,6 @@ class NotMatches
{
public function __invoke($subject, $pattern)
{
return stripos($subject, $pattern) === false;
return false === stripos($subject, $pattern);
}
}
2 changes: 1 addition & 1 deletion src/Wallabag/ImportBundle/Import/AbstractImport.php
Expand Up @@ -165,7 +165,7 @@ protected function parseEntries($entries)
$entryToBeFlushed[] = $entry;

// flush every 20 entries
if (($i % 20) === 0) {
if (0 === ($i % 20)) {
$this->em->flush();

foreach ($entryToBeFlushed as $entry) {
Expand Down