diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index cb30cba..1532432 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -139,7 +139,6 @@ Options: - composer: "composer" with all remaining arguments dispatched. - composerNormalize: "composer normalize" - composerUpdate: "composer update", handy if host has no PHP - - composerUpdateRector: "composer update", for rector subdirectory - composerValidate: "composer validate" - functional: PHP functional tests - lint: PHP linting @@ -454,18 +453,6 @@ case ${TEST_SUITE} in cp ${ROOT_DIR}/composer.json ${ROOT_DIR}/composer.json.testing mv ${ROOT_DIR}/composer.json.orig ${ROOT_DIR}/composer.json ;; - composerUpdateRector) - rm -rf Build/rector/.Build/bin/ Build/rector/.Build/vendor Build/rector/composer.lock - cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.orig - if [ -f "${ROOT_DIR}/Build/rector/composer.json.testing" ]; then - cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.orig - fi - COMMAND=(composer require --working-dir=${ROOT_DIR}/Build/rector --no-ansi --no-interaction --no-progress) - ${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[@]}" - SUITE_EXIT_CODE=$? - cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.testing - mv ${ROOT_DIR}/Build/rector/composer.json.orig ${ROOT_DIR}/Build/rector/composer.json - ;; composerValidate) COMMAND=(composer validate "$@") ${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 ;; rector) if [ "${CGLCHECK_DRY_RUN}" -eq 1 ]; then - COMMAND=(php -dxdebug.mode=off Build/rector/.Build/bin/rector -n --config=Build/rector/rector.php --clear-cache "$@") + COMMAND=(php -dxdebug.mode=off .Build/bin/rector -n --config=Build/rector/rector.php --clear-cache "$@") else - COMMAND=(php -dxdebug.mode=off Build/rector/.Build/bin/rector --config=Build/rector/rector.php --clear-cache "$@") + COMMAND=(php -dxdebug.mode=off .Build/bin/rector --config=Build/rector/rector.php --clear-cache "$@") fi ${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[@]}" SUITE_EXIT_CODE=$? diff --git a/Build/rector/composer.json b/Build/rector/composer.json deleted file mode 100644 index 3f3f8b5..0000000 --- a/Build/rector/composer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "t3docs/blog-example-rector", - "description": "Rector in its own package to avoid compability issues.", - "license": "GPL-2.0-or-later", - "type": "typo3-cms-extension", - "authors": [ - { - "name": "TYPO3 Documentation Team and contributors", - "role": "Developer" - } - ], - "require": { - "ssch/typo3-rector": "^3.6" - }, - "config": { - "bin-dir": ".Build/bin", - "sort-packages": true, - "vendor-dir": ".Build/vendor" - } -} diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 8621928..e5b7a85 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -64,7 +64,7 @@ public function __construct( public function addPopulateButton(ButtonBar $buttonBar): void { - $populateButton = $buttonBar->makeLinkButton() + $populateButton = $this->componentFactory->createLinkButton() ->setHref($this->uriBuilder->reset()->uriFor('populate')) ->setTitle('Create example data') ->setShowLabelText(true) @@ -235,13 +235,13 @@ private function modifyDocHeaderComponent(ModuleTemplate $view, string &$context $metaInformation = $this->getMetaInformation(); if (is_array($metaInformation)) { - $view->getDocHeaderComponent()->setMetaInformation($metaInformation); + $view->getDocHeaderComponent()->setPageBreadcrumb($metaInformation); } } private function addReloadButton(ButtonBar $buttonBar): void { - $reloadButton = $buttonBar->makeLinkButton() + $reloadButton = $this->componentFactory->createLinkButton() ->setHref($this->request->getAttribute('normalizedParams')->getRequestUri()) ->setTitle($this->getLanguageService()->sL('core.core:labels.reload')) ->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL)); @@ -250,7 +250,7 @@ private function addReloadButton(ButtonBar $buttonBar): void private function addShortCutButton(ButtonBar $buttonBar): void { - $shortcutButton = $buttonBar->makeShortcutButton() + $shortcutButton = $this->componentFactory->createShortcutButton() ->setRouteIdentifier('blog_example') ->setDisplayName($this->getLanguageService()->sL('blog_example.messages:administration.menu.index')); $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT); @@ -280,12 +280,12 @@ private function buildMenu(ModuleTemplate $view, string &$context): Menu //$menu = $this->componentFactory->createMenu(); //$menu->setIdentifier('viewSelector')->setLabel('View'); - $menu = $view->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); + $menu = $this->componentFactory->createMenu(); $menu->setIdentifier('BlogExampleModuleMenu')->setLabel('View'); foreach ($menuItems as $menuItemConfig) { $isActive = $this->request->getControllerActionName() === $menuItemConfig['action']; - $menuItem = $menu->makeMenuItem() + $menuItem = $this->componentFactory->createMenuItem() ->setTitle($menuItemConfig['label']) ->setHref($this->uriBuilder->reset()->uriFor( $menuItemConfig['action'], diff --git a/Classes/Controller/BlogController.php b/Classes/Controller/BlogController.php index 84679f0..570bb92 100644 --- a/Classes/Controller/BlogController.php +++ b/Classes/Controller/BlogController.php @@ -79,9 +79,10 @@ public function helloWorldAction(): ResponseInterface /** * Displays a form for creating a new blog */ - #[IgnoreValidation(['value' => 'newBlog'])] - public function newAction(?Blog $newBlog = null): ResponseInterface - { + public function newAction( + #[IgnoreValidation] + ?Blog $newBlog = null, + ): ResponseInterface { $this->view->assignMultiple([ 'newBlog' => $newBlog, 'administrators' => $this->administratorRepository->findAll(), @@ -95,9 +96,10 @@ public function newAction(?Blog $newBlog = null): ResponseInterface * $blog is a fresh Blog object which has not yet been added to the * repository */ - #[Validate(['param' => 'newBlog', 'validator' => BlogValidator::class])] - public function createAction(Blog $newBlog): ResponseInterface - { + public function createAction( + #[Validate(validator: BlogValidator::class)] + Blog $newBlog, + ): ResponseInterface { $this->checkBlogAdminAccess(); $this->blogRepository->add($newBlog); $this->addFlashMessage('created'); @@ -111,9 +113,10 @@ public function createAction(Blog $newBlog): ResponseInterface * modifications if the edit form has been submitted, contained errors and * therefore ended up in this action again. */ - #[IgnoreValidation(['value' => 'blog'])] - public function editAction(Blog $blog): ResponseInterface - { + public function editAction( + #[IgnoreValidation] + Blog $blog, + ): ResponseInterface { $this->view->assignMultiple([ 'blog' => $blog, 'administrators' => $this->administratorRepository->findAll(), @@ -129,9 +132,10 @@ public function editAction(Blog $blog): ResponseInterface * * @throws NoBlogAdminAccessException */ - #[Validate(['param' => 'blog', 'validator' => BlogValidator::class])] - public function updateAction(Blog $blog): ResponseInterface - { + public function updateAction( + #[Validate(validator: BlogValidator::class)] + Blog $blog, + ): ResponseInterface { $this->checkBlogAdminAccess(); $this->blogRepository->update($blog); $this->addFlashMessage('updated'); diff --git a/Classes/Controller/PostController.php b/Classes/Controller/PostController.php index c3b7154..2afc8dd 100644 --- a/Classes/Controller/PostController.php +++ b/Classes/Controller/PostController.php @@ -138,9 +138,9 @@ public function displayRssListAction(): ResponseInterface /** * Displays one single post */ - #[IgnoreValidation(['value' => 'newComment'])] public function showAction( Post $post, + #[IgnoreValidation] ?Comment $newComment = null, ): ResponseInterface { $this->blogPageTitleProvider->setTitle($post->getTitle()); @@ -156,9 +156,9 @@ public function showAction( * * $newPost is a fresh post object taken as a basis for the rendering */ - #[IgnoreValidation(['value' => 'newPost'])] public function newAction( Blog $blog, + #[IgnoreValidation] ?Post $newPost = null, ): ResponseInterface { $this->view->assignMultiple([ @@ -167,7 +167,6 @@ public function newAction( 'newPost' => $newPost, 'remainingPosts' => $this->postRepository->findBy(['blog' => $blog]), ]); - return $this->htmlResponse(); } @@ -190,9 +189,11 @@ public function createAction( /** * Displays a form to edit an existing post */ - #[IgnoreValidation(['value' => 'post'])] - public function editAction(Blog $blog, Post $post): ResponseInterface - { + public function editAction( + Blog $blog, + #[IgnoreValidation] + Post $post, + ): ResponseInterface { $this->view->assignMultiple([ 'authors' => $this->personRepository->findAll(), 'blog' => $blog, diff --git a/Classes/Domain/Model/Blog.php b/Classes/Domain/Model/Blog.php index e942ff4..abb4137 100644 --- a/Classes/Domain/Model/Blog.php +++ b/Classes/Domain/Model/Blog.php @@ -30,16 +30,16 @@ */ class Blog extends AbstractEntity { - #[Validate(['validator' => TitleValidator::class])] + #[Validate(validator: TitleValidator::class)] public string $title = ''; - #[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 5, 'maximum' => 80]])] + #[Validate(validator: 'StringLength', options: ['minimum' => 5, 'maximum' => 80])] public string|null $subtitle = null; /** * A short description of the blog */ - #[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 150]])] + #[Validate(validator: 'StringLength', options: ['maximum' => 150])] public string $description = ''; /** @@ -51,7 +51,7 @@ class Blog extends AbstractEntity * @var ?ObjectStorage */ #[Lazy()] - #[Cascade(['value' => 'remove'])] + #[Cascade('remove')] public ?ObjectStorage $posts = null; /** diff --git a/Classes/Domain/Model/Comment.php b/Classes/Domain/Model/Comment.php index 09e09ea..6a48231 100644 --- a/Classes/Domain/Model/Comment.php +++ b/Classes/Domain/Model/Comment.php @@ -26,13 +26,13 @@ class Comment extends AbstractEntity implements \Stringable { protected \DateTime $date; - #[Validate(['validator' => 'NotEmpty'])] + #[Validate(validator: 'NotEmpty')] protected string $author = ''; - #[Validate(['validator' => 'EmailAddress'])] + #[Validate(validator: 'EmailAddress')] protected string $email = ''; - #[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 500]])] + #[Validate(validator: 'StringLength', options: ['maximum' => 500])] protected string $content = ''; protected bool $hidden = true; diff --git a/Classes/Domain/Model/Person.php b/Classes/Domain/Model/Person.php index 55439d5..5e49f46 100644 --- a/Classes/Domain/Model/Person.php +++ b/Classes/Domain/Model/Person.php @@ -27,16 +27,16 @@ */ class Person extends AbstractEntity { - #[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 80]])] + #[Validate(validator: 'StringLength', options: ['maximum' => 80])] protected string $firstname = ''; - #[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 2, 'maximum' => 80]])] + #[Validate(validator: 'StringLength', options: ['minimum' => 2, 'maximum' => 80])] protected string $lastname = ''; #[Transient()] protected string $fullname = ''; - #[Validate(['validator' => 'EmailAddress'])] + #[Validate(validator: 'EmailAddress')] protected string $email = ''; /** diff --git a/Classes/Domain/Model/Post.php b/Classes/Domain/Model/Post.php index d7f1dea..b6c3182 100644 --- a/Classes/Domain/Model/Post.php +++ b/Classes/Domain/Model/Post.php @@ -30,7 +30,7 @@ class Post extends AbstractEntity implements \Stringable { protected ?Blog $blog = null; - #[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 3, 'maximum' => 50]])] + #[Validate(validator: 'StringLength', options: ['minimum' => 3, 'maximum' => 50])] protected string $title = ''; /** @@ -45,13 +45,13 @@ class Post extends AbstractEntity implements \Stringable protected ?Person $secondAuthor = null; protected ?Person $reviewer = null; - #[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 3]])] + #[Validate(validator: 'StringLength', options: ['minimum' => 3])] protected string $content = ''; /** * @var ?ObjectStorage */ - #[Cascade(['value' => 'remove'])] + #[Cascade('remove')] public ?ObjectStorage $tags = null; /** @@ -63,7 +63,7 @@ class Post extends AbstractEntity implements \Stringable * @var ?ObjectStorage */ #[Lazy()] - #[Cascade(['value' => 'remove'])] + #[Cascade('remove')] public ?ObjectStorage $comments = null; /** @@ -75,13 +75,13 @@ class Post extends AbstractEntity implements \Stringable /** * 1:1 optional relation */ - #[Cascade(['value' => 'remove'])] + #[Cascade('remove')] public ?Info $additionalName = null; /** * 1:1 optional relation */ - #[Cascade(['value' => 'remove'])] + #[Cascade('remove')] protected ?Info $additionalInfo = null; /** diff --git a/Classes/Upgrades/MigratePluginsToContentElementsUpgradeWizard.php b/Classes/Upgrades/MigratePluginsToContentElementsUpgradeWizard.php index 529b455..2ae524b 100644 --- a/Classes/Upgrades/MigratePluginsToContentElementsUpgradeWizard.php +++ b/Classes/Upgrades/MigratePluginsToContentElementsUpgradeWizard.php @@ -2,12 +2,12 @@ namespace T3docs\BlogExample\Upgrades; +use TYPO3\CMS\Core\Attribute\UpgradeWizard; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; +use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Install\Attribute\UpgradeWizard; -use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; #[UpgradeWizard('blogExample_migratePluginsToContentElementsUpgradeWizard')] final readonly class MigratePluginsToContentElementsUpgradeWizard implements UpgradeWizardInterface diff --git a/Classes/Upgrades/PluginUpgradeWizard.php b/Classes/Upgrades/PluginUpgradeWizard.php index 85d6c7b..27f2553 100644 --- a/Classes/Upgrades/PluginUpgradeWizard.php +++ b/Classes/Upgrades/PluginUpgradeWizard.php @@ -2,9 +2,9 @@ namespace T3docs\BlogExample\Upgrades; +use TYPO3\CMS\Core\Attribute\UpgradeWizard; use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Install\Attribute\UpgradeWizard; -use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; +use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface; #[UpgradeWizard('blogExample_pluginUpgradeWizard')] final readonly class PluginUpgradeWizard implements UpgradeWizardInterface diff --git a/composer.json b/composer.json index 65a1bcb..ecf795a 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "require-dev": { "ergebnis/composer-normalize": "~2.42.0", "friendsofphp/php-cs-fixer": "^3.52", - "phpstan/phpstan": "^1.10", + "ssch/typo3-rector": "^3.6", + "phpstan/phpstan": "^2.0.3", "phpunit/phpunit": "^11.0.3", "typo3/cms-install": "^14.0 || dev-main", "typo3/testing-framework": "dev-main"