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

php-cs-fixer: native_function_invocation #3716

Merged
merged 1 commit into from Sep 5, 2018
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/Version20170719231144.php
Expand Up @@ -55,7 +55,7 @@ public function up(Schema $schema)
}

// Just in case...
if (count($ids) > 0) {
if (\count($ids) > 0) {
// Merge tags
$this->addSql('
UPDATE ' . $this->getTable('entry_tag') . '
Expand Down
Expand Up @@ -28,7 +28,7 @@ public function getAnnotationsAction(Entry $entry)
->getDoctrine()
->getRepository('WallabagAnnotationBundle:Annotation')
->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId());
$total = count($annotationRows);
$total = \count($annotationRows);
$annotations = ['total' => $total, 'rows' => $annotationRows];

$json = $this->get('jms_serializer')->serialize($annotations, 'json');
Expand Down
8 changes: 4 additions & 4 deletions src/Wallabag/ApiBundle/Controller/EntryRestController.php
Expand Up @@ -102,7 +102,7 @@ public function getEntriesAction(Request $request)
$order = $request->query->get('order', 'desc');
$page = (int) $request->query->get('page', 1);
$perPage = (int) $request->query->get('perPage', 30);
$tags = is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
$tags = \is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', '');
$since = $request->query->get('since', 0);

/** @var \Pagerfanta\Pagerfanta $pager */
Expand Down Expand Up @@ -253,7 +253,7 @@ public function postEntriesListAction(Request $request)

$limit = $this->container->getParameter('wallabag_core.api_limit_mass_actions');

if (count($urls) > $limit) {
if (\count($urls) > $limit) {
throw new HttpException(400, 'API limit reached');
}

Expand Down Expand Up @@ -347,7 +347,7 @@ public function postEntriesAction(Request $request)
'open_graph' => [
'og_image' => !empty($data['picture']) ? $data['picture'] : $entry->getPreviewPicture(),
],
'authors' => is_string($data['authors']) ? explode(',', $data['authors']) : $entry->getPublishedBy(),
'authors' => \is_string($data['authors']) ? explode(',', $data['authors']) : $entry->getPublishedBy(),
]
);
} catch (\Exception $e) {
Expand Down Expand Up @@ -461,7 +461,7 @@ public function patchEntriesAction(Entry $entry, Request $request)
$contentProxy->updateLanguage($entry, $data['language']);
}

if (!empty($data['authors']) && is_string($data['authors'])) {
if (!empty($data['authors']) && \is_string($data['authors'])) {
$entry->setPublishedBy(explode(',', $data['authors']));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Wallabag/ApiBundle/Controller/TagRestController.php
Expand Up @@ -138,14 +138,14 @@ public function deleteTagAction(Tag $tag)
*/
private function cleanOrphanTag($tags)
{
if (!is_array($tags)) {
if (!\is_array($tags)) {
$tags = [$tags];
}

$em = $this->getDoctrine()->getManager();

foreach ($tags as $tag) {
if (0 === count($tag->getEntries())) {
if (0 === \count($tag->getEntries())) {
$em->remove($tag);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
Expand Up @@ -51,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} 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()));
Expand Down Expand Up @@ -79,7 +79,7 @@ private function cleanDuplicates(User $user)
$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']));
Expand All @@ -96,8 +96,8 @@ private function cleanDuplicates(User $user)

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;
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Command/ExportCommand.php
Expand Up @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->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');

Expand Down
8 changes: 4 additions & 4 deletions src/Wallabag/CoreBundle/Command/InstallCommand.php
Expand Up @@ -81,7 +81,7 @@ protected function checkRequirements()
$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.';
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function checkRequirements()
$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';
Expand Down Expand Up @@ -371,7 +371,7 @@ private function isDatabasePresent()
}

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

Expand All @@ -389,6 +389,6 @@ private function isSchemaPresent()
{
$schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();

return count($schemaManager->listTableNames()) > 0 ? true : false;
return \count($schemaManager->listTableNames()) > 0 ? true : false;
}
}
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Command/ListUserCommand.php
Expand Up @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->success(
sprintf(
'%s/%s%s user(s) displayed.',
count($users),
\count($users),
$nbUsers,
null === $input->getArgument('search') ? '' : ' (filtered)'
)
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Command/ReloadEntryCommand.php
Expand Up @@ -43,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$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.');

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 (0 === count($tag->getEntries())) {
if (0 === \count($tag->getEntries())) {
$em->remove($tag);
}
}
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 (0 === count($tag->getEntries())) {
if (0 === \count($tag->getEntries())) {
$em->remove($tag);
$em->flush();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
Expand Up @@ -33,7 +33,7 @@ public function __construct(EntityRepository $entryRepository, TokenStorageInter

$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;
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->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 . '%')));
Expand Down
Expand Up @@ -107,7 +107,7 @@ public function buildForHost($host)
*/
protected function processExtraFields($extraFieldsStrings)
{
if (!is_array($extraFieldsStrings)) {
if (!\is_array($extraFieldsStrings)) {
return [];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Wallabag/CoreBundle/Helper/ContentProxy.php
Expand Up @@ -85,7 +85,7 @@ public function updateLanguage(Entry $entry, $value)
(new LocaleConstraint())
);

if (0 === count($errors)) {
if (0 === \count($errors)) {
$entry->setLanguage($value);

return;
Expand All @@ -107,7 +107,7 @@ public function updatePreviewPicture(Entry $entry, $value)
(new UrlConstraint())
);

if (0 === count($errors)) {
if (0 === \count($errors)) {
$entry->setPreviewPicture($value);

return;
Expand Down Expand Up @@ -212,7 +212,7 @@ private function stockEntry(Entry $entry, array $content)
$entry->setHttpStatus($content['status']);
}

if (!empty($content['authors']) && is_array($content['authors'])) {
if (!empty($content['authors']) && \is_array($content['authors'])) {
$entry->setPublishedBy($content['authors']);
}

Expand All @@ -233,7 +233,7 @@ private function stockEntry(Entry $entry, array $content)
}

// 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']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Helper/CryptoProxy.php
Expand Up @@ -81,6 +81,6 @@ private function loadKey()
*/
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';
}
}
4 changes: 2 additions & 2 deletions src/Wallabag/CoreBundle/Helper/DownloadImages.php
Expand Up @@ -198,7 +198,7 @@ private function getSrcsetUrls(Crawler $imagesCrawler)
// 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);
Expand Down Expand Up @@ -308,7 +308,7 @@ private function getExtensionFromResponse(Response $res, $imagePath)
$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;
Expand Down
4 changes: 2 additions & 2 deletions src/Wallabag/CoreBundle/Helper/EntriesExport.php
Expand Up @@ -45,7 +45,7 @@ public function __construct(TranslatorInterface $translator, $wallabagUrl, $logo
*/
public function setEntries($entries)
{
if (!is_array($entries)) {
if (!\is_array($entries)) {
$this->language = $entries->getLanguage();
$entries = [$entries];
}
Expand Down Expand Up @@ -325,7 +325,7 @@ private function produceCsv()
{
$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);

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
Expand Up @@ -31,7 +31,7 @@ public function prepare(AdapterInterface $adapter, User $user = null)
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
}

if (null === $user || !is_object($user)) {
if (null === $user || !\is_object($user)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Helper/Redirect.php
Expand Up @@ -31,7 +31,7 @@ public function to($url, $fallback = '', $ignoreActionMarkAsRead = false)
{
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;

if (null === $user || !is_object($user)) {
if (null === $user || !\is_object($user)) {
return $url;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Wallabag/CoreBundle/Helper/TagsAssigner.php
Expand Up @@ -32,7 +32,7 @@ public function assignTagsToEntry(Entry $entry, $tags, array $entitiesReady = []
{
$tagsEntities = [];

if (!is_array($tags)) {
if (!\is_array($tags)) {
$tags = explode(',', $tags);
}

Expand All @@ -48,7 +48,7 @@ public function assignTagsToEntry(Entry $entry, $tags, array $entitiesReady = []
$label = trim(mb_convert_case($label, MB_CASE_LOWER));

// avoid empty tag
if (0 === strlen($label)) {
if (0 === \strlen($label)) {
continue;
}

Expand Down
Expand Up @@ -36,7 +36,7 @@ public function supports(ParamConverter $configuration)
{
// 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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Wallabag/CoreBundle/Repository/EntryRepository.php
Expand Up @@ -151,7 +151,7 @@ public function findEntries($userId, $isArchived = null, $isStarred = null, $isP
$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;
Expand Down Expand Up @@ -320,7 +320,7 @@ public function findByUrlAndUserId($url, $userId)
->getQuery()
->getResult();

if (count($res)) {
if (\count($res)) {
return current($res);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Repository/TagRepository.php
Expand Up @@ -30,7 +30,7 @@ public function countAllTags($userId, $cacheLifeTime = null)
$query->setResultCacheLifetime($cacheLifeTime);
}

return count($query->getArrayResult());
return \count($query->getArrayResult());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Wallabag/CoreBundle/Tools/Utils.php
Expand Up @@ -29,6 +29,6 @@ public static function generateToken($length = 15)
*/
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);
}
}