Skip to content

Commit

Permalink
Support TYPO3 v12
Browse files Browse the repository at this point in the history
  • Loading branch information
d-s-codappix committed Sep 16, 2024
1 parent b087098 commit 94ef9d2
Show file tree
Hide file tree
Showing 25 changed files with 428 additions and 446 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ jobs:
strategy:
matrix:
php-version:
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -78,13 +76,42 @@ jobs:
with:
coverage: none
tools: composer:v2
php-version: "8.2"
php-version: "8.3"

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

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

phpstan:
runs-on: ubuntu-latest
needs:
- xml-linting
strategy:
matrix:
include:
- php-version: '8.1'
typo3-version: '^12.4'
- php-version: '8.2'
typo3-version: '^12.4'
- php-version: '8.3'
typo3-version: '^12.4'
steps:
- uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: composer:v2
php-version: "${{ matrix.php-version }}"

- name: Install dependencies
run: composer req "typo3/cms-core:${{ matrix.typo3-version }}" --prefer-dist --no-progress --no-interaction

- name: PHPStan
run: ./vendor/bin/phpstan

tests:
runs-on: ubuntu-latest
Expand All @@ -93,16 +120,12 @@ jobs:
strategy:
matrix:
include:
- php-version: '7.3'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^10.4'
- php-version: '7.4'
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 @@ -114,7 +137,7 @@ jobs:
php-version: "${{ matrix.php-version }}"

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
run: composer req "typo3/cms-core:${{ matrix.typo3-version }}" --prefer-dist --no-progress --no-interaction

- name: PHPUnit Tests
run: ./vendor/bin/phpunit --testdox
63 changes: 63 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

$finder = (new PhpCsFixer\Finder())
->ignoreVCSIgnored(true)
->in(realpath(__DIR__));

return (new \PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'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'],
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'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_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_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_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'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);
47 changes: 31 additions & 16 deletions Classes/Controller/Frontend/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
* 02110-1301, USA.
*/

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use WerkraumMedia\Calendar\Domain\Model\Context;
use WerkraumMedia\Calendar\Domain\Model\ContextSpecificFactory;
use WerkraumMedia\Calendar\Domain\Model\Day;
Expand All @@ -35,7 +37,7 @@
use WerkraumMedia\Calendar\Domain\Model\Year;
use WerkraumMedia\Calendar\Events\AssignTemplateVariables;

class CalendarController extends ActionController
final class CalendarController extends ActionController
{
/**
* @var ForeignDataFactory
Expand All @@ -55,19 +57,19 @@ public function __construct(
$this->typoScriptService = $typoScriptService;
}

public function initializeAction()
public function initializeAction(): void
{
if ($this->foreignDataFactory instanceof ContextSpecificFactory) {
$this->foreignDataFactory->setContext(
Context::createFromContentObjectRenderer($this->configurationManager->getContentObject())
Context::createFromContentObjectRenderer($this->getContentObjectRenderer())
);
}
}

public function initializeYearAction()
public function initializeYearAction(): void
{
if ($this->request->hasArgument('year') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'year' => [
'year' => $this->getDefaultArgumentValue('year'),
],
Expand All @@ -82,17 +84,19 @@ public function initializeYearAction()
/**
* @Extbase\IgnoreValidation("year")
*/
public function yearAction(Year $year)
public function yearAction(Year $year): ResponseInterface
{
$this->assignVariables([
'year' => $year,
]);

return $this->htmlResponse();
}

public function initializeMonthAction()
public function initializeMonthAction(): void
{
if ($this->request->hasArgument('month') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'month' => [
'month' => $this->getDefaultArgumentValue('month'),
'year' => $this->getDefaultArgumentValue('year'),
Expand All @@ -108,17 +112,19 @@ public function initializeMonthAction()
/**
* @Extbase\IgnoreValidation("month")
*/
public function monthAction(Month $month)
public function monthAction(Month $month): ResponseInterface
{
$this->assignVariables([
'month' => $month,
]);

return $this->htmlResponse();
}

public function initializeWeekAction()
public function initializeWeekAction(): void
{
if ($this->request->hasArgument('week') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'week' => [
'week' => $this->getDefaultArgumentValue('week'),
'year' => $this->getDefaultArgumentValue('year'),
Expand All @@ -134,17 +140,19 @@ public function initializeWeekAction()
/**
* @Extbase\IgnoreValidation("week")
*/
public function weekAction(Week $week)
public function weekAction(Week $week): ResponseInterface
{
$this->assignVariables([
'week' => $week,
]);

return $this->htmlResponse();
}

public function initializeDayAction()
public function initializeDayAction(): void
{
if ($this->request->hasArgument('day') === false) {
$this->request->setArguments([
$this->request = $this->request->withArguments([
'day' => [
'day' => $this->getDefaultArgumentValue('day'),
],
Expand All @@ -167,11 +175,13 @@ public function initializeDayAction()
/**
* @Extbase\IgnoreValidation("day")
*/
public function dayAction(Day $day)
public function dayAction(Day $day): ResponseInterface
{
$this->assignVariables([
'day' => $day,
]);

return $this->htmlResponse();
}

private function assignVariables(array $variables): void
Expand Down Expand Up @@ -202,12 +212,17 @@ private function getDefaultArgumentValue(string $argumentName): string
'day' => date('Y-m-d'),
];

$value = $this->configurationManager->getContentObject()->stdWrapValue(
$value = $this->getContentObjectRenderer()->stdWrapValue(
$argumentName,
$arguments,
$fallbackValues[$argumentName]
);

return $value;

Check failure on line 221 in Classes/Controller/Frontend/CalendarController.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3, ^12.4)

Method WerkraumMedia\Calendar\Controller\Frontend\CalendarController::getDefaultArgumentValue() should return string but returns bool|int|string|null.
}

private function getContentObjectRenderer(): ContentObjectRenderer
{
return $this->request->getAttribute('currentContentObject');

Check failure on line 226 in Classes/Controller/Frontend/CalendarController.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3, ^12.4)

Method WerkraumMedia\Calendar\Controller\Frontend\CalendarController::getContentObjectRenderer() should return TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer but returns mixed.
}
}
2 changes: 0 additions & 2 deletions Classes/Domain/Model/Day.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Day
{
Expand All @@ -44,7 +43,6 @@ class Day
public function __construct(
\DateTime $day
) {
$this->periods = new ObjectStorage();
$this->day = \DateTimeImmutable::createFromMutable($day)->modify('midnight');
}

Expand Down
7 changes: 2 additions & 5 deletions Classes/Domain/Model/Month.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
* 02110-1301, USA.
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Month
{
/**
Expand Down Expand Up @@ -77,8 +74,8 @@ public function getWeeks(): array

while ($currentDay <= $lastDay) {
$this->weeks[] = new Week(
(int) $currentDay->format('W'),
(int) $currentDay->format('o')
(int)$currentDay->format('W'),
(int)$currentDay->format('o')
);

$currentDay = $currentDay->modify('+7 days');
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Model/Week.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public function getPreviousWeek(): Week
$newDay = $this->getWeek()->modify('-1 week');

return new self(
(int) $newDay->format('W'),
(int) $newDay->format('o')
(int)$newDay->format('W'),
(int)$newDay->format('o')
);
}

Expand All @@ -89,8 +89,8 @@ public function getNextWeek(): Week
$newDay = $this->getWeek()->modify('+1 week');

return new self(
(int) $newDay->format('W'),
(int) $newDay->format('o')
(int)$newDay->format('W'),
(int)$newDay->format('o')
);
}

Expand Down
5 changes: 1 addition & 4 deletions Classes/Domain/Model/Year.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
* 02110-1301, USA.
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Year
{
/**
Expand Down Expand Up @@ -64,7 +61,7 @@ public function getMonths(): array

while ($currentMonth <= $lastMonth) {
$this->months[] = new Month(
(int) $currentMonth->format('n'),
(int)$currentMonth->format('n'),
$this->year
);

Expand Down
Loading

0 comments on commit 94ef9d2

Please sign in to comment.