Skip to content

Commit d4257fd

Browse files
authored
[TASK] Apply rector to fix Extbase arguments (#179)
1 parent dc4d518 commit d4257fd

File tree

12 files changed

+53
-80
lines changed

12 files changed

+53
-80
lines changed

Build/Scripts/runTests.sh

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ Options:
139139
- composer: "composer" with all remaining arguments dispatched.
140140
- composerNormalize: "composer normalize"
141141
- composerUpdate: "composer update", handy if host has no PHP
142-
- composerUpdateRector: "composer update", for rector subdirectory
143142
- composerValidate: "composer validate"
144143
- functional: PHP functional tests
145144
- lint: PHP linting
@@ -454,18 +453,6 @@ case ${TEST_SUITE} in
454453
cp ${ROOT_DIR}/composer.json ${ROOT_DIR}/composer.json.testing
455454
mv ${ROOT_DIR}/composer.json.orig ${ROOT_DIR}/composer.json
456455
;;
457-
composerUpdateRector)
458-
rm -rf Build/rector/.Build/bin/ Build/rector/.Build/vendor Build/rector/composer.lock
459-
cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.orig
460-
if [ -f "${ROOT_DIR}/Build/rector/composer.json.testing" ]; then
461-
cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.orig
462-
fi
463-
COMMAND=(composer require --working-dir=${ROOT_DIR}/Build/rector --no-ansi --no-interaction --no-progress)
464-
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-install-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
465-
SUITE_EXIT_CODE=$?
466-
cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.testing
467-
mv ${ROOT_DIR}/Build/rector/composer.json.orig ${ROOT_DIR}/Build/rector/composer.json
468-
;;
469456
composerValidate)
470457
COMMAND=(composer validate "$@")
471458
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
@@ -524,9 +511,9 @@ case ${TEST_SUITE} in
524511
;;
525512
rector)
526513
if [ "${CGLCHECK_DRY_RUN}" -eq 1 ]; then
527-
COMMAND=(php -dxdebug.mode=off Build/rector/.Build/bin/rector -n --config=Build/rector/rector.php --clear-cache "$@")
514+
COMMAND=(php -dxdebug.mode=off .Build/bin/rector -n --config=Build/rector/rector.php --clear-cache "$@")
528515
else
529-
COMMAND=(php -dxdebug.mode=off Build/rector/.Build/bin/rector --config=Build/rector/rector.php --clear-cache "$@")
516+
COMMAND=(php -dxdebug.mode=off .Build/bin/rector --config=Build/rector/rector.php --clear-cache "$@")
530517
fi
531518
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name rector-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
532519
SUITE_EXIT_CODE=$?

Build/rector/composer.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

Classes/Controller/BackendController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(
6464

6565
public function addPopulateButton(ButtonBar $buttonBar): void
6666
{
67-
$populateButton = $buttonBar->makeLinkButton()
67+
$populateButton = $this->componentFactory->createLinkButton()
6868
->setHref($this->uriBuilder->reset()->uriFor('populate'))
6969
->setTitle('Create example data')
7070
->setShowLabelText(true)
@@ -235,13 +235,13 @@ private function modifyDocHeaderComponent(ModuleTemplate $view, string &$context
235235

236236
$metaInformation = $this->getMetaInformation();
237237
if (is_array($metaInformation)) {
238-
$view->getDocHeaderComponent()->setMetaInformation($metaInformation);
238+
$view->getDocHeaderComponent()->setPageBreadcrumb($metaInformation);
239239
}
240240
}
241241

242242
private function addReloadButton(ButtonBar $buttonBar): void
243243
{
244-
$reloadButton = $buttonBar->makeLinkButton()
244+
$reloadButton = $this->componentFactory->createLinkButton()
245245
->setHref($this->request->getAttribute('normalizedParams')->getRequestUri())
246246
->setTitle($this->getLanguageService()->sL('core.core:labels.reload'))
247247
->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL));
@@ -250,7 +250,7 @@ private function addReloadButton(ButtonBar $buttonBar): void
250250

251251
private function addShortCutButton(ButtonBar $buttonBar): void
252252
{
253-
$shortcutButton = $buttonBar->makeShortcutButton()
253+
$shortcutButton = $this->componentFactory->createShortcutButton()
254254
->setRouteIdentifier('blog_example')
255255
->setDisplayName($this->getLanguageService()->sL('blog_example.messages:administration.menu.index'));
256256
$buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
@@ -280,12 +280,12 @@ private function buildMenu(ModuleTemplate $view, string &$context): Menu
280280
//$menu = $this->componentFactory->createMenu();
281281
//$menu->setIdentifier('viewSelector')->setLabel('View');
282282

283-
$menu = $view->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
283+
$menu = $this->componentFactory->createMenu();
284284
$menu->setIdentifier('BlogExampleModuleMenu')->setLabel('View');
285285

286286
foreach ($menuItems as $menuItemConfig) {
287287
$isActive = $this->request->getControllerActionName() === $menuItemConfig['action'];
288-
$menuItem = $menu->makeMenuItem()
288+
$menuItem = $this->componentFactory->createMenuItem()
289289
->setTitle($menuItemConfig['label'])
290290
->setHref($this->uriBuilder->reset()->uriFor(
291291
$menuItemConfig['action'],

Classes/Controller/BlogController.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public function helloWorldAction(): ResponseInterface
7979
/**
8080
* Displays a form for creating a new blog
8181
*/
82-
#[IgnoreValidation(['value' => 'newBlog'])]
83-
public function newAction(?Blog $newBlog = null): ResponseInterface
84-
{
82+
public function newAction(
83+
#[IgnoreValidation]
84+
?Blog $newBlog = null,
85+
): ResponseInterface {
8586
$this->view->assignMultiple([
8687
'newBlog' => $newBlog,
8788
'administrators' => $this->administratorRepository->findAll(),
@@ -95,9 +96,10 @@ public function newAction(?Blog $newBlog = null): ResponseInterface
9596
* $blog is a fresh Blog object which has not yet been added to the
9697
* repository
9798
*/
98-
#[Validate(['param' => 'newBlog', 'validator' => BlogValidator::class])]
99-
public function createAction(Blog $newBlog): ResponseInterface
100-
{
99+
public function createAction(
100+
#[Validate(validator: BlogValidator::class)]
101+
Blog $newBlog,
102+
): ResponseInterface {
101103
$this->checkBlogAdminAccess();
102104
$this->blogRepository->add($newBlog);
103105
$this->addFlashMessage('created');
@@ -111,9 +113,10 @@ public function createAction(Blog $newBlog): ResponseInterface
111113
* modifications if the edit form has been submitted, contained errors and
112114
* therefore ended up in this action again.
113115
*/
114-
#[IgnoreValidation(['value' => 'blog'])]
115-
public function editAction(Blog $blog): ResponseInterface
116-
{
116+
public function editAction(
117+
#[IgnoreValidation]
118+
Blog $blog,
119+
): ResponseInterface {
117120
$this->view->assignMultiple([
118121
'blog' => $blog,
119122
'administrators' => $this->administratorRepository->findAll(),
@@ -129,9 +132,10 @@ public function editAction(Blog $blog): ResponseInterface
129132
*
130133
* @throws NoBlogAdminAccessException
131134
*/
132-
#[Validate(['param' => 'blog', 'validator' => BlogValidator::class])]
133-
public function updateAction(Blog $blog): ResponseInterface
134-
{
135+
public function updateAction(
136+
#[Validate(validator: BlogValidator::class)]
137+
Blog $blog,
138+
): ResponseInterface {
135139
$this->checkBlogAdminAccess();
136140
$this->blogRepository->update($blog);
137141
$this->addFlashMessage('updated');

Classes/Controller/PostController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public function displayRssListAction(): ResponseInterface
138138
/**
139139
* Displays one single post
140140
*/
141-
#[IgnoreValidation(['value' => 'newComment'])]
142141
public function showAction(
143142
Post $post,
143+
#[IgnoreValidation]
144144
?Comment $newComment = null,
145145
): ResponseInterface {
146146
$this->blogPageTitleProvider->setTitle($post->getTitle());
@@ -156,9 +156,9 @@ public function showAction(
156156
*
157157
* $newPost is a fresh post object taken as a basis for the rendering
158158
*/
159-
#[IgnoreValidation(['value' => 'newPost'])]
160159
public function newAction(
161160
Blog $blog,
161+
#[IgnoreValidation]
162162
?Post $newPost = null,
163163
): ResponseInterface {
164164
$this->view->assignMultiple([
@@ -167,7 +167,6 @@ public function newAction(
167167
'newPost' => $newPost,
168168
'remainingPosts' => $this->postRepository->findBy(['blog' => $blog]),
169169
]);
170-
171170
return $this->htmlResponse();
172171
}
173172

@@ -190,9 +189,11 @@ public function createAction(
190189
/**
191190
* Displays a form to edit an existing post
192191
*/
193-
#[IgnoreValidation(['value' => 'post'])]
194-
public function editAction(Blog $blog, Post $post): ResponseInterface
195-
{
192+
public function editAction(
193+
Blog $blog,
194+
#[IgnoreValidation]
195+
Post $post,
196+
): ResponseInterface {
196197
$this->view->assignMultiple([
197198
'authors' => $this->personRepository->findAll(),
198199
'blog' => $blog,

Classes/Domain/Model/Blog.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
*/
3131
class Blog extends AbstractEntity
3232
{
33-
#[Validate(['validator' => TitleValidator::class])]
33+
#[Validate(validator: TitleValidator::class)]
3434
public string $title = '';
3535

36-
#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 5, 'maximum' => 80]])]
36+
#[Validate(validator: 'StringLength', options: ['minimum' => 5, 'maximum' => 80])]
3737
public string|null $subtitle = null;
3838

3939
/**
4040
* A short description of the blog
4141
*/
42-
#[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 150]])]
42+
#[Validate(validator: 'StringLength', options: ['maximum' => 150])]
4343
public string $description = '';
4444

4545
/**
@@ -51,7 +51,7 @@ class Blog extends AbstractEntity
5151
* @var ?ObjectStorage<Post>
5252
*/
5353
#[Lazy()]
54-
#[Cascade(['value' => 'remove'])]
54+
#[Cascade('remove')]
5555
public ?ObjectStorage $posts = null;
5656

5757
/**

Classes/Domain/Model/Comment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class Comment extends AbstractEntity implements \Stringable
2626
{
2727
protected \DateTime $date;
2828

29-
#[Validate(['validator' => 'NotEmpty'])]
29+
#[Validate(validator: 'NotEmpty')]
3030
protected string $author = '';
3131

32-
#[Validate(['validator' => 'EmailAddress'])]
32+
#[Validate(validator: 'EmailAddress')]
3333
protected string $email = '';
3434

35-
#[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 500]])]
35+
#[Validate(validator: 'StringLength', options: ['maximum' => 500])]
3636
protected string $content = '';
3737

3838
protected bool $hidden = true;

Classes/Domain/Model/Person.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
*/
2828
class Person extends AbstractEntity
2929
{
30-
#[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 80]])]
30+
#[Validate(validator: 'StringLength', options: ['maximum' => 80])]
3131
protected string $firstname = '';
3232

33-
#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 2, 'maximum' => 80]])]
33+
#[Validate(validator: 'StringLength', options: ['minimum' => 2, 'maximum' => 80])]
3434
protected string $lastname = '';
3535

3636
#[Transient()]
3737
protected string $fullname = '';
3838

39-
#[Validate(['validator' => 'EmailAddress'])]
39+
#[Validate(validator: 'EmailAddress')]
4040
protected string $email = '';
4141

4242
/**

Classes/Domain/Model/Post.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Post extends AbstractEntity implements \Stringable
3030
{
3131
protected ?Blog $blog = null;
3232

33-
#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 3, 'maximum' => 50]])]
33+
#[Validate(validator: 'StringLength', options: ['minimum' => 3, 'maximum' => 50])]
3434
protected string $title = '';
3535

3636
/**
@@ -45,13 +45,13 @@ class Post extends AbstractEntity implements \Stringable
4545
protected ?Person $secondAuthor = null;
4646
protected ?Person $reviewer = null;
4747

48-
#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 3]])]
48+
#[Validate(validator: 'StringLength', options: ['minimum' => 3])]
4949
protected string $content = '';
5050

5151
/**
5252
* @var ?ObjectStorage<Tag>
5353
*/
54-
#[Cascade(['value' => 'remove'])]
54+
#[Cascade('remove')]
5555
public ?ObjectStorage $tags = null;
5656

5757
/**
@@ -63,7 +63,7 @@ class Post extends AbstractEntity implements \Stringable
6363
* @var ?ObjectStorage<Comment>
6464
*/
6565
#[Lazy()]
66-
#[Cascade(['value' => 'remove'])]
66+
#[Cascade('remove')]
6767
public ?ObjectStorage $comments = null;
6868

6969
/**
@@ -75,13 +75,13 @@ class Post extends AbstractEntity implements \Stringable
7575
/**
7676
* 1:1 optional relation
7777
*/
78-
#[Cascade(['value' => 'remove'])]
78+
#[Cascade('remove')]
7979
public ?Info $additionalName = null;
8080

8181
/**
8282
* 1:1 optional relation
8383
*/
84-
#[Cascade(['value' => 'remove'])]
84+
#[Cascade('remove')]
8585
protected ?Info $additionalInfo = null;
8686

8787
/**

Classes/Upgrades/MigratePluginsToContentElementsUpgradeWizard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace T3docs\BlogExample\Upgrades;
44

5+
use TYPO3\CMS\Core\Attribute\UpgradeWizard;
56
use TYPO3\CMS\Core\Database\ConnectionPool;
67
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
78
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
9+
use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface;
810
use TYPO3\CMS\Core\Utility\GeneralUtility;
9-
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
10-
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
1111

1212
#[UpgradeWizard('blogExample_migratePluginsToContentElementsUpgradeWizard')]
1313
final readonly class MigratePluginsToContentElementsUpgradeWizard implements UpgradeWizardInterface

0 commit comments

Comments
 (0)