Skip to content

Commit

Permalink
Task #468: activate phpcs and php sniff
Browse files Browse the repository at this point in the history
php-cs and php-sniff are activated and codes are fixed accordingly
  • Loading branch information
kartolo committed Dec 24, 2023
1 parent 151c2a7 commit 98396b6
Show file tree
Hide file tree
Showing 35 changed files with 322 additions and 328 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ jobs:
- "composer:normalize"
- "composer:psr-verify"
- "json:lint"
# - "php:sniff"
- "php:sniff"
- "php:cs-fixer"
# - "php:stan"
- "xliff:lint"
php-version:
Expand Down
4 changes: 2 additions & 2 deletions Classes/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
/**
* Container class for auxilliary functions of tx_directmail
*
* @author Kasper Skårhøj <kasperYYYY>@typo3.com>
* @author Thorsten Kahler <[email protected]>
* @author Kasper Skårhøj <kasperYYYY>@typo3.com>
* @author Thorsten Kahler <[email protected]>
*/
class Container
{
Expand Down
9 changes: 4 additions & 5 deletions Classes/DirectMailUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
* Static class.
* Functions in this class are used by more than one modules.
*
* @author Kasper Skaarhoj <[email protected]>
* @author Jan-Erik Revsbech <[email protected]>
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
* @author Ivan-Dharma Kartolo <[email protected]>
* @author Kasper Skaarhoj <[email protected]>
* @author Jan-Erik Revsbech <[email protected]>
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
* @author Ivan-Dharma Kartolo <[email protected]>
*/
class DirectMailUtility
{
Expand Down Expand Up @@ -362,7 +362,6 @@ public static function substUrlsInPlainText(string $message, string $urlmode = '
$lengthLimit = 0;
break;
case '76':

default:
$lengthLimit = (int)$urlmode;
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/DmQueryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
/**
* Used to generate queries for selecting users in the database
*
* @author Kasper Skårhøj <[email protected]>
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
* @author Kasper Skårhøj <[email protected]>
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
*/
class DmQueryGenerator extends QueryGenerator
{
Expand Down Expand Up @@ -129,7 +129,7 @@ public function getQueryDM(bool $queryLimitDisabled): string
// Show query
$this->enablePrefix = true;
$queryString = $this->getQuery($this->queryConfig);
if($queryLimitDisabled) {
if ($queryLimitDisabled) {
$this->extFieldLists['queryLimit'] = '';
}
$selectQueryString = $this->getSelectQuery($queryString);
Expand Down
27 changes: 13 additions & 14 deletions Classes/Dmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class, doing the sending of Direct-mails, eg. through a cron-job
*
* @author Kasper Skårhøj <[email protected]>
* @author Kasper Skårhøj <[email protected]>
* @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
*/
class Dmailer implements LoggerAwareInterface
Expand Down Expand Up @@ -461,7 +460,7 @@ public function sendSimple(array $recipients): bool
* @param array $cArray Array of content split by dmail boundary
* @param string $userCategories The list of categories the user is subscribing to.
*
* @return string Content of the email, which the recipient subscribed
* @return string Content of the email, which the recipient subscribed
*/
protected function getBoundaryParts($cArray, $userCategories): string
{
Expand Down Expand Up @@ -508,7 +507,7 @@ protected function getBoundaryParts($cArray, $userCategories): string
* @param string $table Tablename of the recipient
* @param int $uid Uid of the recipient
*
* @return string list of categories
* @return string list of categories
*/
public function getListOfRecipentCategories(string $table, int $uid): string
{
Expand All @@ -533,9 +532,9 @@ public function getListOfRecipentCategories(string $table, int $uid): string
/**
* Mass send to recipient in the list
*
* @param array $query_info List of recipients' ID in the sys_dmail table
* @param int $mid Directmail ID. UID of the sys_dmail table
* @return bool
* @param array $query_info List of recipients' ID in the sys_dmail table
* @param int $mid Directmail ID. UID of the sys_dmail table
* @return bool
*/
protected function masssendList(array $query_info, int $mid): bool
{
Expand Down Expand Up @@ -643,7 +642,7 @@ protected function shipOfMail(int $mid, array $recipRow, string $tableKey): void
'logUid' => $logUid,
'html_sent' => (int)$this->sendAdvanced($recipRow, $tableKey),
'parsetime' => $this->getMilliseconds() - $parseTimeStart,
'size' => strlen($this->message)
'size' => strlen($this->message),
];
$ok = $sysDmailMaillogRepository->updateSysDmailMaillogForShipOfMail($values);

Expand All @@ -665,7 +664,7 @@ protected function shipOfMail(int $mid, array $recipRow, string $tableKey): void
* Converting array key.
* fe_user and tt_address are using different fieldname for the same information
*
* @param array $recipRow Recipient's data array
* @param array $recipRow Recipient's data array
*
* @return array Fixed recipient's data array
*/
Expand Down Expand Up @@ -934,9 +933,9 @@ protected function sendTheMail(Address $recipient, array $recipientRow = null):
/**
* Add HTML to an email
*
* @param string $file String location of the HTML
* @param string $file String location of the HTML
*
* @return mixed bool: HTML fetch status. string: if HTML is a frameset.
* @return mixed bool: HTML fetch status. string: if HTML is a frameset.
*/
public function addHTML(string $file)
{
Expand All @@ -957,7 +956,7 @@ public function addHTML(string $file)
/**
* Fetches the HTML-content from either url or local server file
*
* @param string $url Url of the html to fetch
* @param string $url Url of the html to fetch
*
* @return bool Whether the data was fetched or not
*/
Expand Down Expand Up @@ -1296,7 +1295,7 @@ public function extractFramesInfo(): bool
* Creates a regular expression out of a list of tags
*
* @param array $tags Array the list of tags
* (either as array or string if it is one tag)
* (either as array or string if it is one tag)
*
* @return string the regular expression
*/
Expand All @@ -1317,7 +1316,7 @@ protected function tag_regex(array $tags): string
* Check it with is_set();
*
* @param string $tag Tag is either like this "<TAG OPTION ATTRIB=VALUE>" or
* this " OPTION ATTRIB=VALUE>" which means you can omit the tag-name
* this " OPTION ATTRIB=VALUE>" which means you can omit the tag-name
* @param bool $removeQuotes When TRUE (default) quotes around a value will get removed
*
* @return array array with attributes as keys in lower-case
Expand Down
50 changes: 26 additions & 24 deletions Classes/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Resource\DuplicationBehavior;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\ArrayUtility;
Expand All @@ -39,7 +39,7 @@
/**
* Recipient list module for tx_directmail extension
*
* @author Ivan-Dharma Kartolo <[email protected]>
* @author Ivan-Dharma Kartolo <[email protected]>
*/
class Importer
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public function init(&$pObj): void
/**
* Import CSV-Data in step-by-step mode
*
* @return array HTML form
* @return array HTML form
*/
public function displayImport(): array
{
Expand Down Expand Up @@ -211,7 +211,7 @@ public function displayImport(): array
}

// check if "email" is mapped
$error = [];
$error = [];
if (isset($stepCurrent) && $stepCurrent === 'startImport') {
$map = $this->indata['map'];
// check noMap
Expand All @@ -227,9 +227,9 @@ public function displayImport(): array
}

$out = '';
if(!isset($stepCurrent)) {
$stepCurrent = '';
}
if (!isset($stepCurrent)) {
$stepCurrent = '';
}
switch ($stepCurrent) {
case 'conf':
$output['conf']['show'] = true;
Expand Down Expand Up @@ -269,7 +269,7 @@ public function displayImport(): array
// TODO: make it variable?
$optUnique = [
['val' => 'email', 'text' => 'email'],
['val' =>'name', 'text' => 'name'],
['val' => 'name', 'text' => 'name'],
];

$output['conf']['disableInput'] = ($this->params['inputDisable'] ?? 0) == 1 ? true : false;
Expand Down Expand Up @@ -524,8 +524,10 @@ public function displayImport(): array
* use it to manipulate the steps in the import process
*/
$hookObjectsArr = [];
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['displayImport']) &&
is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['displayImport'])) {
if (
isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['displayImport']) &&
is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['displayImport'])
) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['displayImport'] as $classRef) {
$hookObjectsArr[] = GeneralUtility::makeInstance($classRef);
}
Expand Down Expand Up @@ -562,7 +564,7 @@ public function filterCSV(array $mappedCsv): array
foreach ($mappedCsv as $k => $csvData) {
if (!in_array($k, $remove)) {
$found = 0;
foreach ($cmpCsv as $kk =>$cmpData) {
foreach ($cmpCsv as $kk => $cmpData) {
if ($k != $kk) {
if ($csvData[$this->indata['record_unique']] == $cmpData[$this->indata['record_unique']]) {
$double[] = $mappedCsv[$kk];
Expand Down Expand Up @@ -769,7 +771,7 @@ public function addDataArray(array &$data, $id, array $dataArray): void
* Read in the given CSV file. The function is used during the final file import.
* Removes first the first data row if the CSV has fieldnames.
*
* @return array file content in array
* @return array file content in array
*/
public function readCSV(): array
{
Expand Down Expand Up @@ -813,9 +815,9 @@ public function readCSV(): array
* Read in the given CSV file. Only showed a couple of the CSV values as example
* Removes first the first data row if the CSV has fieldnames.
*
* @param int $records Number of example values
* @param int $records Number of example values
*
* @return array File content in array
* @return array File content in array
*/
public function readExampleCSV($records = 3): array
{
Expand Down Expand Up @@ -865,7 +867,7 @@ public function readExampleCSV($records = 3): array
*
* @param array $data Contains values to convert
*
* @return array array of charset-converted values
* @return array array of charset-converted values
* @see \TYPO3\CMS\Core\Charset\CharsetConverter::conv[]
*/
public function convCharset(array $data): array
Expand All @@ -883,7 +885,7 @@ public function convCharset(array $data): array
/**
* Write CSV Data to a temporary file and will be used for the import
*
* @return array path and uid of the temp file
* @return array path and uid of the temp file
*/
public function writeTempFile(string $csv, string $newFile, int $newFileUid): array
{
Expand Down Expand Up @@ -933,7 +935,7 @@ public function writeTempFile(string $csv, string $newFile, int $newFileUid): ar
/**
* Checks if a file has been uploaded and returns the complete physical fileinfo if so.
*
* @return array \TYPO3\CMS\Core\Resource\File the complete physical file name, including path info.
* @return array \TYPO3\CMS\Core\Resource\File the complete physical file name, including path info.
* @throws \Exception
*/
public function checkUpload(): array
Expand Down Expand Up @@ -979,7 +981,7 @@ private function getFileById(int $fileUid) //: \TYPO3\CMS\Core\Resource\File|boo
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
try {
return $resourceFactory->getFileObject($fileUid);
} catch(\TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException $e) {
} catch (\TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException $e) {
}
return false;
}
Expand All @@ -1000,7 +1002,7 @@ private function getFileAbsolutePath(int $fileUid): string
/**
* Returns first temporary folder of the user account
*
* @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
* @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
*/
public function userTempFolder(): string
{
Expand Down Expand Up @@ -1044,11 +1046,11 @@ protected function getMessageQueue(): FlashMessageQueue

/**
https://api.typo3.org/11.5/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_messaging_1_1_abstract_message.html
const NOTICE = -2
const INFO = -1
const OK = 0
const WARNING = 1
const ERROR = 2
const NOTICE = -2
const INFO = -1
const OK = 0
const WARNING = 1
const ERROR = 2
* @param string $messageText
* @param string $messageHeader
* @param int $messageType
Expand Down
14 changes: 8 additions & 6 deletions Classes/Middleware/JumpurlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* JumpUrl processing hook on TYPO3\CMS\Frontend\Http\RequestHandler
*
* @author Ivan Kartolo <[email protected]>
* @author Ivan Kartolo <[email protected]>
*/
class JumpurlController implements MiddlewareInterface
{
Expand Down Expand Up @@ -125,7 +125,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

// to count the dmailerping correctly, we need something unique
$submittedAuthCode = preg_replace("/[^a-zA-Z0-9]/", "", $submittedAuthCode);
$submittedAuthCode = preg_replace('/[^a-zA-Z0-9]/', '', $submittedAuthCode);
}

if ($this->responseType !== 0) {
Expand Down Expand Up @@ -191,7 +191,7 @@ protected function getTargetUrl(int $targetIndex): string
['allowed_classes' => false]
);

if(is_array($mailContent)) {
if (is_array($mailContent)) {
if ($targetIndex >= 0) {
// Link (number)
$this->responseType = self::RESPONSE_TYPE_HREF;
Expand Down Expand Up @@ -266,7 +266,7 @@ protected function substituteUserMarkersFromTargetUrl(string $targetUrl): string
if (isset($this->recipientRecord[$substField])) {
$processedTargetUrl = str_replace(
'###USER_' . $substField . '###',
(string) $this->recipientRecord[$substField],
(string)$this->recipientRecord[$substField],
$processedTargetUrl
);
}
Expand Down Expand Up @@ -304,11 +304,13 @@ protected function substituteSystemMarkersFromTargetUrl(string $targetUrl): stri
protected function performFeUserAutoLogin()
{
// TODO: add a switch in Direct Mail configuration to decide if this option should be enabled by default
if ($this->recipientTable === 'fe_users' &&
if (
$this->recipientTable === 'fe_users' &&
GeneralUtility::inList(
$this->directMailRecord['authcode_fieldList'],
'password'
)) {
)
) {
$_POST['user'] = $this->recipientRecord['username'];
$_POST['pass'] = $this->recipientRecord['password'];
$_POST['pid'] = $this->recipientRecord['pid'];
Expand Down
8 changes: 4 additions & 4 deletions Classes/Module/ConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ protected function setDefaultValues(): void
}
}

/**
* Update the pageTS
* No return value: sent header to the same page
*/
/**
* Update the pageTS
* No return value: sent header to the same page
*/
protected function updatePageTS(): void
{
if ($this->getBackendUser()->doesUserHaveAccess(BackendUtility::getRecord('pages', $this->id), 2)) {
Expand Down
Loading

0 comments on commit 98396b6

Please sign in to comment.