Add a real configuration for CS-Fixer

This commit is contained in:
Jeremy Benoist
2017-07-01 09:52:38 +02:00
parent 822c877949
commit f808b01692
170 changed files with 3147 additions and 3120 deletions

View File

@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Helper;
use Graby\Graby;
use Psr\Log\LoggerInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Tools\Utils;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Tools\Utils;
/**
* This kind of proxy class take care of getting the content from an url
@ -100,7 +100,7 @@ class ContentProxy
// is it a timestamp?
if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
$date = '@'.$content['date'];
$date = '@' . $content['date'];
}
try {
@ -189,7 +189,7 @@ class ContentProxy
return;
}
$this->logger->warning('Language validation failed. '.(string) $errors);
$this->logger->warning('Language validation failed. ' . (string) $errors);
}
/**
@ -211,6 +211,6 @@ class ContentProxy
return;
}
$this->logger->warning('PreviewPicture validation failed. '.(string) $errors);
$this->logger->warning('PreviewPicture validation failed. ' . (string) $errors);
}
}

View File

@ -2,10 +2,10 @@
namespace Wallabag\CoreBundle\Helper;
use Psr\Log\LoggerInterface;
use Defuse\Crypto\Key;
use Defuse\Crypto\Crypto;
use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException;
use Defuse\Crypto\Key;
use Psr\Log\LoggerInterface;
/**
* This is a proxy to crypt and decrypt password used by SiteCredential entity.
@ -39,7 +39,7 @@ class CryptoProxy
*/
public function crypt($secretValue)
{
$this->logger->debug('Crypto: crypting value: '.$this->mask($secretValue));
$this->logger->debug('Crypto: crypting value: ' . $this->mask($secretValue));
return Crypto::encrypt($secretValue, $this->loadKey());
}
@ -53,12 +53,12 @@ class CryptoProxy
*/
public function decrypt($cryptedValue)
{
$this->logger->debug('Crypto: decrypting value: '.$this->mask($cryptedValue));
$this->logger->debug('Crypto: decrypting value: ' . $this->mask($cryptedValue));
try {
return Crypto::decrypt($cryptedValue, $this->loadKey());
} catch (WrongKeyOrModifiedCiphertextException $e) {
throw new \RuntimeException('Decrypt fail: '.$e->getMessage());
throw new \RuntimeException('Decrypt fail: ' . $e->getMessage());
}
}
@ -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';
}
}

View File

@ -44,7 +44,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
{
$token = $this->tokenStorage->getToken();
if (is_null($token)) {
if (null === $token) {
return $this->defaultTheme;
}

View File

@ -2,12 +2,12 @@
namespace Wallabag\CoreBundle\Helper;
use Psr\Log\LoggerInterface;
use Symfony\Component\DomCrawler\Crawler;
use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
use Psr\Log\LoggerInterface;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
class DownloadImages
{
@ -30,17 +30,6 @@ class DownloadImages
$this->setFolder();
}
/**
* Setup base folder where all images are going to be saved.
*/
private function setFolder()
{
// if folder doesn't exist, attempt to create one and store the folder name in property $folder
if (!file_exists($this->baseFolder)) {
mkdir($this->baseFolder, 0755, true);
}
}
/**
* Process the html and extract image from it, save them to local and return the updated html.
*
@ -97,9 +86,9 @@ class DownloadImages
$relativePath = $this->getRelativePath($entryId);
}
$this->logger->debug('DownloadImages: working on image: '.$imagePath);
$this->logger->debug('DownloadImages: working on image: ' . $imagePath);
$folderPath = $this->baseFolder.'/'.$relativePath;
$folderPath = $this->baseFolder . '/' . $relativePath;
// build image path
$absolutePath = $this->getAbsoluteLink($url, $imagePath);
@ -123,7 +112,7 @@ class DownloadImages
}
$hashImage = hash('crc32', $absolutePath);
$localPath = $folderPath.'/'.$hashImage.'.'.$ext;
$localPath = $folderPath . '/' . $hashImage . '.' . $ext;
try {
$im = imagecreatefromstring($res->getBody());
@ -156,7 +145,7 @@ class DownloadImages
imagedestroy($im);
return $this->wallabagUrl.'/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext;
return $this->wallabagUrl . '/assets/images/' . $relativePath . '/' . $hashImage . '.' . $ext;
}
/**
@ -167,7 +156,7 @@ class DownloadImages
public function removeImages($entryId)
{
$relativePath = $this->getRelativePath($entryId);
$folderPath = $this->baseFolder.'/'.$relativePath;
$folderPath = $this->baseFolder . '/' . $relativePath;
$finder = new Finder();
$finder
@ -182,6 +171,17 @@ class DownloadImages
@rmdir($folderPath);
}
/**
* Setup base folder where all images are going to be saved.
*/
private function setFolder()
{
// if folder doesn't exist, attempt to create one and store the folder name in property $folder
if (!file_exists($this->baseFolder)) {
mkdir($this->baseFolder, 0755, true);
}
}
/**
* Generate the folder where we are going to save images based on the entry url.
*
@ -192,8 +192,8 @@ class DownloadImages
private function getRelativePath($entryId)
{
$hashId = hash('crc32', $entryId);
$relativePath = $hashId[0].'/'.$hashId[1].'/'.$hashId;
$folderPath = $this->baseFolder.'/'.$relativePath;
$relativePath = $hashId[0] . '/' . $hashId[1] . '/' . $hashId;
$folderPath = $this->baseFolder . '/' . $relativePath;
if (!file_exists($folderPath)) {
mkdir($folderPath, 0777, true);
@ -270,7 +270,7 @@ class DownloadImages
}
if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
$this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: '.$imagePath);
$this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: ' . $imagePath);
return false;
}

View File

@ -63,7 +63,7 @@ class EntriesExport
*/
public function updateTitle($method)
{
$this->title = $method.' articles';
$this->title = $method . ' articles';
if ('entry' === $method) {
$this->title = $this->entries[0]->getTitle();
@ -81,7 +81,7 @@ class EntriesExport
*/
public function exportAs($format)
{
$functionName = 'produce'.ucfirst($format);
$functionName = 'produce' . ucfirst($format);
if (method_exists($this, $functionName)) {
return $this->$functionName();
}
@ -106,12 +106,12 @@ class EntriesExport
*/
$content_start =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
."<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
.'<head>'
."<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
."<title>wallabag articles book</title>\n"
."</head>\n"
."<body>\n";
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
. '<head>'
. "<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
. "<title>wallabag articles book</title>\n"
. "</head>\n"
. "<body>\n";
$bookEnd = "</body>\n</html>\n";
@ -164,11 +164,11 @@ class EntriesExport
// in filenames, we limit to A-z/0-9
$filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle());
$chapter = $content_start.$entry->getContent().$bookEnd;
$book->addChapter($entry->getTitle(), htmlspecialchars($filename).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
$chapter = $content_start . $entry->getContent() . $bookEnd;
$book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
}
$book->addChapter('Notices', 'Cover2.html', $content_start.$this->getExportInformation('PHPePub').$bookEnd);
$book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd);
return Response::create(
$book->getBook(),
@ -176,7 +176,7 @@ class EntriesExport
[
'Content-Description' => 'File Transfer',
'Content-type' => 'application/epub+zip',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.epub"',
'Content-Transfer-Encoding' => 'binary',
]
);
@ -228,7 +228,7 @@ class EntriesExport
'Accept-Ranges' => 'bytes',
'Content-Description' => 'File Transfer',
'Content-type' => 'application/x-mobipocket-ebook',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.mobi"',
'Content-Transfer-Encoding' => 'binary',
]
);
@ -256,7 +256,7 @@ class EntriesExport
* Front page
*/
$pdf->AddPage();
$intro = '<h1>'.$this->title.'</h1>'.$this->getExportInformation('tcpdf');
$intro = '<h1>' . $this->title . '</h1>' . $this->getExportInformation('tcpdf');
$pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true);
@ -269,7 +269,7 @@ class EntriesExport
}
$pdf->AddPage();
$html = '<h1>'.$entry->getTitle().'</h1>';
$html = '<h1>' . $entry->getTitle() . '</h1>';
$html .= $entry->getContent();
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
@ -284,7 +284,7 @@ class EntriesExport
[
'Content-Description' => 'File Transfer',
'Content-type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"',
'Content-Transfer-Encoding' => 'binary',
]
);
@ -330,7 +330,7 @@ class EntriesExport
200,
[
'Content-type' => 'application/csv',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
@ -348,7 +348,7 @@ class EntriesExport
200,
[
'Content-type' => 'application/json',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.json"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
@ -366,7 +366,7 @@ class EntriesExport
200,
[
'Content-type' => 'application/xml',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.xml"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
@ -382,8 +382,8 @@ class EntriesExport
$content = '';
$bar = str_repeat('=', 100);
foreach ($this->entries as $entry) {
$content .= "\n\n".$bar."\n\n".$entry->getTitle()."\n\n".$bar."\n\n";
$content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent())))."\n\n";
$content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n";
$content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n";
}
return Response::create(
@ -391,7 +391,7 @@ class EntriesExport
200,
[
'Content-type' => 'text/plain',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
'Content-Disposition' => 'attachment; filename="' . $this->title . '.txt"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
@ -427,7 +427,7 @@ class EntriesExport
$info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate);
if ('tcpdf' === $type) {
return str_replace('%IMAGE%', '<img src="'.$this->logoPath.'" />', $info);
return str_replace('%IMAGE%', '<img src="' . $this->logoPath . '" />', $info);
}
return str_replace('%IMAGE%', '', $info);

View File

@ -41,7 +41,7 @@ class HttpClientFactory
*/
public function buildHttpClient()
{
$this->logger->log('debug', 'Restricted access config enabled?', array('enabled' => (int) $this->restrictedAccess));
$this->logger->log('debug', 'Restricted access config enabled?', ['enabled' => (int) $this->restrictedAccess]);
if (0 === (int) $this->restrictedAccess) {
return;

View File

@ -4,9 +4,9 @@ namespace Wallabag\CoreBundle\Helper;
use Pagerfanta\Adapter\AdapterInterface;
use Pagerfanta\Pagerfanta;
use Wallabag\UserBundle\Entity\User;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Wallabag\UserBundle\Entity\User;
class PreparePagerForEntries
{

View File

@ -2,13 +2,13 @@
namespace Wallabag\CoreBundle\Helper;
use Psr\Log\LoggerInterface;
use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\UserBundle\Entity\User;
use Psr\Log\LoggerInterface;
class RuleBasedTagger
{