Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Commit abb3fbe

Browse files
sabbelasichon7elix
authored andcommitted
[TASK] Add phpstan
# Conflicts: # composer.json
1 parent 8a941fc commit abb3fbe

13 files changed

+509
-15
lines changed

Classes/Ajax/RemoveFile.php

+41-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,54 @@
2222
*/
2323
class RemoveFile
2424
{
25+
/**
26+
* @var string
27+
*/
28+
private $fieldName;
29+
30+
/**
31+
* @var string
32+
*/
33+
private $uploadedFileName;
34+
35+
/**
36+
* @var Manager
37+
*/
38+
private $componentManager;
39+
40+
/**
41+
* @var Globals
42+
*/
43+
private $globals;
44+
45+
/**
46+
* @var int
47+
*/
48+
private $id;
49+
50+
/**
51+
* @var \Typoheads\Formhandler\Utility\GeneralUtility
52+
*/
53+
private $utilityFuncs;
54+
55+
/**
56+
* @var array
57+
*/
58+
private $settings;
59+
60+
/**
61+
* @var array
62+
*/
63+
private $langFiles;
2564

2665
/**
2766
* Main method of the class.
28-
*
29-
* @return string The HTML list of remaining files to be displayed in the form
3067
*/
3168
public function main()
3269
{
3370
$this->init();
3471
$content = '';
72+
$field = null;
3573

3674
if ($this->fieldName) {
3775
$sessionFiles = $this->globals->getSession()->get('files');
@@ -72,7 +110,7 @@ public function main()
72110
$this->globals->getSession()->set('files', $sessionFiles);
73111

74112
// Add the content to or Result Box: #formResult
75-
if (is_array($sessionFiles) && !empty($sessionFiles[$field])) {
113+
if ($field !== null && is_array($sessionFiles) && !empty($sessionFiles[$field])) {
76114
$markers = [];
77115
$view = $this->componentManager->getComponent('View\\Form');
78116
$view->setSettings($this->settings);

Classes/Ajax/Validate.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Typoheads\Formhandler\Ajax;
33

4+
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
45
use Typoheads\Formhandler\Utility\Globals;
56
use Typoheads\Formhandler\Component\Manager;
67
/* *
@@ -18,6 +19,7 @@
1819
* */
1920
use TYPO3\CMS\Core\Utility\GeneralUtility;
2021
use TYPO3\CMS\Core\Utility\PathUtility;
22+
use Typoheads\Formhandler\View\AjaxValidation;
2123

2224
/**
2325
* A class validating a field via AJAX.
@@ -33,6 +35,22 @@ class Validate
3335
'spanError' => '<span class="error">%s</span>',
3436
];
3537

38+
/**
39+
* @var Manager
40+
*/
41+
private $componentManager;
42+
43+
/**
44+
* @var array
45+
*/
46+
private $settings;
47+
48+
49+
/**
50+
* @var int
51+
*/
52+
private $id;
53+
3654
/**
3755
* Main method of the class.
3856
*
@@ -106,7 +124,7 @@ protected function init()
106124
* Initialize the AJAX validation view.
107125
*
108126
* @param string $content The raw content
109-
* @return Tx_Formhandler_View_AjaxValidation The view class
127+
* @return AjaxValidation The view class
110128
*/
111129
protected function initView($content)
112130
{

Classes/AjaxHandler/JQuery.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Typoheads\Formhandler\AjaxHandler;
33

4+
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
45
use TYPO3\CMS\Core\Utility\GeneralUtility;
56
use TYPO3\CMS\Core\Context\Context;
67
/* *

Classes/Component/AbstractClass.php

+10
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ abstract class AbstractClass
5959
*/
6060
protected $cObj;
6161

62+
/**
63+
* @var array
64+
*/
65+
protected $settings;
66+
67+
/**
68+
* @var array
69+
*/
70+
protected $validationStatusClasses;
71+
6272
/**
6373
* The constructor for an interceptor setting the component manager and the configuration.
6474
*

Classes/Controller/Configuration.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Typoheads\Formhandler\Controller;
33

4+
use TYPO3\CMS\Core\Http\ApplicationType;
45
use Typoheads\Formhandler\Utility\Globals;
56
/* *
67
* This script is part of the TYPO3 project - inspiring people to share! *
@@ -36,12 +37,22 @@ class Configuration implements \ArrayAccess
3637
*/
3738
protected $setup;
3839

40+
/**
41+
* @var Globals
42+
*/
43+
private $globals;
44+
45+
/**
46+
* @var \Typoheads\Formhandler\Utility\GeneralUtility
47+
*/
48+
private $utilityFuncs;
49+
3950
/**
4051
* The constructor reading the TS setup into the according attribute
4152
*/
4253
public function __construct()
4354
{
44-
if (TYPO3_MODE === 'FE') {
55+
if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) {
4556
$this->globals = GeneralUtility::makeInstance(Globals::class);
4657
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
4758
$this->setup = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->getPrefixedPackageKey() . '.'];
@@ -57,7 +68,7 @@ public function __construct()
5768
/**
5869
* Merges the values of $setup with plugin.[xxx].settings
5970
*
60-
* @param array $setup
71+
* @param array|null $setup
6172
*/
6273
public function merge($setup)
6374
{

Classes/Controller/Dispatcher.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Typoheads\Formhandler\Controller;
33

4+
use TYPO3\CMS\Core\Log\LogManager;
45
use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
56
use Typoheads\Formhandler\Component\Manager;
67
use Typoheads\Formhandler\Utility\Globals;
@@ -49,12 +50,11 @@ class Dispatcher extends AbstractPlugin
4950
* Main method of the dispatcher. This method is called as a user function.
5051
*
5152
* @return string rendered view
52-
* @param string $content
53+
* @param string|null $content
5354
* @param array $setup The TypoScript config
5455
*/
5556
public function main($content, $setup)
5657
{
57-
$this->pi_USER_INT_obj = 1;
5858
$this->componentManager = GeneralUtility::makeInstance(Manager::class);
5959
$this->globals = GeneralUtility::makeInstance(Globals::class);
6060
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
@@ -113,11 +113,11 @@ public function main($content, $setup)
113113

114114
$result = $controller->process();
115115
} catch (\Exception $e) {
116-
GeneralUtility::sysLog(
116+
GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__)->error(
117117
$e->getFile() . '(' . $e->getLine() . ')' . ' ' . $e->getMessage(),
118-
'formhandler',
119-
GeneralUtility::SYSLOG_SEVERITY_ERROR
118+
['formhandler']
120119
);
120+
121121
$result = $this->utilityFuncs->getTranslatedMessage($this->globals->getLangFiles(), 'fe-exception');
122122
if (!$result) {
123123
$result = '<div style="color:red; font-weight: bold">' . $this->utilityFuncs->getExceptionMessage('fe-exception') . '</div>';

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"require": {
88
"typo3/cms-core": "^10.4.0",
99
"tecnickcom/tcpdf": "^6.0",
10-
"parsecsv/php-parsecsv": "^0.4",
1110
"typo3/cms-extbase": "^10.4.0",
1211
"typo3/cms-fluid": "^10.4.0",
13-
"typo3/cms-frontend": "^10.4.0"
12+
"typo3/cms-frontend": "^10.4.0",
13+
"parsecsv/php-parsecsv": "^1.2"
1414
},
1515
"autoload": {
1616
"psr-4": {

dynamicReturnTypeMeta.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"methodCalls": [
3+
{
4+
"class": "\\TYPO3\\CMS\\Core\\Utility\\GeneralUtility",
5+
"method": "makeInstance",
6+
"position": 0
7+
},
8+
{
9+
"class": "\\TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface",
10+
"method": "get",
11+
"position": 0
12+
}
13+
],
14+
"functionCalls": [
15+
]
16+
}

ext_emconf.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$EM_CONF[$_EXTKEY] = [
3+
$EM_CONF['formhandler'] = [
44
'title' => 'Formhandler',
55
'description' => 'The swiss army knife for all kinds of mailforms, completely new written using the MVC concept. Result: Flexibility, Flexibility, Flexibility :-).',
66
'category' => 'plugin',

ext_localconf.php

+8
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@
3131
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
3232
['source' => 'EXT:formhandler/Resources/Public/Images/pagetreeicon.png']
3333
);
34+
35+
if (!isset($GLOBALS['TYPO3_CONF_VARS']['LOG']['Typoheads']['Formhandler']['writerConfiguration'])) {
36+
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Typoheads']['Formhandler']['writerConfiguration'] = [
37+
\TYPO3\CMS\Core\Log\LogLevel::ERROR => [
38+
\TYPO3\CMS\Core\Log\Writer\SyslogWriter::class => []
39+
],
40+
];
41+
}

0 commit comments

Comments
 (0)