Skip to content

Commit 7237470

Browse files
committed
[TASK] Apply more and newer php-cs-fixer rules
1 parent 2a6d9db commit 7237470

208 files changed

Lines changed: 1728 additions & 1120 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Build/.php-cs-fixer.dist.php

Lines changed: 482 additions & 52 deletions
Large diffs are not rendered by default.

Build/UnitTestsBootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use TYPO3\CMS\Core\Cache\Backend\NullBackend;
46
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
57
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
@@ -39,7 +41,7 @@
3941
* according script within TYPO3 core's Build/Scripts directory and
4042
* adapt to extensions needs.
4143
*/
42-
(static function () {
44+
(static function (): void {
4345
$testbase = new Testbase();
4446

4547
// These if's are for core testing (package typo3/cms) only. cms-composer-installer does

Build/phpstan-baseline.neon

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ parameters:
24272427
-
24282428
message: '#^Cannot access offset 0 on mixed\.$#'
24292429
identifier: offsetAccess.nonOffsetAccessible
2430-
count: 1
2430+
count: 4
24312431
path: ../Classes/Domain/Validator/OrderItemValidator.php
24322432

24332433
-
@@ -4197,7 +4197,7 @@ parameters:
41974197
-
41984198
message: '#^Cannot access offset ''templateLayouts\.'' on mixed\.$#'
41994199
identifier: offsetAccess.nonOffsetAccessible
4200-
count: 2
4200+
count: 3
42014201
path: ../Classes/Utility/TemplateLayout.php
42024202

42034203
-
@@ -4393,8 +4393,8 @@ parameters:
43934393
path: ../Classes/ViewHelpers/Format/CurrencyViewHelper.php
43944394

43954395
-
4396-
message: '#^Binary operation "/" between float and mixed results in an error\.$#'
4397-
identifier: binaryOp.invalid
4396+
message: '#^Binary operation "/\=" between float and mixed results in an error\.$#'
4397+
identifier: assignOp.invalid
43984398
count: 1
43994399
path: ../Classes/ViewHelpers/Format/CurrencyViewHelper.php
44004400

@@ -4903,8 +4903,8 @@ parameters:
49034903
path: ../Tests/Functional/Command/OrderItemCleanupCommandTest.php
49044904

49054905
-
4906-
message: '#^Method Extcode\\Cart\\Tests\\Functional\\Command\\OrderItemCleanupCommandTest\:\:wrongCutOffDateDataProvider\(\) has no return type specified\.$#'
4907-
identifier: missingType.return
4906+
message: '#^Method Extcode\\Cart\\Tests\\Functional\\Command\\OrderItemCleanupCommandTest\:\:wrongCutOffDateDataProvider\(\) return type has no value type specified in iterable type iterable\.$#'
4907+
identifier: missingType.iterableValue
49084908
count: 1
49094909
path: ../Tests/Functional/Command/OrderItemCleanupCommandTest.php
49104910

@@ -4975,7 +4975,7 @@ parameters:
49754975
path: ../Tests/Unit/Controller/ProductControllerTest.php
49764976

49774977
-
4978-
message: '#^Method Extcode\\Cart\\Tests\\Unit\\Controller\\ProductControllerTest\:\:getHighestSeverityDataProvider\(\) return type has no value type specified in iterable type Traversable\.$#'
4978+
message: '#^Method Extcode\\Cart\\Tests\\Unit\\Controller\\ProductControllerTest\:\:getHighestSeverityDataProvider\(\) return type has no value type specified in iterable type iterable\.$#'
49794979
identifier: missingType.iterableValue
49804980
count: 1
49814981
path: ../Tests/Unit/Controller/ProductControllerTest.php
@@ -4987,7 +4987,7 @@ parameters:
49874987
path: ../Tests/Unit/Controller/ProductControllerTest.php
49884988

49894989
-
4990-
message: '#^Method Extcode\\Cart\\Tests\\Unit\\Controller\\ProductControllerTest\:\:getLastHighestSeverityDataProvider\(\) return type has no value type specified in iterable type Traversable\.$#'
4990+
message: '#^Method Extcode\\Cart\\Tests\\Unit\\Controller\\ProductControllerTest\:\:getLastHighestSeverityDataProvider\(\) return type has no value type specified in iterable type iterable\.$#'
49914991
identifier: missingType.iterableValue
49924992
count: 1
49934993
path: ../Tests/Unit/Controller/ProductControllerTest.php
@@ -5323,7 +5323,7 @@ parameters:
53235323
path: ../Tests/Unit/Domain/Model/Product/MeasureTraitTest.php
53245324

53255325
-
5326-
message: '#^Method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\MeasureTraitTest\:\:measureUnitsProvider\(\) return type has no value type specified in iterable type array\.$#'
5326+
message: '#^Method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\MeasureTraitTest\:\:measureUnitsProvider\(\) return type has no value type specified in iterable type iterable\.$#'
53275327
identifier: missingType.iterableValue
53285328
count: 1
53295329
path: ../Tests/Unit/Domain/Model/Product/MeasureTraitTest.php

Classes/Command/OrderItemCleanupCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
parent::__construct();
2828
}
2929

30-
protected function configure()
30+
protected function configure(): void
3131
{
3232
$this->setDescription('Will remove all old orders');
3333
$this->addArgument(
@@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4141
{
4242
$cutOffDate = $input->getArgument('cutOffDate');
4343

44-
if (is_string($cutOffDate) === false || $this->isCutOffDateValid($cutOffDate) === false) {
44+
if (is_string($cutOffDate) === false || self::isCutOffDateValid($cutOffDate) === false) {
4545
$output->writeln('The cutOffDate argument must follow the pattern YYYY-MM-DD.');
4646

4747
return Command::FAILURE;
@@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5858
return Command::SUCCESS;
5959
}
6060

61-
private function isCutOffDateValid(string $cutOffDate): bool
61+
private static function isCutOffDateValid(string $cutOffDate): bool
6262
{
6363
$pattern = '/^\d{4}-\d{2}-\d{2}$/';
6464

Classes/Constants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ class Constants
1919
public const DOKTYPE_CART_CART = 181;
2020

2121
public const LANGUAGE_PATH = 'LLL:EXT:cart/Resources/Private/Language/locallang.xlf';
22+
2223
public const LANGUAGE_BE_PATH = 'LLL:EXT:cart/Resources/Private/Language/locallang_be.xlf';
2324
}

Classes/Controller/Backend/ActionController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
1919
{
2020
protected array $pluginSettings = [];
21+
2122
public function __construct(
2223
protected ConfigurationManagerInterface $configurationManager
23-
) {}
24+
) {
25+
}
2426

2527
protected function initializeAction(): void
2628
{
@@ -29,7 +31,7 @@ protected function initializeAction(): void
2931
ConfigurationManager::CONFIGURATION_TYPE_FRAMEWORK
3032
);
3133

32-
$pageId = (int)($this->request->getQueryParams()['id'] ?? 1);
34+
$pageId = (int) ($this->request->getQueryParams()['id'] ?? 1);
3335

3436
BackendUtility::readPageAccess(
3537
$pageId,

Classes/Controller/Backend/Order/DocumentController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class DocumentController extends ActionController
2828
public function __construct(
2929
protected readonly PersistenceManager $persistenceManager,
3030
protected readonly ItemRepository $itemRepository
31-
) {}
31+
) {
32+
}
3233

3334
public function createAction(Item $orderItem, string $pdfType): ResponseInterface
3435
{
@@ -79,12 +80,13 @@ public function downloadAction(Item $orderItem, string $pdfType): ResponseInterf
7980
->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
8081
->withHeader('Content-Description', 'File Transfer')
8182
->withHeader('Content-Disposition', 'attachment; filename="' . $originalPdf->getName() . '"')
82-
->withHeader('Content-Length', (string)$originalPdf->getSize())
83+
->withHeader('Content-Length', (string) $originalPdf->getSize())
8384
->withHeader('Content-Transfer-Encoding', 'binary')
8485
->withHeader('Content-Type', 'application/pdf')
8586
->withHeader('Expires', '0')
8687
->withHeader('Pragma', 'public')
87-
->withBody($this->streamFactory->createStream($originalPdf->getContents()));
88+
->withBody($this->streamFactory->createStream($originalPdf->getContents()))
89+
;
8890
}
8991

9092
return $this->htmlResponse();

Classes/Controller/Backend/Order/OrderController.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,24 @@
3333
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
3434
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
3535
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
36+
use stdClass;
3637

3738
class OrderController extends ActionController
3839
{
3940
private const LANG_FILE = 'LLL:EXT:cart/Resources/Private/Language/locallang.xlf:';
4041

41-
private ModuleTemplate $moduleTemplate;
42-
4342
protected array $searchArguments = [];
4443

44+
private ModuleTemplate $moduleTemplate;
45+
4546
public function __construct(
4647
protected readonly ModuleTemplateFactory $moduleTemplateFactory,
4748
protected readonly IconFactory $iconFactory,
4849
protected readonly PersistenceManager $persistenceManager,
4950
protected readonly ItemRepository $itemRepository,
5051
private readonly PageRenderer $pageRenderer,
5152
private readonly ComponentFactory $componentFactory
52-
) {}
53-
54-
protected function initializeAction(): void
55-
{
56-
parent::initializeAction();
57-
58-
if ($this->request->hasArgument('search')) {
59-
$this->searchArguments = $this->request->getArgument('search');
60-
}
53+
) {
6154
}
6255

6356
public function listAction(int $currentPage = 1): ResponseInterface
@@ -70,7 +63,7 @@ public function listAction(int $currentPage = 1): ResponseInterface
7063
$this->moduleTemplate->assign('settings', $this->settings);
7164
$this->moduleTemplate->assign('searchArguments', $this->searchArguments);
7265

73-
$itemsPerPage = (isset($this->settings['itemsPerPage']) && is_numeric($this->settings['itemsPerPage'])) ? (int)$this->settings['itemsPerPage'] : 20;
66+
$itemsPerPage = (isset($this->settings['itemsPerPage']) && is_numeric($this->settings['itemsPerPage'])) ? (int) $this->settings['itemsPerPage'] : 20;
7467

7568
$orderItems = $this->itemRepository->findAll($this->searchArguments);
7669
$arrayPaginator = new QueryResultPaginator(
@@ -156,7 +149,8 @@ public function exportAction(): ResponseInterface
156149
->withAddedHeader('Content-Type', 'text/' . $format)
157150
->withAddedHeader('Content-Description', 'File transfer')
158151
->withAddedHeader('Content-Disposition', 'attachment; filename="' . $filename . '"')
159-
->withBody($this->streamFactory->createStream($this->view->render()));
152+
->withBody($this->streamFactory->createStream($this->view->render()))
153+
;
160154
}
161155

162156
public function generateNumberAction(Item $orderItem, string $numberType): ResponseInterface
@@ -194,7 +188,7 @@ public function getPaymentStatus(): array
194188
{
195189
$paymentStatusArray = [];
196190

197-
$paymentStatus = new \stdClass();
191+
$paymentStatus = new stdClass();
198192
$paymentStatus->key = '';
199193
$paymentStatus->value = LocalizationUtility::translate(
200194
'tx_cart_domain_model_order_payment.status.all',
@@ -204,22 +198,23 @@ public function getPaymentStatus(): array
204198

205199
$entries = ['open', 'pending', 'paid', 'canceled'];
206200
foreach ($entries as $entry) {
207-
$paymentStatus = new \stdClass();
201+
$paymentStatus = new stdClass();
208202
$paymentStatus->key = $entry;
209203
$paymentStatus->value = LocalizationUtility::translate(
210204
'tx_cart_domain_model_order_payment.status.' . $entry,
211205
'Cart'
212206
);
213207
$paymentStatusArray[] = $paymentStatus;
214208
}
209+
215210
return $paymentStatusArray;
216211
}
217212

218213
public function getShippingStatus(): array
219214
{
220215
$shippingStatusArray = [];
221216

222-
$shippingStatus = new \stdClass();
217+
$shippingStatus = new stdClass();
223218
$shippingStatus->key = '';
224219
$shippingStatus->value = LocalizationUtility::translate(
225220
'tx_cart_domain_model_order_shipping.status.all',
@@ -229,17 +224,27 @@ public function getShippingStatus(): array
229224

230225
$entries = ['open', 'on_hold', 'in_process', 'shipped'];
231226
foreach ($entries as $entry) {
232-
$shippingStatus = new \stdClass();
227+
$shippingStatus = new stdClass();
233228
$shippingStatus->key = $entry;
234229
$shippingStatus->value = LocalizationUtility::translate(
235230
'tx_cart_domain_model_order_shipping.status.' . $entry,
236231
'Cart'
237232
);
238233
$shippingStatusArray[] = $shippingStatus;
239234
}
235+
240236
return $shippingStatusArray;
241237
}
242238

239+
protected function initializeAction(): void
240+
{
241+
parent::initializeAction();
242+
243+
if ($this->request->hasArgument('search')) {
244+
$this->searchArguments = $this->request->getArgument('search');
245+
}
246+
}
247+
243248
protected function getLanguageService(): LanguageService
244249
{
245250
return $GLOBALS['LANG'];
@@ -282,7 +287,8 @@ private function setDocHeader(array $buttons): void
282287
->setHref($button['link'])
283288
->setTitle($title)
284289
->setShowLabelText($button['showLabel'])
285-
->setIcon($icon);
290+
->setIcon($icon)
291+
;
286292
$buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $button['group']);
287293
}
288294
}

Classes/Controller/Backend/Order/PaymentController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ class PaymentController extends ActionController
2626
public function __construct(
2727
private readonly PaymentRepository $paymentRepository,
2828
private readonly LogServiceInterface $logService,
29-
) {}
29+
) {
30+
}
3031

3132
public function updateAction(Payment $payment): ResponseInterface
3233
{
3334
$this->paymentRepository->update($payment);
3435
$this->logService->write(
3536
Log::info(
36-
$this->getOrderItemUid($payment),
37+
self::getOrderItemUid($payment),
3738
'updatePayment',
3839
'Payment was set to ' . $payment->getStatus() . '.',
3940
[
@@ -55,7 +56,7 @@ public function updateAction(Payment $payment): ResponseInterface
5556
return $this->redirect('show', 'Backend\Order\Order', null, ['orderItem' => $payment->getItem()]);
5657
}
5758

58-
private function getOrderItemUid(Payment $payment): int
59+
private static function getOrderItemUid(Payment $payment): int
5960
{
6061
$orderItemUid = $payment->getItem()?->getUid();
6162

Classes/Controller/Backend/Order/ShippingController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ class ShippingController extends ActionController
2626
public function __construct(
2727
private readonly ShippingRepository $shippingRepository,
2828
private readonly LogServiceInterface $logService,
29-
) {}
29+
) {
30+
}
3031

3132
public function updateAction(Shipping $shipping): ResponseInterface
3233
{
3334
$this->shippingRepository->update($shipping);
3435
$this->logService->write(
3536
Log::info(
36-
$this->getOrderItemUid($shipping),
37+
self::getOrderItemUid($shipping),
3738
'updateShipping',
3839
'Shipping was set to ' . $shipping->getStatus() . '.',
3940
[
@@ -55,7 +56,7 @@ public function updateAction(Shipping $shipping): ResponseInterface
5556
return $this->redirect('show', 'Backend\Order\Order', null, ['orderItem' => $shipping->getItem()]);
5657
}
5758

58-
private function getOrderItemUid(Shipping $shipping): int
59+
private static function getOrderItemUid(Shipping $shipping): int
5960
{
6061
$orderItemUid = $shipping->getItem()?->getUid();
6162

0 commit comments

Comments
 (0)