Skip to content

Commit

Permalink
Support TYPO3 v12 and PHP 8.3
Browse files Browse the repository at this point in the history
Use rector, PHPUnit, Codeception and PHPStan to find and fix issues.
  • Loading branch information
DanielSiepmann committed Dec 4, 2023
1 parent 8a2c543 commit 7a046f0
Show file tree
Hide file tree
Showing 201 changed files with 4,380 additions and 3,662 deletions.
14 changes: 6 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Tests export-ignore
shell.nix export-ignore

.github export-ignore
codeception.dist.yml export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore

ecs.php export-ignore
phpstan.neon export-ignore
.php-cs-fixer.dist.php export-ignore
phpstan-baseline.neon export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
codeception.dist.yml export-ignore
shell.nix export-ignore
Tests export-ignore
62 changes: 33 additions & 29 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -41,7 +40,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: "8.2"
tools: composer:v2

- name: Install xmllint
Expand Down Expand Up @@ -70,14 +69,14 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: "8.2"
tools: composer:v2

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Coding Guideline
run: ./vendor/bin/ecs check
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff

code-quality:
runs-on: ubuntu-latest
Expand All @@ -86,16 +85,12 @@ jobs:
strategy:
matrix:
include:
- php-version: '7.4'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^11.5'
- php-version: '8.0'
typo3-version: '^11.5'
- php-version: '8.1'
typo3-version: '^11.5'
typo3-version: '^12.4'
- php-version: '8.2'
typo3-version: '^11.5'
typo3-version: '^12.4'
- php-version: '8.3'
typo3-version: '^12.4'
steps:
- uses: actions/checkout@v3

Expand All @@ -121,23 +116,14 @@ jobs:
strategy:
matrix:
include:
- php-version: '7.4'
typo3-version: '^10.4'
db-version: '5.6'
- php-version: '7.4'
typo3-version: '^10.4'
db-version: '8'
- php-version: '7.4'
typo3-version: '^11.5'
db-version: '8'
- php-version: '8.0'
typo3-version: '^11.5'
db-version: '8'
- php-version: '8.1'
typo3-version: '^11.5'
typo3-version: '^12.4'
db-version: '8'
- php-version: '8.2'
typo3-version: '^11.5'
typo3-version: '^12.4'
db-version: '8'
- php-version: '8.3'
typo3-version: '^12.4'
db-version: '8'
steps:
- uses: actions/checkout@v3
Expand All @@ -151,10 +137,16 @@ jobs:
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
mysql version: '5.7'
mysql version: "${{ matrix.db-version }}"
mysql database: 'typo3'
mysql root password: 'root'

- name: Wait for MySQL
run: |
while ! mysqladmin ping --host=127.0.0.1 --password=root --silent; do
sleep 1
done
- name: Install dependencies
run: composer require --no-interaction --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}" "typo3/cms-fluid-styled-content:${{ matrix.typo3-version }}"

Expand All @@ -165,4 +157,16 @@ jobs:
export typo3DatabaseHost="127.0.0.1"
export typo3DatabaseUsername="root"
export typo3DatabasePassword="root"
./vendor/bin/phpunit --testdox
./vendor/bin/phpunit
tests-acceptance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: cachix/install-nix-action@v24
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Run Acceptance Tests
run: nix-shell --run project-test-acceptance
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.Build/
/.phpunit.cache
/composer.lock
/vendor/
73 changes: 73 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
$finder = (new PhpCsFixer\Finder())
->ignoreVCSIgnored(true)
->in(realpath(__DIR__))
;

return (new \PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'attribute_empty_parentheses' => true,
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_strict_types' => true,
'dir_constant' => true,
'fully_qualified_strict_types' => false,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_import_alias' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => ['order' => ['test', 'dataProvider', 'param', 'throws', 'return']],
'phpdoc_scalar' => true,
'phpdoc_separation' => ['groups' => [['Extbase\\*']]],
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_quote' => true,
'single_trait_insert_per_statement' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
])
->setFinder($finder)
;
17 changes: 2 additions & 15 deletions Classes/Command/ImportConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,11 @@

class ImportConfigurationCommand extends Command
{
/**
* @var ImportConfigurationRepository
*/
private $importConfigurationRepository;

/**
* @var Importer
*/
private $importer;

public function __construct(
ImportConfigurationRepository $importConfigurationRepository,
Importer $importer
private readonly ImportConfigurationRepository $importConfigurationRepository,
private readonly Importer $importer
) {
parent::__construct();

$this->importConfigurationRepository = $importConfigurationRepository;
$this->importer = $importer;
}

protected function configure(): void
Expand Down
36 changes: 22 additions & 14 deletions Classes/Controller/Backend/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,30 @@

namespace WerkraumMedia\ThueCat\Controller\Backend;

use TYPO3\CMS\Backend\View\BackendTemplateView;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

abstract class AbstractController extends ActionController
{
/**
* BackendTemplateContainer
*
* @var BackendTemplateView
*/
protected $view;

/**
* Backend Template Container
*
* @var string
*/
protected $defaultViewObjectName = BackendTemplateView::class;
private ModuleTemplateFactory $moduleTemplateFactory;

protected ModuleTemplate $moduleTemplate;

public function injectModuleTemplateFactory(ModuleTemplateFactory $moduleTemplateFactory): void
{
$this->moduleTemplateFactory = $moduleTemplateFactory;
}

protected function initializeView(): void
{
$this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);
$this->moduleTemplate->assign('settings', $this->settings);
}

protected function htmlResponse(?string $html = null): ResponseInterface
{
return parent::htmlResponse($html ?? $this->moduleTemplate->render());
}
}
23 changes: 7 additions & 16 deletions Classes/Controller/Backend/ConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,25 @@

namespace WerkraumMedia\ThueCat\Controller\Backend;

use Psr\Http\Message\ResponseInterface;
use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportConfigurationRepository;
use WerkraumMedia\ThueCat\Domain\Repository\Backend\OrganisationRepository;

class ConfigurationController extends AbstractController
{
/**
* @var OrganisationRepository
*/
private $organisationRepository;

/**
* @var ImportConfigurationRepository
*/
private $importConfigurationRepository;

public function __construct(
OrganisationRepository $organisationRepository,
ImportConfigurationRepository $importConfigurationRepository
private readonly OrganisationRepository $organisationRepository,
private readonly ImportConfigurationRepository $importConfigurationRepository
) {
$this->organisationRepository = $organisationRepository;
$this->importConfigurationRepository = $importConfigurationRepository;
}

public function indexAction(): void
public function indexAction(): ResponseInterface
{
$this->view->assignMultiple([
$this->moduleTemplate->assignMultiple([
'importConfigurations' => $this->importConfigurationRepository->findAll(),
'organisations' => $this->organisationRepository->findAll(),
]);

return $this->htmlResponse();
}
}
Loading

0 comments on commit 7a046f0

Please sign in to comment.