Skip to content

Commit

Permalink
[FEATURE] Make ready for v13 (#387)
Browse files Browse the repository at this point in the history
* [FEATURE] Make ready for v13

* Add CI test for v12 and v13

* Remove prophecy for v13

* Use PHP 8.3 for cgl tests

* Remove prophecy from phpstan

* Use DI in constuctors

* Support up to PHP 8.3
  • Loading branch information
sypets authored Oct 27, 2024
1 parent 1d8fea7 commit 6fc0d3b
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 112 deletions.
95 changes: 82 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ on:
push:
pull_request:
schedule:
- cron: '42 5 * * *'
- cron: '42 5 * * 1'

jobs:
all_core_12:
static:
# only run jobs via scheduled workflow in main repo, not in forks
if: (github.event_name == 'schedule' && github.repository == 'sypets/brofix') || (github.event_name != 'schedule')
name: "all core-12"
name: "static"
runs-on: ubuntu-20.04
strategy:
# This prevents cancellation of matrix job runs, if one/two already failed and let the
# rest matrix jobs be be executed anyway.
fail-fast: false
fail-fast: true
matrix:
php: [ '8.1', '8.2' ]
php: [ '8.3' ]
minMax: [ 'composerInstallMax' ]
steps:
- name: "Checkout"
Expand Down Expand Up @@ -50,6 +50,32 @@ jobs:
if: always()
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s composerValidate


all_core_latest:
# only run jobs via scheduled workflow in main repo, not in forks
if: (github.event_name == 'schedule' && github.repository == 'sypets/brofix') || (github.event_name != 'schedule')
name: "all core-latest"
runs-on: ubuntu-20.04
strategy:
# This prevents cancellation of matrix job runs, if one/two already failed and let the
# rest matrix jobs be be executed anyway.
fail-fast: true
matrix:
php: [ '8.2', '8.3' ]
minMax: [ 'composerInstallMax' ]
steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "show php version"
run: php --version

#- name: "Set Typo3 core version"
# run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t "^11.5" -s composerCoreVersion

- name: "Composer"
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s ${{ matrix.minMax }}

- name: "Lint PHP"
if: always()
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s lint
Expand All @@ -58,18 +84,61 @@ jobs:
if: ${{ always() && matrix.minMax == 'composerInstallMax' }}
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s phpstan -e "--error-format=github" -v

# todo: replace prophecy

#- name: "Unit tests"
# if: always()
# run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s unit -v

#- name: "Functional tests with mariadb"
# if: always()
# run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d mariadb -s functional -v

#- name: "Functional tests with sqlite (nightly or pull_request)"
# if: ${{ always() && (github.event_name == 'schedule' || github.event_name == 'pull_request' ) }}
# run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d sqlite -s functional

#- name: "Functional tests with postgres (nightly or pull_request)"
# if: ${{ always() && (github.event_name == 'schedule' || github.event_name == 'pull_request' ) }}
# run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d postgres -s functional

# v12
all_core_v12:
# only run jobs via scheduled workflow in main repo, not in forks
if: (github.event_name == 'schedule' && github.repository == 'sypets/brofix') || (github.event_name != 'schedule')
name: "all core-v12"
runs-on: ubuntu-20.04
strategy:
# This prevents cancellation of matrix job runs, if one/two already failed and let the
# rest matrix jobs be be executed anyway.
fail-fast: true
matrix:
php: [ '8.1', '8.3' ]
minMax: [ 'composerInstallMax' ]
steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "show php version"
run: php --version

- name: "Set Typo3 core version"
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t "^12.4" -s composerCoreVersion

- name: "Add prophecy for unit / functional tests"
run: composer require --dev jangregor/phpstan-prophecy phpspec/prophecy phpspec/prophecy-phpunit

- name: "Composer"
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s ${{ matrix.minMax }}

- name: "phpstan"
if: ${{ always() && matrix.minMax == 'composerInstallMax' }}
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s phpstan -e "--error-format=github" -v

- name: "Unit tests"
if: always()
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s unit -v

- name: "Functional tests with mariadb"
if: always()
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d mariadb -s functional -v

- name: "Functional tests with sqlite (nightly or pull_request)"
if: ${{ always() && (github.event_name == 'schedule' || github.event_name == 'pull_request' ) }}
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d sqlite -s functional

- name: "Functional tests with postgres (nightly or pull_request)"
if: ${{ always() && (github.event_name == 'schedule' || github.event_name == 'pull_request' ) }}
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d postgres -s functional
6 changes: 3 additions & 3 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@


# config
SUPPORTED_PHP_VERSIONS="8.1|8.2|8.3"
DEFAULT_PHP_VERSION="8.1"
SUPPORTED_PHP_VERSIONS="8.1|8.2|8.3|8.4"
DEFAULT_PHP_VERSION="8.3"
PHP_VERSION="${DEFAULT_PHP_VERSION}"
DEFAULT_PHP_PLATFORM_VERSION="8.2.15"
DEFAULT_PHP_PLATFORM_VERSION="8.3.0"


# Function to write a .env file in Build/testing-docker/local
Expand Down
2 changes: 1 addition & 1 deletion Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
# regenerate baseline with: Build/Scripts/runTests.sh -s phpstanGenerateBaseline
#- phpstan-baseline.neon
- ../../.Build/vendor/jangregor/phpstan-prophecy/extension.neon
#- ../../.Build/vendor/jangregor/phpstan-prophecy/extension.neon

parameters:
# Use local cache dir instead of /tmp
Expand Down
30 changes: 13 additions & 17 deletions Classes/Controller/BrokenLinkListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,25 @@ class BrokenLinkListController extends AbstractBrofixController
protected bool $backendUserHasPermissionsForExcludes = false;

public function __construct(
PagesRepository $pagesRepository = null,
BrokenLinkRepository $brokenLinkRepository = null,
ExcludeLinkTarget $excludeLinkTarget = null,
FlashMessageService $flashMessageService = null,
PagesRepository $pagesRepository,
BrokenLinkRepository $brokenLinkRepository,
ExcludeLinkTarget $excludeLinkTarget,
FlashMessageService $flashMessageService,
ModuleTemplateFactory $moduleTemplateFactory,
IconFactory $iconFactory = null,
ExtensionConfiguration $extensionConfiguration = null,
PageRenderer $pageRenderer = null
IconFactory $iconFactory,
ExtensionConfiguration $extensionConfiguration,
PageRenderer $pageRenderer
) {
$this->pageRenderer = $pageRenderer ?: GeneralUtility::makeInstance(PageRenderer::class);
$iconFactory = $iconFactory ?: GeneralUtility::makeInstance(IconFactory::class);
$excludeLinkTarget = $excludeLinkTarget ?: GeneralUtility::makeInstance(ExcludeLinkTarget::class);
$this->pageRenderer = $pageRenderer;
$iconFactory = $iconFactory;
$excludeLinkTarget = $excludeLinkTarget;
$moduleTemplateFactory = $moduleTemplateFactory;
$this->brokenLinkRepository = $brokenLinkRepository ?: GeneralUtility::makeInstance(BrokenLinkRepository::class);
$this->pagesRepository = $pagesRepository ?: GeneralUtility::makeInstance(PagesRepository::class);
$flashMessageService = $flashMessageService ?: GeneralUtility::makeInstance(FlashMessageService::class);
$this->brokenLinkRepository = $brokenLinkRepository;
$this->pagesRepository = $pagesRepository;

$this->defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$this->orderBy = BrokenLinkListController::DEFAULT_ORDER_BY;

// configuration / extension configuration
if (!$extensionConfiguration) {
$extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class);
}
$extConfArray = $extensionConfiguration->get('brofix') ?: [];
$configuration = GeneralUtility::makeInstance(Configuration::class, $extConfArray);

Expand Down
33 changes: 16 additions & 17 deletions Classes/Controller/ManageExclusionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,26 @@ class ManageExclusionsController extends AbstractBrofixController
protected bool $backendUserHasPermissions = false;

public function __construct(
ExcludeLinkTargetRepository $excludeLinkTargetRepository = null,
ManageExclusionsFilter $filter = null,
ExtensionConfiguration $extensionConfiguration = null,
ExcludeLinkTargetRepository $excludeLinkTargetRepository,
ManageExclusionsFilter $filter,
ExtensionConfiguration $extensionConfiguration,
ModuleTemplateFactory $moduleTemplateFactory,
IconFactory $iconFactory = null,
ExcludeLinkTarget $excludeLinkTarget = null,
CharsetConverter $charsetConverter = null,
LocalizationUtility $localizationUtility = null,
PageRenderer $pageRenderer = null
IconFactory $iconFactory,
ExcludeLinkTarget $excludeLinkTarget,
CharsetConverter $charsetConverter,
LocalizationUtility $localizationUtility,
PageRenderer $pageRenderer
) {
$this->pageRenderer = $pageRenderer ?: GeneralUtility::makeInstance(PageRenderer::class);
$iconFactory = $iconFactory ?: GeneralUtility::makeInstance(IconFactory::class);
$this->pageRenderer = $pageRenderer;
$iconFactory = $iconFactory;
$moduleTemplateFactory = $moduleTemplateFactory;
$excludeLinkTarget = $excludeLinkTarget ?: GeneralUtility::makeInstance(ExcludeLinkTarget::class);
$this->excludeLinkTargetRepository = $excludeLinkTargetRepository ?: GeneralUtility::makeInstance(ExcludeLinkTargetRepository::class);
$this->filter = $filter ?: GeneralUtility::makeInstance(ManageExclusionsFilter::class);
$this->charsetConverter = $charsetConverter ?? GeneralUtility::makeInstance(CharsetConverter::class);
$this->localizationUtility = $localizationUtility ?? GeneralUtility::makeInstance(LocalizationUtility::class);
$this->orderBy = ManageExclusionsController::ORDER_BY_DEFAULT;
$excludeLinkTarget = $excludeLinkTarget;
$this->excludeLinkTargetRepository = $excludeLinkTargetRepository;
$this->filter = $filter;
$this->charsetConverter = $charsetConverter;
$this->localizationUtility = $localizationUtility;

$extensionConfiguration = $extensionConfiguration ?: GeneralUtility::makeInstance(ExtensionConfiguration::class);
$this->orderBy = ManageExclusionsController::ORDER_BY_DEFAULT;
$extConfArray = $extensionConfiguration->get('brofix') ?: [];
$configuration = GeneralUtility::makeInstance(Configuration::class, $extConfArray);

Expand Down
15 changes: 1 addition & 14 deletions Classes/Exceptions/MissingConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,9 @@
declare(strict_types=1);
namespace Sypets\Brofix\Exceptions;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

class MissingConfigurationException extends \Exception
{
public function __construct(string $message = '', int $code = 0, \Throwable $previous = null)
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
{
if ($message === '') {
$message = 'Missing configuration';
Expand Down
4 changes: 2 additions & 2 deletions Classes/Linktype/AbstractLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public function getBrokenUrl(array $row): string
* Text to be displayed with the Link as anchor text
* (not the real anchor text of the Link.
* @param mixed[] $row
* @param mixed[] $additionalConfig
* @param array<mixed>|null $additionalConfig
* @return string
*/
public function getBrokenLinkText(array $row, array $additionalConfig = null): string
public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string
{
return $row['url'];
}
Expand Down
8 changes: 4 additions & 4 deletions Classes/Linktype/ExternalLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class ExternalLinktype extends AbstractLinktype implements LoggerAwareInterface
protected $crawlDelay;

public function __construct(
RequestFactory $requestFactory = null,
ExcludeLinkTarget $excludeLinkTarget = null,
LinkTargetCacheInterface $linkTargetCache = null,
CrawlDelay $crawlDelay = null
?RequestFactory $requestFactory = null,
?ExcludeLinkTarget $excludeLinkTarget = null,
?LinkTargetCacheInterface $linkTargetCache = null,
?CrawlDelay $crawlDelay = null
) {
$this->requestFactory = $requestFactory ?: GeneralUtility::makeInstance(RequestFactory::class);
$this->excludeLinkTarget = $excludeLinkTarget ?: GeneralUtility::makeInstance(ExcludeLinkTarget::class);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Linktype/FileLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public function getBrokenUrl(array $row): string
* Text to be displayed with the Link as anchor text
* (not the real anchor text of the Link.
* @param mixed[] $row
* @param mixed[] $additionalConfig
* @param array<mixed>|null $additionalConfig
* @return string
*/
public function getBrokenLinkText(array $row, array $additionalConfig = null): string
public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string
{
return $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.url.file');
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/Linktype/InternalLinktype.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,10 @@ public function getBrokenUrl(array $row): string
* Text to be displayed with the Link as anchor text
* (not the real anchor text of the Link.
* @param mixed[] $row
* @param array<mixed>|null $additionalConfig
* @return string
*/
public function getBrokenLinkText(array $row, array $additionalConfig = null): string
public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string
{
$pageTitle = $additionalConfig['page']['title'] ?? '';
$contentTitle = $additionalConfig['content']['title'] ?? '';
Expand Down
15 changes: 1 addition & 14 deletions Classes/Linktype/LinktypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
declare(strict_types=1);
namespace Sypets\Brofix\Linktype;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use Sypets\Brofix\CheckLinks\LinkTargetResponse\LinkTargetResponse;
use Sypets\Brofix\Configuration\Configuration;

Expand Down Expand Up @@ -70,5 +57,5 @@ public function getBrokenUrl(array $row): string;
* @param mixed[] $additionalConfig
* @return string
*/
public function getBrokenLinkText(array $row, array $additionalConfig = null): string;
public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string;
}
20 changes: 4 additions & 16 deletions Classes/Mail/GenerateCheckResultFluidMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
declare(strict_types=1);
namespace Sypets\Brofix\Mail;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\SentMessage;
use Symfony\Component\Mime\Address;
Expand All @@ -24,13 +11,14 @@
use Sypets\Brofix\Exceptions\MissingConfigurationException;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\TemplatePaths;

/**
* Send mail with Fluid
*/
class GenerateCheckResultFluidMail
class GenerateCheckResultFluidMail implements SingletonInterface
{
/**
* @var Mailer
Expand All @@ -42,9 +30,9 @@ class GenerateCheckResultFluidMail
*/
protected $messageId;

public function __construct(Mailer $mailer = null)
public function __construct(Mailer $mailer)
{
$this->mailer = $mailer ?: GeneralUtility::makeInstance(Mailer::class);
$this->mailer = $mailer;
}

public function getMessageId(): string
Expand Down
Loading

0 comments on commit 6fc0d3b

Please sign in to comment.