This commit is contained in:
Jeremy Benoist 2017-10-09 16:47:15 +02:00
parent f40c88eb1f
commit 3ef055ced3
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
27 changed files with 37 additions and 37 deletions

View file

@ -28,7 +28,7 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
*/
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()) {

View file

@ -27,7 +27,7 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
*/
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;');
@ -58,7 +58,7 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
*/
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;');

View file

@ -55,7 +55,7 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
$clientsTable->dropColumn('user_id', 'integer');
if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) {
$clientsTable->removeForeignKey($this->constraintName);
}
}

View file

@ -34,7 +34,7 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
*/
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;');
@ -46,7 +46,7 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
*/
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;');

View file

@ -27,7 +27,7 @@ class Version20170719231144 extends AbstractMigration implements ContainerAwareI
*/
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('

View file

@ -145,7 +145,7 @@ class TagRestController extends WallabagRestController
$em = $this->getDoctrine()->getManager();
foreach ($tags as $tag) {
if (count($tag->getEntries()) === 0) {
if (0 === count($tag->getEntries())) {
$em->remove($tag);
}
}

View file

@ -52,7 +52,7 @@ class ListUserCommand extends ContainerAwareCommand
'%s/%s%s user(s) displayed.',
count($users),
$nbUsers,
$input->getArgument('search') === null ? '' : ' (filtered)'
null === $input->getArgument('search') ? '' : ' (filtered)'
)
);

View file

@ -56,7 +56,7 @@ class ShowUserCommand extends ContainerAwareCommand
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'),
]);
}

View file

@ -348,7 +348,7 @@ class ConfigController extends Controller
$em = $this->getDoctrine()->getManager();
foreach ($tags as $tag) {
if (count($tag->getEntries()) === 0) {
if (0 === count($tag->getEntries())) {
$em->remove($tag);
}
}

View file

@ -195,7 +195,7 @@ class EntryController extends Controller
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'));
}

View file

@ -59,7 +59,7 @@ class ExportController extends Controller
$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(

View file

@ -65,7 +65,7 @@ class TagController extends Controller
$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();
}

View file

@ -42,7 +42,7 @@ class TablePrefixSubscriber implements EventSubscriber
$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;
}

View file

@ -48,7 +48,7 @@ class StringToListTransformer implements DataTransformerInterface
*/
public function reverseTransform($string)
{
if ($string === null) {
if (null === $string) {
return;
}

View file

@ -58,7 +58,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
{
// required by credentials below
$host = strtolower($host);
if (substr($host, 0, 4) === 'www.') {
if ('www.' === substr($host, 0, 4)) {
$host = substr($host, 4);
}
@ -113,7 +113,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
$extraFields = [];
foreach ($extraFieldsStrings as $extraField) {
if (strpos($extraField, '=') === false) {
if (false === strpos($extraField, '=')) {
continue;
}

View file

@ -125,7 +125,7 @@ class ContentProxy
$date = $value;
// is it a timestamp?
if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
if (false !== filter_var($date, FILTER_VALIDATE_INT)) {
$date = '@' . $date;
}

View file

@ -16,7 +16,7 @@ class Matches
{
public function __invoke($subject, $pattern)
{
if ($pattern[0] === "'") {
if ("'" === $pattern[0]) {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}

View file

@ -16,7 +16,7 @@ class NotMatches
{
public function __invoke($subject, $pattern)
{
if ($pattern[0] === "'") {
if ("'" === $pattern[0]) {
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
}

View file

@ -16,6 +16,6 @@ class Matches
{
public function __invoke($subject, $pattern)
{
return stripos($subject, $pattern) !== false;
return false !== stripos($subject, $pattern);
}
}

View file

@ -16,6 +16,6 @@ class NotMatches
{
public function __invoke($subject, $pattern)
{
return stripos($subject, $pattern) === false;
return false === stripos($subject, $pattern);
}
}

View file

@ -165,7 +165,7 @@ abstract class AbstractImport implements ImportInterface
$entryToBeFlushed[] = $entry;
// flush every 20 entries
if (($i % 20) === 0) {
if (0 === ($i % 20)) {
$this->em->flush();
foreach ($entryToBeFlushed as $entry) {

View file

@ -171,7 +171,7 @@ abstract class BrowserImport extends AbstractImport
$entryToBeFlushed[] = $entry;
// flush every 20 entries
if (($i % 20) === 0) {
if (0 === ($i % 20)) {
$this->em->flush();
foreach ($entryToBeFlushed as $entry) {

View file

@ -45,7 +45,7 @@ class ChromeImport extends BrowserImport
'created_at' => substr($entry['date_added'], 0, 10),
];
if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags'];
}

View file

@ -45,7 +45,7 @@ class FirefoxImport extends BrowserImport
'created_at' => substr($entry['dateAdded'], 0, 10),
];
if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags'];
}

View file

@ -63,7 +63,7 @@ class InstapaperImport extends AbstractImport
$entries = [];
$handle = fopen($this->filepath, 'r');
while (($data = fgetcsv($handle, 10240)) !== false) {
while (false !== ($data = fgetcsv($handle, 10240))) {
if ('URL' === $data[0]) {
continue;
}
@ -80,8 +80,8 @@ class InstapaperImport extends AbstractImport
'url' => $data[0],
'title' => $data[1],
'status' => $data[3],
'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred',
'is_starred' => $data[3] === 'Starred',
'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3],
'is_starred' => 'Starred' === $data[3],
'html' => false,
'tags' => $tags,
];

View file

@ -149,7 +149,7 @@ class PocketImport extends AbstractImport
// - first call get 5k offset 0
// - second call get 5k offset 5k
// - and so on
if (count($entries['list']) === self::NB_ELEMENTS) {
if (self::NB_ELEMENTS === count($entries['list'])) {
++$run;
return $this->import(self::NB_ELEMENTS * $run);
@ -175,7 +175,7 @@ class PocketImport extends AbstractImport
*/
public function parseEntry(array $importedEntry)
{
$url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] !== '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
$url = isset($importedEntry['resolved_url']) && '' !== $importedEntry['resolved_url'] ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
$existingEntry = $this->em
->getRepository('WallabagCoreBundle:Entry')
@ -194,15 +194,15 @@ class PocketImport extends AbstractImport
$this->fetchContent($entry, $url);
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
$entry->setArchived($importedEntry['status'] === 1 || $this->markAsRead);
$entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead);
// 0 or 1 - 1 If the item is starred
$entry->setStarred($importedEntry['favorite'] === 1);
$entry->setStarred(1 === $importedEntry['favorite']);
$title = 'Untitled';
if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] !== '') {
if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) {
$title = $importedEntry['resolved_title'];
} elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] !== '') {
} elseif (isset($importedEntry['given_title']) && '' !== $importedEntry['given_title']) {
$title = $importedEntry['given_title'];
}

View file

@ -61,7 +61,7 @@ class WallabagV1Import extends WallabagImport
$data['html'] = $this->fetchingErrorMessage;
}
if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags'];
}