Skip to content
Snippets Groups Projects
Commit 4a574c76 authored by Stefan Bürk's avatar Stefan Bürk
Browse files

[TASK] Avoid implicitly nullable class method parameter in `EXT:workspaces`

With PHP 8.4 marking method parameter implicitly nullable
is deprecated and will emit a `E_DEPRECATED` warning. One
recommended way to resolve this, is making it explicitly
nullable using the `?` nullable operator. [1]

This prepares the way towards PHP 8.4 compatibility and
unifies towards using `?` nullable operator over union
null type when possible.

[1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated

Resolves: #104185
Releases: main, 12.4, 11.5
Change-Id: I12462595d622efa1bbe2a479f159d68a984bda23
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84869


Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarGarvin Hicking <gh@faktor-e.de>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarGarvin Hicking <gh@faktor-e.de>
parent 078baa6c
Branches
Tags
No related merge requests found
...@@ -280,7 +280,7 @@ class ReviewController ...@@ -280,7 +280,7 @@ class ReviewController
* @param int $workspaceId * @param int $workspaceId
* @return string * @return string
*/ */
protected function getModuleUri(int $workspaceId = null): string protected function getModuleUri(?int $workspaceId = null): string
{ {
$parameters = [ $parameters = [
'id' => $this->pageId, 'id' => $this->pageId,
......
...@@ -67,7 +67,7 @@ class DatabaseRecord ...@@ -67,7 +67,7 @@ class DatabaseRecord
* @param int $uid Id of the database record row * @param int $uid Id of the database record row
* @param array|null $row The relevant database record row * @param array|null $row The relevant database record row
*/ */
public function __construct($table, $uid, array $row = null) public function __construct($table, $uid, ?array $row = null)
{ {
$this->setTable($table); $this->setTable($table);
$this->setUid($uid); $this->setUid($uid);
......
...@@ -57,7 +57,7 @@ class StageRecord extends AbstractRecord ...@@ -57,7 +57,7 @@ class StageRecord extends AbstractRecord
* @param array $record * @param array $record
* @return StageRecord|null * @return StageRecord|null
*/ */
public static function get($uid, array $record = null) public static function get($uid, ?array $record = null)
{ {
if (empty($record)) { if (empty($record)) {
$record = static::fetch('sys_workspace_stage', $uid); $record = static::fetch('sys_workspace_stage', $uid);
...@@ -71,7 +71,7 @@ class StageRecord extends AbstractRecord ...@@ -71,7 +71,7 @@ class StageRecord extends AbstractRecord
* @param array $record * @param array $record
* @return StageRecord * @return StageRecord
*/ */
public static function build(WorkspaceRecord $workspace, $uid, array $record = null) public static function build(WorkspaceRecord $workspace, $uid, ?array $record = null)
{ {
if (empty($record)) { if (empty($record)) {
$record = static::fetch('sys_workspace_stage', $uid); $record = static::fetch('sys_workspace_stage', $uid);
......
...@@ -72,7 +72,7 @@ class WorkspaceRecord extends AbstractRecord ...@@ -72,7 +72,7 @@ class WorkspaceRecord extends AbstractRecord
* @param array $record * @param array $record
* @return WorkspaceRecord * @return WorkspaceRecord
*/ */
public static function get($uid, array $record = null) public static function get($uid, ?array $record = null)
{ {
if (empty($uid)) { if (empty($uid)) {
$record = []; $record = [];
......
...@@ -413,7 +413,7 @@ class WorkspacePreview implements MiddlewareInterface ...@@ -413,7 +413,7 @@ class WorkspacePreview implements MiddlewareInterface
/** /**
* Register or override the backend user as aspect, as well as the workspace information the user object is holding * Register or override the backend user as aspect, as well as the workspace information the user object is holding
*/ */
protected function setBackendUserAspect(Context $context, BackendUserAuthentication $user = null) protected function setBackendUserAspect(Context $context, ?BackendUserAuthentication $user = null)
{ {
$context->setAspect('backend.user', GeneralUtility::makeInstance(UserAspect::class, $user)); $context->setAspect('backend.user', GeneralUtility::makeInstance(UserAspect::class, $user));
$context->setAspect('workspace', GeneralUtility::makeInstance(WorkspaceAspect::class, $user ? $user->workspace : 0)); $context->setAspect('workspace', GeneralUtility::makeInstance(WorkspaceAspect::class, $user ? $user->workspace : 0));
......
...@@ -148,7 +148,7 @@ class PreviewUriBuilder ...@@ -148,7 +148,7 @@ class PreviewUriBuilder
* @param array $versionRecord Optional version record data * @param array $versionRecord Optional version record data
* @return string * @return string
*/ */
public function buildUriForElement(string $table, int $uid, array $liveRecord = null, array $versionRecord = null): string public function buildUriForElement(string $table, int $uid, ?array $liveRecord = null, ?array $versionRecord = null): string
{ {
$previewUri = $this->createPreviewUriForElement($table, $uid, $liveRecord, $versionRecord); $previewUri = $this->createPreviewUriForElement($table, $uid, $liveRecord, $versionRecord);
$event = new RetrievedPreviewUrlEvent($table, $uid, $previewUri, [ $event = new RetrievedPreviewUrlEvent($table, $uid, $previewUri, [
...@@ -161,7 +161,7 @@ class PreviewUriBuilder ...@@ -161,7 +161,7 @@ class PreviewUriBuilder
return $previewUri; return $previewUri;
} }
protected function createPreviewUriForElement(string $table, int $uid, array $liveRecord = null, array $versionRecord = null): ?UriInterface protected function createPreviewUriForElement(string $table, int $uid, ?array $liveRecord = null, ?array $versionRecord = null): ?UriInterface
{ {
if ($table === 'pages') { if ($table === 'pages') {
return BackendPreviewUriBuilder::create((int)BackendUtility::getLiveVersionIdOfRecord('pages', $uid)) return BackendPreviewUriBuilder::create((int)BackendUtility::getLiveVersionIdOfRecord('pages', $uid))
...@@ -221,7 +221,7 @@ class PreviewUriBuilder ...@@ -221,7 +221,7 @@ class PreviewUriBuilder
* @param int|null $workspaceId Which workspace ID to preview. * @param int|null $workspaceId Which workspace ID to preview.
* @return string Returns keyword to use in URL for ADMCMD_prev=, a 32 byte MD5 hash keyword for the URL: "?ADMCMD_prev=[keyword] * @return string Returns keyword to use in URL for ADMCMD_prev=, a 32 byte MD5 hash keyword for the URL: "?ADMCMD_prev=[keyword]
*/ */
protected function compilePreviewKeyword(int $ttl = 172800, int $workspaceId = null): string protected function compilePreviewKeyword(int $ttl = 172800, ?int $workspaceId = null): string
{ {
$keyword = md5(StringUtility::getUniqueId()); $keyword = md5(StringUtility::getUniqueId());
GeneralUtility::makeInstance(ConnectionPool::class) GeneralUtility::makeInstance(ConnectionPool::class)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment