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
* @param int $workspaceId
* @return string
*/
protected function getModuleUri(int $workspaceId = null): string
protected function getModuleUri(?int $workspaceId = null): string
{
$parameters = [
'id' => $this->pageId,
......
......@@ -67,7 +67,7 @@ class DatabaseRecord
* @param int $uid Id of the 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->setUid($uid);
......
......@@ -57,7 +57,7 @@ class StageRecord extends AbstractRecord
* @param array $record
* @return StageRecord|null
*/
public static function get($uid, array $record = null)
public static function get($uid, ?array $record = null)
{
if (empty($record)) {
$record = static::fetch('sys_workspace_stage', $uid);
......@@ -71,7 +71,7 @@ class StageRecord extends AbstractRecord
* @param array $record
* @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)) {
$record = static::fetch('sys_workspace_stage', $uid);
......
......@@ -72,7 +72,7 @@ class WorkspaceRecord extends AbstractRecord
* @param array $record
* @return WorkspaceRecord
*/
public static function get($uid, array $record = null)
public static function get($uid, ?array $record = null)
{
if (empty($uid)) {
$record = [];
......
......@@ -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
*/
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('workspace', GeneralUtility::makeInstance(WorkspaceAspect::class, $user ? $user->workspace : 0));
......
......@@ -148,7 +148,7 @@ class PreviewUriBuilder
* @param array $versionRecord Optional version record data
* @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);
$event = new RetrievedPreviewUrlEvent($table, $uid, $previewUri, [
......@@ -161,7 +161,7 @@ class PreviewUriBuilder
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') {
return BackendPreviewUriBuilder::create((int)BackendUtility::getLiveVersionIdOfRecord('pages', $uid))
......@@ -221,7 +221,7 @@ class PreviewUriBuilder
* @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]
*/
protected function compilePreviewKeyword(int $ttl = 172800, int $workspaceId = null): string
protected function compilePreviewKeyword(int $ttl = 172800, ?int $workspaceId = null): string
{
$keyword = md5(StringUtility::getUniqueId());
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