Skip to content

Commit

Permalink
[TASK] Raise PHPstan level to 8 (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf authored May 4, 2024
1 parent e3ae8eb commit 7c78ff6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:

parameters:
phpVersion: 80200
level: 7
level: 8

bootstrapFiles:
- phpstan-typo3-constants.php
Expand Down
39 changes: 20 additions & 19 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use T3docs\Examples\Service\TableInformationService;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Routing\UriBuilder;
Expand Down Expand Up @@ -50,10 +49,8 @@
*
* @author Francois Suter (Cobweb) <[email protected]>
*/
class ModuleController extends ActionController implements LoggerAwareInterface
class ModuleController extends ActionController
{
use LoggerAwareTrait;

private int $pageUid;
/** @var array<string, mixed> */
private array $exampleConfig;
Expand All @@ -68,6 +65,7 @@ public function __construct(
protected readonly ConnectionPool $connectionPool,
protected readonly DataHandler $dataHandler,
protected readonly TableInformationService $tableInformationService,
private readonly LoggerInterface $logger,
) {}

/**
Expand Down Expand Up @@ -429,19 +427,22 @@ public function fileReferenceAction(int $element = 0): ResponseInterface
* @param int $element Uid of the content element
*/
public function fileReferenceCreateAction(
$file,
$element,
int $file,
int $element,
): ResponseInterface {
// Early return if either item is missing
if ((int)$file === 0 || (int)$element === 0) {
if ($file === 0 || $element === 0) {
// NOTE: there would normally a nice error Flash Message added here
$this->redirect('fileReference');
}
$fileObject = $this->resourceFactory->getFileObject((int)$file);
$fileObject = $this->resourceFactory->getFileObject($file);
$contentElement = BackendUtility::getRecord(
'tt_content',
(int)$element,
$element,
);
if ($contentElement === null) {
throw new \Exception('Content element with uid ' . $element . ' not found');
}
// Assemble DataHandler data
$newId = 'NEW1234';
$data = [];
Expand All @@ -465,7 +466,7 @@ public function fileReferenceCreateAction(
LocalizationUtility::translate(
'create_relation_success',
'examples',
),
) ?? '',
'',
);
} else {
Expand All @@ -475,7 +476,7 @@ public function fileReferenceCreateAction(
LocalizationUtility::translate(
'create_relation_error',
'examples',
),
) ?? '',
ContextualFeedbackSeverity::ERROR,
);
}
Expand All @@ -492,7 +493,7 @@ public function fileReferenceCreateAction(
);
}

public function getPasswordHash(string $password, string $mode): string
public function getPasswordHash(string $password, string $mode): string|null
{
$hashInstance = $this->passwordHashFactory->getDefaultHashInstance($mode);
return $hashInstance->getHashedPassword($password);
Expand Down Expand Up @@ -545,15 +546,15 @@ public function countAction(string $tablename = 'pages'): ResponseInterface
$count = $this->tableInformationService->countRecords($tablename);

$message = LocalizationUtility::translate(
key: 'record_count_message',
extensionName: 'examples',
arguments: [$count, $tablename],
'record_count_message',
'examples',
[$count, $tablename],
);

$this->addFlashMessage(
messageBody: $message,
messageTitle: 'Information',
severity: ContextualFeedbackSeverity::INFO,
$message ?? '',
'Information',
ContextualFeedbackSeverity::INFO,
);
return $this->redirect('flash');
}
Expand Down

0 comments on commit 7c78ff6

Please sign in to comment.