forked from wallabag/wallabag
@ -51,7 +51,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
|
||||
} else {
|
||||
$users = $this->getContainer()->get('wallabag_user.user_repository')->findAll();
|
||||
|
||||
$this->io->text(sprintf('Cleaning through <info>%d</info> user accounts', count($users)));
|
||||
$this->io->text(sprintf('Cleaning through <info>%d</info> user accounts', \count($users)));
|
||||
|
||||
foreach ($users as $user) {
|
||||
$this->io->text(sprintf('Processing user <info>%s</info>', $user->getUsername()));
|
||||
@ -79,7 +79,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
|
||||
$url = $this->similarUrl($entry['url']);
|
||||
|
||||
/* @var $entry Entry */
|
||||
if (in_array($url, $urls, true)) {
|
||||
if (\in_array($url, $urls, true)) {
|
||||
++$duplicatesCount;
|
||||
|
||||
$em->remove($repo->find($entry['id']));
|
||||
@ -96,8 +96,8 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
|
||||
|
||||
private function similarUrl($url)
|
||||
{
|
||||
if (in_array(substr($url, -1), ['/', '#'], true)) { // get rid of "/" and "#" and the end of urls
|
||||
return substr($url, 0, strlen($url));
|
||||
if (\in_array(substr($url, -1), ['/', '#'], true)) { // get rid of "/" and "#" and the end of urls
|
||||
return substr($url, 0, \strlen($url));
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
||||
@ -47,7 +47,7 @@ class ExportCommand extends ContainerAwareCommand
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
$io->text(sprintf('Exporting <info>%d</info> entrie(s) for user <info>%s</info>...', count($entries), $user->getUserName()));
|
||||
$io->text(sprintf('Exporting <info>%d</info> entrie(s) for user <info>%s</info>...', \count($entries), $user->getUserName()));
|
||||
|
||||
$filePath = $input->getArgument('filepath');
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ class InstallCommand extends ContainerAwareCommand
|
||||
$status = '<info>OK!</info>';
|
||||
$help = '';
|
||||
|
||||
if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) {
|
||||
if (!\extension_loaded($this->getContainer()->getParameter('database_driver'))) {
|
||||
$fulfilled = false;
|
||||
$status = '<error>ERROR!</error>';
|
||||
$help = 'Database driver "' . $this->getContainer()->getParameter('database_driver') . '" is not installed.';
|
||||
@ -146,7 +146,7 @@ class InstallCommand extends ContainerAwareCommand
|
||||
$status = '<info>OK!</info>';
|
||||
$help = '';
|
||||
|
||||
if (!function_exists($functionRequired)) {
|
||||
if (!\function_exists($functionRequired)) {
|
||||
$fulfilled = false;
|
||||
$status = '<error>ERROR!</error>';
|
||||
$help = 'You need the ' . $functionRequired . ' function activated';
|
||||
@ -371,7 +371,7 @@ class InstallCommand extends ContainerAwareCommand
|
||||
}
|
||||
|
||||
try {
|
||||
return in_array($databaseName, $schemaManager->listDatabases(), true);
|
||||
return \in_array($databaseName, $schemaManager->listDatabases(), true);
|
||||
} catch (\Doctrine\DBAL\Exception\DriverException $e) {
|
||||
// it means we weren't able to get database list, assume the database doesn't exist
|
||||
|
||||
@ -389,6 +389,6 @@ class InstallCommand extends ContainerAwareCommand
|
||||
{
|
||||
$schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
|
||||
|
||||
return count($schemaManager->listTableNames()) > 0 ? true : false;
|
||||
return \count($schemaManager->listTableNames()) > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class ListUserCommand extends ContainerAwareCommand
|
||||
$io->success(
|
||||
sprintf(
|
||||
'%s/%s%s user(s) displayed.',
|
||||
count($users),
|
||||
\count($users),
|
||||
$nbUsers,
|
||||
null === $input->getArgument('search') ? '' : ' (filtered)'
|
||||
)
|
||||
|
||||
@ -43,7 +43,7 @@ class ReloadEntryCommand extends ContainerAwareCommand
|
||||
$entryRepository = $this->getContainer()->get('wallabag_core.entry_repository');
|
||||
$entryIds = $entryRepository->findAllEntriesIdByUserId($userId);
|
||||
|
||||
$nbEntries = count($entryIds);
|
||||
$nbEntries = \count($entryIds);
|
||||
if (!$nbEntries) {
|
||||
$io->success('No entry to reload.');
|
||||
|
||||
|
||||
@ -348,7 +348,7 @@ class ConfigController extends Controller
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if (0 === count($tag->getEntries())) {
|
||||
if (0 === \count($tag->getEntries())) {
|
||||
$em->remove($tag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class TagController extends Controller
|
||||
$em->flush();
|
||||
|
||||
// remove orphan tag in case no entries are associated to it
|
||||
if (0 === count($tag->getEntries())) {
|
||||
if (0 === \count($tag->getEntries())) {
|
||||
$em->remove($tag);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class EntryFilterType extends AbstractType
|
||||
|
||||
$this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $this->user || !is_object($this->user)) {
|
||||
if (null === $this->user || !\is_object($this->user)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ class EntryFilterType extends AbstractType
|
||||
->add('domainName', TextFilterType::class, [
|
||||
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
|
||||
$value = $values['value'];
|
||||
if (strlen($value) <= 2 || empty($value)) {
|
||||
if (\strlen($value) <= 2 || empty($value)) {
|
||||
return;
|
||||
}
|
||||
$expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%')));
|
||||
|
||||
@ -107,7 +107,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
|
||||
*/
|
||||
protected function processExtraFields($extraFieldsStrings)
|
||||
{
|
||||
if (!is_array($extraFieldsStrings)) {
|
||||
if (!\is_array($extraFieldsStrings)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ class ContentProxy
|
||||
(new LocaleConstraint())
|
||||
);
|
||||
|
||||
if (0 === count($errors)) {
|
||||
if (0 === \count($errors)) {
|
||||
$entry->setLanguage($value);
|
||||
|
||||
return;
|
||||
@ -107,7 +107,7 @@ class ContentProxy
|
||||
(new UrlConstraint())
|
||||
);
|
||||
|
||||
if (0 === count($errors)) {
|
||||
if (0 === \count($errors)) {
|
||||
$entry->setPreviewPicture($value);
|
||||
|
||||
return;
|
||||
@ -212,7 +212,7 @@ class ContentProxy
|
||||
$entry->setHttpStatus($content['status']);
|
||||
}
|
||||
|
||||
if (!empty($content['authors']) && is_array($content['authors'])) {
|
||||
if (!empty($content['authors']) && \is_array($content['authors'])) {
|
||||
$entry->setPublishedBy($content['authors']);
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ class ContentProxy
|
||||
}
|
||||
|
||||
// if content is an image, define it as a preview too
|
||||
if (!empty($content['content_type']) && in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
|
||||
if (!empty($content['content_type']) && \in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
|
||||
$this->updatePreviewPicture($entry, $content['url']);
|
||||
}
|
||||
|
||||
|
||||
@ -81,6 +81,6 @@ class CryptoProxy
|
||||
*/
|
||||
private function mask($value)
|
||||
{
|
||||
return strlen($value) > 0 ? $value[0] . '*****' . $value[strlen($value) - 1] : 'Empty value';
|
||||
return \strlen($value) > 0 ? $value[0] . '*****' . $value[\strlen($value) - 1] : 'Empty value';
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ class DownloadImages
|
||||
// Must be one or more digits followed by w OR x
|
||||
$pattern = "/(?:[^\"'\s]+\s*(?:\d+[wx])+)/";
|
||||
preg_match_all($pattern, $srcsetAttribute, $matches);
|
||||
$srcset = call_user_func_array('array_merge', $matches);
|
||||
$srcset = \call_user_func_array('array_merge', $matches);
|
||||
$srcsetUrls = array_map(function ($src) {
|
||||
return trim(explode(' ', $src, 2)[0]);
|
||||
}, $srcset);
|
||||
@ -308,7 +308,7 @@ class DownloadImages
|
||||
$this->logger->debug('DownloadImages: Checking extension (alternative)', ['ext' => $ext]);
|
||||
}
|
||||
|
||||
if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
|
||||
if (!\in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
|
||||
$this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: ' . $imagePath);
|
||||
|
||||
return false;
|
||||
|
||||
@ -45,7 +45,7 @@ class EntriesExport
|
||||
*/
|
||||
public function setEntries($entries)
|
||||
{
|
||||
if (!is_array($entries)) {
|
||||
if (!\is_array($entries)) {
|
||||
$this->language = $entries->getLanguage();
|
||||
$entries = [$entries];
|
||||
}
|
||||
@ -325,7 +325,7 @@ class EntriesExport
|
||||
{
|
||||
$delimiter = ';';
|
||||
$enclosure = '"';
|
||||
$handle = fopen('php://memory', 'rb+');
|
||||
$handle = fopen('php://memory', 'b+r');
|
||||
|
||||
fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language', 'Creation date'], $delimiter, $enclosure);
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class PreparePagerForEntries
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
}
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
if (null === $user || !\is_object($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class Redirect
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
if (null === $user || !\is_object($user)) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ class TagsAssigner
|
||||
{
|
||||
$tagsEntities = [];
|
||||
|
||||
if (!is_array($tags)) {
|
||||
if (!\is_array($tags)) {
|
||||
$tags = explode(',', $tags);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class TagsAssigner
|
||||
$label = trim(mb_convert_case($label, MB_CASE_LOWER));
|
||||
|
||||
// avoid empty tag
|
||||
if (0 === strlen($label)) {
|
||||
if (0 === \strlen($label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class UsernameRssTokenConverter implements ParamConverterInterface
|
||||
{
|
||||
// If there is no manager, this means that only Doctrine DBAL is configured
|
||||
// In this case we can do nothing and just return
|
||||
if (null === $this->registry || !count($this->registry->getManagers())) {
|
||||
if (null === $this->registry || !\count($this->registry->getManagers())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ class EntryRepository extends EntityRepository
|
||||
$qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
|
||||
}
|
||||
|
||||
if (is_string($tags) && '' !== $tags) {
|
||||
if (\is_string($tags) && '' !== $tags) {
|
||||
foreach (explode(',', $tags) as $i => $tag) {
|
||||
$entryAlias = 'e' . $i;
|
||||
$tagAlias = 't' . $i;
|
||||
@ -320,7 +320,7 @@ class EntryRepository extends EntityRepository
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
if (count($res)) {
|
||||
if (\count($res)) {
|
||||
return current($res);
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ class TagRepository extends EntityRepository
|
||||
$query->setResultCacheLifetime($cacheLifeTime);
|
||||
}
|
||||
|
||||
return count($query->getArrayResult());
|
||||
return \count($query->getArrayResult());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -29,6 +29,6 @@ class Utils
|
||||
*/
|
||||
public static function getReadingTime($text)
|
||||
{
|
||||
return floor(count(preg_split('~[^\p{L}\p{N}\']+~u', strip_tags($text))) / 200);
|
||||
return floor(\count(preg_split('~[^\p{L}\p{N}\']+~u', strip_tags($text))) / 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
if (null === $user || !\is_object($user)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
$query->useResultCache(true);
|
||||
$query->setResultCacheLifetime($this->lifeTime);
|
||||
|
||||
return count($query->getArrayResult());
|
||||
return \count($query->getArrayResult());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
if (null === $user || !\is_object($user)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
if (null === $user || !\is_object($user)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
$query->useResultCache(true);
|
||||
$query->setResultCacheLifetime($this->lifeTime);
|
||||
|
||||
$nbArchives = count($query->getArrayResult());
|
||||
$nbArchives = \count($query->getArrayResult());
|
||||
|
||||
$interval = $user->getCreatedAt()->diff(new \DateTime('now'));
|
||||
$nbDays = (int) $interval->format('%a') ?: 1;
|
||||
|
||||
Reference in New Issue
Block a user