test: adjust PHP code to support v8.4

The implicite nullable type has been deprecated.
This fixes it by explicitely typing every nullable type.
PHP is also bumped in composer and drone to v8.4.
This commit is contained in:
Lukas Hirt
2025-06-24 11:39:50 +02:00
parent 9031871ec0
commit b933f48b68
20 changed files with 65 additions and 50 deletions

View File

@@ -40,7 +40,7 @@ SONARSOURCE_SONAR_SCANNER_CLI = "sonarsource/sonar-scanner-cli:11.0"
KEYCLOAK_IMAGE = "quay.io/keycloak/keycloak:26.2.5" KEYCLOAK_IMAGE = "quay.io/keycloak/keycloak:26.2.5"
POSTGRES_ALPINE_IMAGE = "postgres:alpine3.18" POSTGRES_ALPINE_IMAGE = "postgres:alpine3.18"
DEFAULT_PHP_VERSION = "8.2" DEFAULT_PHP_VERSION = "8.4"
DEFAULT_NODEJS_VERSION = "22" DEFAULT_NODEJS_VERSION = "22"
dirs = { dirs = {
@@ -1010,6 +1010,9 @@ def codestyle(ctx):
{ {
"name": "php-style", "name": "php-style",
"image": OC_CI_PHP % phpVersion, "image": OC_CI_PHP % phpVersion,
"environment": {
"PHP_CS_FIXER_IGNORE_ENV": "true",
},
"commands": [ "commands": [
"make test-php-style", "make test-php-style",
], ],

View File

@@ -2,7 +2,7 @@
"name": "owncloud/ocis", "name": "owncloud/ocis",
"config": { "config": {
"platform": { "platform": {
"php": "8.2" "php": "8.4"
}, },
"vendor-dir": "./vendor-php", "vendor-dir": "./vendor-php",
"allow-plugins": { "allow-plugins": {

View File

@@ -99,7 +99,7 @@ class SharingHelper {
$shareType, $shareType,
?string $shareWith = null, ?string $shareWith = null,
?bool $publicUpload = false, ?bool $publicUpload = false,
string $sharePassword = null, ?string $sharePassword = null,
$permissions = null, $permissions = null,
?string $linkName = null, ?string $linkName = null,
?string $expireDate = null, ?string $expireDate = null,

View File

@@ -719,7 +719,7 @@ class CliContext implements Context {
* @return array * @return array
*/ */
protected function getTrashedResourceFromCliCommandResponse( protected function getTrashedResourceFromCliCommandResponse(
ResponseInterface $response = null, ?ResponseInterface $response = null,
): array { ): array {
$responseArray = $this->featureContext->getJsonDecodedResponseBodyContent($response); $responseArray = $this->featureContext->getJsonDecodedResponseBodyContent($response);
$lines = explode("\n", $responseArray->message); $lines = explode("\n", $responseArray->message);

View File

@@ -91,7 +91,7 @@ class CollaborationContext implements Context {
string $file, string $file,
string $space, string $space,
string $app, string $app,
string $viewMode = null, ?string $viewMode = null,
): void { ): void {
$fileId = $this->spacesContext->getFileId($user, $space, $file); $fileId = $this->spacesContext->getFileId($user, $space, $file);
$response = \json_decode( $response = \json_decode(

View File

@@ -43,7 +43,7 @@ class FavoritesContext implements Context {
* *
* @return ResponseInterface * @return ResponseInterface
*/ */
public function userFavoritesElement(string $user, string $path, string $spaceId = null): ResponseInterface { public function userFavoritesElement(string $user, string $path, ?string $spaceId = null): ResponseInterface {
return $this->changeFavStateOfAnElement( return $this->changeFavStateOfAnElement(
$user, $user,
$path, $path,
@@ -179,7 +179,7 @@ class FavoritesContext implements Context {
string $user, string $user,
string $path, string $path,
int $expectedValue = 1, int $expectedValue = 1,
string $spaceId = null, ?string $spaceId = null,
): void { ): void {
$property = "oc:favorite"; $property = "oc:favorite";
$this->webDavPropertiesContext->checkPropertyOfAFolder( $this->webDavPropertiesContext->checkPropertyOfAFolder(

View File

@@ -1583,7 +1583,7 @@ class FeatureContext extends BehatVariablesContext {
* *
* @return mixed * @return mixed
*/ */
public function getJsonDecodedResponseBodyContent(ResponseInterface $response = null): mixed { public function getJsonDecodedResponseBodyContent(?ResponseInterface $response = null): mixed {
$response = $response ?? $this->response; $response = $response ?? $this->response;
$response->getBody()->rewind(); $response->getBody()->rewind();
return HttpRequestHelper::getJsonDecodedResponseBodyContent($response); return HttpRequestHelper::getJsonDecodedResponseBodyContent($response);

View File

@@ -205,10 +205,10 @@ class GraphContext implements Context {
public function editUserUsingTheGraphApi( public function editUserUsingTheGraphApi(
string $byUser, string $byUser,
string $user, string $user,
string $userName = null, ?string $userName = null,
string $password = null, ?string $password = null,
string $email = null, ?string $email = null,
string $displayName = null, ?string $displayName = null,
bool $accountEnabled = true, bool $accountEnabled = true,
string $method = "PATCH", string $method = "PATCH",
): ResponseInterface { ): ResponseInterface {
@@ -2342,7 +2342,7 @@ class GraphContext implements Context {
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch( public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(
string $eventType, string $eventType,
?string $spaceType = null, ?string $spaceType = null,
PyStringNode $schemaString = null, ?PyStringNode $schemaString = null,
): void { ): void {
$actualResponseToAssert = null; $actualResponseToAssert = null;
$events = $this->featureContext->getJsonDecodedResponseBodyContent()->events; $events = $this->featureContext->getJsonDecodedResponseBodyContent()->events;

View File

@@ -73,13 +73,17 @@ class OcmContext implements Context {
/** /**
* @param string $user * @param string $user
* @param string $email * @param string|null $email
* @param string $description * @param string|null $description
* *
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @throws GuzzleException
*/ */
public function createInvitation(string $user, $email = null, $description = null): ResponseInterface { public function createInvitation(
string $user,
?string $email = null,
?string $description = null,
): ResponseInterface {
$response = OcmHelper::createInvitation( $response = OcmHelper::createInvitation(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$user, $user,
@@ -99,13 +103,17 @@ class OcmContext implements Context {
* @When :user creates the federation share invitation with email :email and description :description * @When :user creates the federation share invitation with email :email and description :description
* *
* @param string $user * @param string $user
* @param string $email * @param string|null $email
* @param string $description * @param string|null $description
* *
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userCreatesTheFederationShareInvitation(string $user, $email = null, $description = null): void { public function userCreatesTheFederationShareInvitation(
string $user,
?string $email = null,
?string $description = null,
): void {
$this->featureContext->setResponse($this->createInvitation($user, $email, $description)); $this->featureContext->setResponse($this->createInvitation($user, $email, $description));
} }
@@ -114,25 +122,29 @@ class OcmContext implements Context {
* @Given :user has created the federation share invitation with email :email and description :description * @Given :user has created the federation share invitation with email :email and description :description
* *
* @param string $user * @param string $user
* @param string $email * @param string|null $email
* @param string $description * @param string|null $description
* *
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userHasCreatedTheFederationShareInvitation(string $user, $email = null, $description = null): void { public function userHasCreatedTheFederationShareInvitation(
string $user,
?string $email = null,
?string $description = null,
): void {
$response = $this->createInvitation($user, $email, $description); $response = $this->createInvitation($user, $email, $description);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
} }
/** /**
* @param string $user * @param string $user
* @param string $token * @param string|null $token
* *
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @throws GuzzleException
*/ */
public function acceptInvitation(string $user, string $token = null): ResponseInterface { public function acceptInvitation(string $user, ?string $token = null): ResponseInterface {
$providerDomain = $this->featureContext->getLocalBaseUrlWithoutScheme(); $providerDomain = $this->featureContext->getLocalBaseUrlWithoutScheme();
if ($this->featureContext->getCurrentServer() === "LOCAL") { if ($this->featureContext->getCurrentServer() === "LOCAL") {
$providerDomain = $this->featureContext->getRemoteBaseUrlWithoutScheme(); $providerDomain = $this->featureContext->getRemoteBaseUrlWithoutScheme();
@@ -350,7 +362,7 @@ class OcmContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @throws GuzzleException
*/ */
public function deleteConnection(string $user, string $ocmUser, string $idp = null): ResponseInterface { public function deleteConnection(string $user, string $ocmUser, ?string $idp = null): ResponseInterface {
$ocmUser = $this->getAcceptedUserByName($user, $ocmUser); $ocmUser = $this->getAcceptedUserByName($user, $ocmUser);
$ocmUser['idp'] = $idp ?? $ocmUser['idp']; $ocmUser['idp'] = $idp ?? $ocmUser['idp'];
return OcmHelper::deleteConnection( return OcmHelper::deleteConnection(

View File

@@ -1055,7 +1055,7 @@ trait Provisioning {
*/ */
public function userHasBeenCreated( public function userHasBeenCreated(
array $userData, array $userData,
string $byUser = null, ?string $byUser = null,
): void { ): void {
$userId = null; $userId = null;

View File

@@ -787,7 +787,7 @@ class PublicWebDavContext implements Context {
*/ */
public function publiclyUploadingWithPasswordShouldNotWork( public function publiclyUploadingWithPasswordShouldNotWork(
string $password, string $password,
string $expectedHttpCode = null, ?string $expectedHttpCode = null,
): void { ): void {
$response = $this->publicUploadContent( $response = $this->publicUploadContent(
'whateverfilefortesting.txt', 'whateverfilefortesting.txt',

View File

@@ -350,14 +350,14 @@ class SettingsContext implements Context {
/** /**
* @param string $user * @param string $user
* @param array $headers * @param array|null $headers
* *
* @return ResponseInterface * @return ResponseInterface
* *
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @throws Exception
*/ */
public function sendRequestGetSettingsValuesList(string $user, array $headers = null): ResponseInterface { public function sendRequestGetSettingsValuesList(string $user, ?array $headers = null): ResponseInterface {
return SettingsHelper::getValuesList( return SettingsHelper::getValuesList(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$user, $user,

View File

@@ -552,7 +552,7 @@ trait Sharing {
string $user, string $user,
string $path, string $path,
bool $publicUpload = false, bool $publicUpload = false,
string $sharePassword = null, ?string $sharePassword = null,
$permissions = null, $permissions = null,
?string $linkName = null, ?string $linkName = null,
?string $expireDate = null, ?string $expireDate = null,
@@ -1711,7 +1711,7 @@ trait Sharing {
*/ */
public function deleteLastShareUsingSharingApi( public function deleteLastShareUsingSharingApi(
string $user, string $user,
string $sharer = null, ?string $sharer = null,
bool $deleteLastPublicLink = false, bool $deleteLastPublicLink = false,
): ResponseInterface { ): ResponseInterface {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);

View File

@@ -310,7 +310,7 @@ class SharingNgContext implements Context {
public function sendShareInvitation( public function sendShareInvitation(
string $user, string $user,
array $shareInfo, array $shareInfo,
string $fileId = null, ?string $fileId = null,
bool $federatedShare = false, bool $federatedShare = false,
): ResponseInterface { ): ResponseInterface {
$space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']); $space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']);

View File

@@ -2040,7 +2040,7 @@ class SpacesContext implements Context {
string $fromSpaceName, string $fromSpaceName,
string $fileDestination, string $fileDestination,
string $toSpaceName, string $toSpaceName,
TableNode $table = null, ?TableNode $table = null,
): void { ): void {
$space = $this->getSpaceByName($user, $fromSpaceName); $space = $this->getSpaceByName($user, $fromSpaceName);
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName( $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
@@ -2213,7 +2213,7 @@ class SpacesContext implements Context {
string $user, string $user,
string $fileDestination, string $fileDestination,
string $spaceName, string $spaceName,
string $endPath = null, ?string $endPath = null,
): string { ): string {
$space = $this->getSpaceByName($user, $spaceName); $space = $this->getSpaceByName($user, $spaceName);
$fileDestination = $this->escapePath(\ltrim($fileDestination, "/")); $fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));
@@ -4676,7 +4676,7 @@ class SpacesContext implements Context {
string $recipientType, string $recipientType,
string $recipient, string $recipient,
string $role, string $role,
string $expirationDate = null, ?string $expirationDate = null,
): void { ): void {
$response = $this->listAllMySpaces($user); $response = $this->listAllMySpaces($user);
$this->featureContext->theHTTPStatusCodeShouldBe( $this->featureContext->theHTTPStatusCodeShouldBe(

View File

@@ -259,7 +259,7 @@ class TUSContext implements Context {
string $destination, string $destination,
array $uploadMetadata = [], array $uploadMetadata = [],
int $noOfChunks = 1, int $noOfChunks = 1,
int $bytes = null, ?int $bytes = null,
string $checksum = '', string $checksum = '',
): void { ): void {
$response = $this->uploadFileUsingTus( $response = $this->uploadFileUsingTus(
@@ -283,7 +283,7 @@ class TUSContext implements Context {
* @param string|null $spaceId * @param string|null $spaceId
* @param array $uploadMetadata * @param array $uploadMetadata
* @param integer $noOfChunks * @param integer $noOfChunks
* @param integer $bytes * @param integer|null $bytes
* @param string $checksum * @param string $checksum
* *
* @return ResponseInterface * @return ResponseInterface
@@ -295,7 +295,7 @@ class TUSContext implements Context {
?string $spaceId = null, ?string $spaceId = null,
array $uploadMetadata = [], array $uploadMetadata = [],
int $noOfChunks = 1, int $noOfChunks = 1,
int $bytes = null, ?int $bytes = null,
string $checksum = '', string $checksum = '',
): ResponseInterface { ): ResponseInterface {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);

View File

@@ -1600,7 +1600,7 @@ trait WebDav {
* @param string $user * @param string $user
* @param string $source * @param string $source
* @param string $destination * @param string $destination
* @param string $spaceId * @param string|null $spaceId
* @param bool|null $isGivenStep * @param bool|null $isGivenStep
* *
* @return ResponseInterface * @return ResponseInterface
@@ -1609,7 +1609,7 @@ trait WebDav {
string $user, string $user,
string $source, string $source,
string $destination, string $destination,
string $spaceId = null, ?string $spaceId = null,
?bool $isGivenStep = false, ?bool $isGivenStep = false,
): ResponseInterface { ): ResponseInterface {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
@@ -4042,11 +4042,11 @@ trait WebDav {
/** /**
* @param string $user * @param string $user
* @param string $path * @param string $path
* @param string $spaceId * @param string|null $spaceId
* *
* @return string|null * @return string|null
*/ */
public function getFileIdForPath(string $user, string $path, string $spaceId = null): ?string { public function getFileIdForPath(string $user, string $path, ?string $spaceId = null): ?string {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
try { try {
return WebDavHelper::getFileIdForPath( return WebDavHelper::getFileIdForPath(

View File

@@ -64,7 +64,7 @@ class WebDavLockingContext implements Context {
string $user, string $user,
string $file, string $file,
TableNode $properties, TableNode $properties,
string $fullUrl = null, ?string $fullUrl = null,
bool $public = false, bool $public = false,
bool $expectToSucceed = true, bool $expectToSucceed = true,
?string $spaceId = null, ?string $spaceId = null,
@@ -689,7 +689,7 @@ class WebDavLockingContext implements Context {
string $lockOwner, string $lockOwner,
string $itemToUseLockOf, string $itemToUseLockOf,
bool $public = false, bool $public = false,
string $fullUrl = null, ?string $fullUrl = null,
?string $spaceId = null, ?string $spaceId = null,
): ResponseInterface { ): ResponseInterface {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);

View File

@@ -312,7 +312,7 @@ class WebDavPropertiesContext implements Context {
string $propertyName, string $propertyName,
string $path, string $path,
string $propertyValue, string $propertyValue,
string $namespace = null, ?string $namespace = null,
): ResponseInterface { ): ResponseInterface {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
return WebDavHelper::proppatch( return WebDavHelper::proppatch(
@@ -653,7 +653,7 @@ class WebDavPropertiesContext implements Context {
public function checkResponseContainsProperty( public function checkResponseContainsProperty(
ResponseInterface $response, ResponseInterface $response,
string $key, string $key,
string $namespaceString = null, ?string $namespaceString = null,
): SimpleXMLElement { ): SimpleXMLElement {
$xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__); $xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__);
; ;

View File

@@ -1,7 +1,7 @@
{ {
"config": { "config": {
"platform": { "platform": {
"php": "8.2" "php": "8.4"
}, },
"allow-plugins": { "allow-plugins": {
"composer/package-versions-deprecated": true "composer/package-versions-deprecated": true