Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
feat: PHP 8.2 support (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilindsay authored May 15, 2024
1 parent a3d76b0 commit 3e825f6
Show file tree
Hide file tree
Showing 78 changed files with 941 additions and 1,011 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
static-analysis:
uses: dvsa/.github/.github/workflows/php-static.yml@main
with:
php-version: '8.0'
php-version: '8.2'

tests:
uses: dvsa/.github/.github/workflows/php-tests.yml@main
with:
php-versions: '["8.0"]'
php-versions: '["8.2"]'
fail-fast: false
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/dvsa/laminas-form.git"
}],
"require": {
"php": "~8.0.0",
"php": "~8.2.0",
"ext-redis": "*",
"doctrine/annotations": "^1.14.2",
"doctrine/doctrine-module": "^5",
Expand Down
1,551 changes: 695 additions & 856 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions module/Application/src/Form/AddVehiclesQuestionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* @see AddVehiclesQuestionFormTest
* @template TFilteredValues
* @extends Form<TFilteredValues>
*/
class AddVehiclesQuestionForm extends Form implements InputFilterAwareInterface, FormWithCsrfInterface
{
Expand Down
2 changes: 1 addition & 1 deletion module/Application/src/View/Model/ApplicationOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct($data, array $sections = [], $submissionForm = null)
{
$this->setVariable('applicationId', $data['id']);
$this->setVariable('licNo', $data['licence']['licNo'] ?? '');
$this->setVariable('createdOn', date('d F Y', strtotime($data['createdOn'])));
$this->setVariable('createdOn', date('d F Y', strtotime((string) $data['createdOn'])));
$this->setVariable('status', $data['status']['id']);
$this->setVariable('submissionForm', $submissionForm);
$this->setVariable('receivedDate', $data['receivedDate']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ApplicationOverviewSection extends LvaOverviewSection
public function __construct($ref, $data, $sectionDetails)
{
$filter = new \Laminas\Filter\Word\DashToCamelCase();
$index = lcfirst($filter->filter(str_replace('_', '-', $ref)));
$index = lcfirst((string) $filter->filter(str_replace('_', '-', $ref)));

$status = $data['applicationCompletion'][$index . 'Status'] ?? null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function indexActionIsCallable(): void
$this->setUpSut();

// Assert
$this->assertIsCallable([$this->sut, 'indexAction']);
$this->assertIsCallable($this->sut->indexAction(...));
}

/**
Expand Down Expand Up @@ -1162,7 +1162,6 @@ protected function setUpSut(): void
}

/**
* @param ServiceManager $serviceManager
* @return ServiceManager
*/
protected function setUpDefaultServices(ServiceManager $serviceManager): ServiceManager|array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function isInitializedIsCallable(): void
$this->setUpSut();

// Assert
$this->assertIsCallable([$this->sut, 'isInitialized']);
$this->assertIsCallable($this->sut->isInitialized(...));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion module/Olcs/src/Controller/AbstractSelfserveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function onDispatch(MvcEvent $e)
$this->routeParams = $params->fromRoute() ?: [];
$this->postParams = $params->fromPost() ?: [];
$this->queryParams = $params->fromQuery() ?: [];
$this->action = strtolower($e->getRouteMatch()->getParam('action'));
$this->action = strtolower((string) $e->getRouteMatch()->getParam('action'));

/** @todo find a better place for these */
$this->retrieveData();
Expand Down
8 changes: 4 additions & 4 deletions module/Olcs/src/Controller/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class LoginController
* LoginController constructor.
*/
public function __construct(
private ValidatableAdapterInterface $authenticationAdapter,
private readonly ValidatableAdapterInterface $authenticationAdapter,
AuthenticationServiceInterface $authenticationService,
private CurrentUser $currentUser,
private FlashMessenger $flashMessenger,
private readonly CurrentUser $currentUser,
private readonly FlashMessenger $flashMessenger,
FormHelperService $formHelper,
Redirect $redirectHelper,
private AuthChallengeContainer $authChallengeContainer
private readonly AuthChallengeContainer $authChallengeContainer
) {
$this->authenticationService = $authenticationService;
$this->formHelper = $formHelper;
Expand Down
10 changes: 5 additions & 5 deletions module/Olcs/src/Controller/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ private function mapFormDataToCommand(\Laminas\Form\Form $form): Create
'correlationId' => $data['correlationId'],
];

$appOrLicNoPrefix = substr($data['form-actions']['inputs']['appOrLicNo'], 0, 1);
$appOrLicNoSuffix = substr($data['form-actions']['inputs']['appOrLicNo'], 1);
$appOrLicNoPrefix = substr((string) $data['form-actions']['inputs']['appOrLicNo'], 0, 1);
$appOrLicNoSuffix = substr((string) $data['form-actions']['inputs']['appOrLicNo'], 1);
switch ($appOrLicNoPrefix) {
case MessagingAppOrLicNo::PREFIX_LICENCE:
$processedData['licence'] = $appOrLicNoSuffix;
Expand Down Expand Up @@ -247,9 +247,9 @@ protected function parseReply(ViewModel $view, Form $form)
$hasProcessedFiles = $this->processFiles(
$form,
'form-actions->file',
[$this, 'processFileUpload'],
[$this, 'deleteFile'],
[$this, 'getUploadedFiles'],
$this->processFileUpload(...),
$this->deleteFile(...),
$this->getUploadedFiles(...),
'form-actions->file->fileCount',
);

Expand Down
2 changes: 1 addition & 1 deletion module/Olcs/src/Controller/Cookie/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SettingsController extends AbstractOlcsController
*
* @return SettingsController
*/
public function __construct(private CurrentPreferencesProvider $currentPreferencesProvider, private SetCookieArrayGenerator $setCookieArrayGenerator, private PreferencesFactory $preferencesFactory)
public function __construct(private readonly CurrentPreferencesProvider $currentPreferencesProvider, private readonly SetCookieArrayGenerator $setCookieArrayGenerator, private readonly PreferencesFactory $preferencesFactory)
{
}

Expand Down
6 changes: 3 additions & 3 deletions module/Olcs/src/Controller/Ebsr/UploadsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function uploadAction()
$hasProcessedFiles = $this->processFiles(
$form,
'fields->files',
[$this, 'processEbsrFileUpload'],
[$this, 'deleteFile'],
[$this, 'getUploadedPacks'],
$this->processEbsrFileUpload(...),
$this->deleteFile(...),
$this->getUploadedPacks(...),
'fields->uploadedFileCount'
);

Expand Down
6 changes: 3 additions & 3 deletions module/Olcs/src/Controller/FeesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function payFeesAction()
$this->getRequest()->getPost('storedCards')['card'] :
false;

$feeIds = explode(',', $this->params('fee'));
$feeIds = explode(',', (string) $this->params('fee'));
return $this->payOutstandingFees($feeIds, $storedCardReference);
}

Expand Down Expand Up @@ -256,7 +256,7 @@ protected function getFeesFromParams(): array
$outstandingFees = $this->getOutstandingFeesForOrganisation($organisationId);

if (!empty($outstandingFees)) {
$ids = explode(',', $this->params('fee'));
$ids = explode(',', (string) $this->params('fee'));
foreach ($outstandingFees as $fee) {
if (in_array($fee['id'], $ids)) {
$fees[] = $fee;
Expand Down Expand Up @@ -375,7 +375,7 @@ public function lateFeeAction()
}
$result = $response->getResult();
$view = new ViewModel(
['licenceExpiryDate' => date('d F Y', strtotime($result['licenceExpiryDate']))]
['licenceExpiryDate' => date('d F Y', strtotime((string) $result['licenceExpiryDate']))]
);
$view->setTemplate('pages/fees/late');
return $this->render($view);
Expand Down
6 changes: 3 additions & 3 deletions module/Olcs/src/Controller/GdsVerifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ protected function whitelistUserVerifyRequest(string $verifyId): void
private function validateRedisSamlResponseReferenceKey($key): bool
{
// Essentially, we verify the reference key is a SHA1.
return (bool)preg_match('/^[0-9a-f]{40}$/i', $key);
return (bool)preg_match('/^[0-9a-f]{40}$/i', (string) $key);
}

/**
Expand Down Expand Up @@ -401,7 +401,7 @@ private function retrieveSAMLResponseFromRequest(): string
}

if (!$this->isFromVerify()) {
return urldecode($samlResponse);
return urldecode((string) $samlResponse);
}

return $samlResponse;
Expand All @@ -416,7 +416,7 @@ private function isFromVerify(): bool
{
$verifyReferer = 'signin.service.gov.uk';
$referer = $_SERVER['HTTP_REFERER'];
$refererHost = parse_url($referer, PHP_URL_HOST);
$refererHost = parse_url((string) $referer, PHP_URL_HOST);
$trimmedHost = implode('.', array_slice(explode('.', $refererHost), -4, 4));

return $trimmedHost === $verifyReferer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function indexAction()
private function getSignatureFullName(): string
{
$names = [];
$attributes = json_decode($this->data['surrender']["digitalSignature"]["attributes"]);
$attributes = json_decode((string) $this->data['surrender']["digitalSignature"]["attributes"]);
$names[] = $attributes->firstname ?? '';
$names[] = $attributes->surname ?? '';

Expand All @@ -51,7 +51,7 @@ private function getSignatureFullName(): string

private function getSignatureDate(): string
{
$unixTimeStamp = strtotime($this->data['surrender']["digitalSignature"]['createdOn']);
$unixTimeStamp = strtotime((string) $this->data['surrender']["digitalSignature"]['createdOn']);
return date("j M Y", $unixTimeStamp);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SwitchBoardController
public const PANEL_FLASH_MESSENGER_NAMESPACE = 'panel';
protected const FLASH_MESSAGE_INPUT_NAMESPACE = 'switchboard-input';

public function __construct(private FlashMessenger $flashMessenger, private FormHelperService $formHelper, private HandleQuery $queryHandler, private Redirect $redirectHelper, private ResponseHelperService $responseHelper, private LicenceVehicleManagement $session, private Url $urlHelper, private FormValidator $formValidator)
public function __construct(private readonly FlashMessenger $flashMessenger, private readonly FormHelperService $formHelper, private readonly HandleQuery $queryHandler, private readonly Redirect $redirectHelper, private readonly ResponseHelperService $responseHelper, private readonly LicenceVehicleManagement $session, private readonly Url $urlHelper, private readonly FormValidator $formValidator)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected function transferVehicles(int $currentLicenceId, array $vehicleIds, Li
}
if (isset($errors['LIC_TRAN_2']) || isset($errors['LIC_TRAN_3'])) {
$invalidVehiclesJson = $errors['LIC_TRAN_2'] ?? $errors['LIC_TRAN_3'];
$invalidVehicleVrms = json_decode($invalidVehiclesJson, true);
$invalidVehicleVrms = json_decode((string) $invalidVehiclesJson, true);
throw new LicenceAlreadyAssignedVehicleException(
$destinationLicence->getId(),
$destinationLicence->getLicenceNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@ protected function page1Point1(array $transportManagerApplicationData)
$hasProcessedCertificateFiles = $this->processFiles(
$form,
'details->certificate',
[$this, 'processCertificateUpload'],
[$this, 'deleteFile'],
[$this, 'getCertificates']
$this->processCertificateUpload(...),
$this->deleteFile(...),
$this->getCertificates(...)
);

$hasProcessedResponsibilitiesFiles = $this->processFiles(
$form,
'responsibilities->file',
[$this, 'processResponsibilityFileUpload'],
[$this, 'deleteFile'],
[$this, 'getResponsibilityFiles']
$this->processResponsibilityFileUpload(...),
$this->deleteFile(...),
$this->getResponsibilityFiles(...)
);

$hasProcessedFiles = ($hasProcessedCertificateFiles || $hasProcessedResponsibilitiesFiles);
Expand Down Expand Up @@ -470,7 +470,7 @@ public function genericDelete($type = null)
$request = $this->getRequest();

if ($request->isPost()) {
$ids = explode(',', $this->params('grand_child_id'));
$ids = explode(',', (string) $this->params('grand_child_id'));

$commandClass = $this->deleteCommandMap[$type];
$command = $this->transferAnnotationBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ private function getForm()
$this->processFiles(
$form,
'financialEvidence->files',
[$this, 'financialEvidenceProcessFileUpload'],
[$this, 'deleteFile'],
[$this, 'financialEvidenceLoadFileUpload']
$this->financialEvidenceProcessFileUpload(...),
$this->deleteFile(...),
$this->financialEvidenceLoadFileUpload(...)
);
} else {
$form->remove('financialEvidence');
Expand All @@ -136,9 +136,9 @@ private function getForm()
$this->processFiles(
$form,
'operatingCentres->' . (string)$i . '->file',
[$this, 'operatingCentreProcessFileUpload'],
[$this, 'deleteFile'],
[$this, 'operatingCentreLoadFileUpload']
$this->operatingCentreProcessFileUpload(...),
$this->deleteFile(...),
$this->operatingCentreLoadFileUpload(...)
);
}
} elseif ($form->has('operatingCentres')) {
Expand All @@ -149,9 +149,9 @@ private function getForm()
$this->processFiles(
$form,
'supportingEvidence->files',
[$this, 'supportingEvidenceProcessFileUpload'],
[$this, 'deleteFile'],
[$this, 'supportingEvidenceLoadFileUpload']
$this->supportingEvidenceProcessFileUpload(...),
$this->deleteFile(...),
$this->supportingEvidenceLoadFileUpload(...)
);
} elseif ($form->has('supportingEvidence')) {
$form->remove('supportingEvidence');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
TransferAnnotationBuilder $transferAnnotationBuilder,
CachingQueryService $querySrv,
CommandService $commandSrv,
private VariationLvaService $lvaVariationSrv,
private readonly VariationLvaService $lvaVariationSrv,
ContainerInterface $container
) {
parent::__construct($transferAnnotationBuilder, $querySrv, $commandSrv, $container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ private function isOperatorUserOrAdmin(): bool

private function getSignatureDate($signature): string
{
$unixTimeStamp = strtotime($signature['createdOn']);
$unixTimeStamp = strtotime((string) $signature['createdOn']);
return date("j M Y", $unixTimeStamp);
}

private function getSignatureFullName($signature): string
{
$attributes = json_decode($signature['attributes']);
$attributes = json_decode((string) $signature['attributes']);
return $attributes->firstname . ' ' . $attributes->surname;
}

Expand Down
9 changes: 2 additions & 7 deletions module/Olcs/src/Controller/Search/SearchController.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php

/**
* Search Controller
*/

namespace Olcs\Controller\Search;

use Common\Controller\Lva\AbstractController;
Expand All @@ -24,15 +20,14 @@
use Olcs\Form\Model\Form\SimpleSearch;
use LmcRbacMvc\Service\AuthorizationService;

/**
* Search Controller
*/
class SearchController extends AbstractController
{
use ViewHelperManagerAware;

protected $viewHelperManager;

public $navigationId;

/**
* @param NiTextTranslation $niTextTranslationUtil
* @param AuthorizationService $authService
Expand Down
2 changes: 1 addition & 1 deletion module/Olcs/src/Controller/SessionTimeoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SessionTimeoutController
/**
* SessionTimeoutController constructor.
*/
public function __construct(private IdentityProviderInterface $identityProvider, protected Redirect $redirectHelper)
public function __construct(private readonly IdentityProviderInterface $identityProvider, protected Redirect $redirectHelper)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function setAdPlacedLabels(Form $form, $isNi, $isVariation)
$templateUrl = $this->getUrl()->fromRoute(
'getfile',
[
'identifier' => base64_encode($templateIdentifier)
'identifier' => base64_encode((string) $templateIdentifier)
],
[
'query' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function alterForm(Form $form, array $params)
}

foreach ($this->lockElements as $lockElementRef) {
$lockElementRefComponents = explode('->', $lockElementRef);
$lockElementRefComponents = explode('->', (string) $lockElementRef);
$lockElement = $dataElement;
foreach ($lockElementRefComponents as $elementRef) {
if (null === $lockElement) {
Expand Down
2 changes: 1 addition & 1 deletion module/Olcs/src/Mvc/Controller/Plugin/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class Placeholder extends AbstractPlugin
{
public function __construct(private ViewPlaceholder $placeholder)
public function __construct(private readonly ViewPlaceholder $placeholder)
{
}

Expand Down
Loading

0 comments on commit 3e825f6

Please sign in to comment.