Project

General

Profile

Actions

Task #94683

closed

setPid on AbstractDomainObject should not force void return type

Added by Rozbeh Chiryai Sharahi over 3 years ago. Updated 6 months ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-08-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

I believe it is a good practice to have fluent setters (return type self) for instance in order to have immutable objects. Sure in that case it should be called with*. Nevertheless I don't find it necessary to force void as a return type on AbstractDomainObject->setPid. Also this avoids clean code styles like:

$someService->save((new Entity())->setPid(123));
    /**
     * Setter for the pid.
     *
     * @param int $pid
     */
    public function setPid(int $pid): void
    {
        $this->pid = $pid;
    }

If TYPO3 does not use this i fully understand but at least it should not force void return type, which makes it impossible as an extension developer to have fluent setters apart from creating a different method like setPageUid().

Kind regards and thank you for the great work
Rozbeh Chiryai Sharahi

Actions #1

Updated by Rozbeh Chiryai Sharahi over 3 years ago

  • Description updated (diff)
Actions #2

Updated by Bastian Bringenberg over 3 years ago

  • Project changed from 9 to TYPO3 Core
  • TYPO3 Version set to 10

Guessed TYPO3 Version.
Moved Project.

Actions #3

Updated by Georg Ringer 6 months ago

  • Status changed from New to Rejected

closing this issue as declaring the return type is always good and changing the return type is never a good thing.

as you already tell, there is always the option to use alternativ methods

Actions

Also available in: Atom PDF