Project

General

Profile

Actions

Bug #85311

closed

Extbase/ObjectManager does not fully support nullable types

Added by S P over 6 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2018-06-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

This fails (e.g. in a controller): $this->objectManager->get(MyClass:class, null) if the constructur of MyClass uses __construct(?MyType $foo) - an exception is thrown:

throw new \InvalidArgumentException('not a correct info array of constructor dependencies was passed!', 1476107941);

Changing the ctor to __construct(MyType $foo = null) works, but this means something different. The ? means it is nullable but required, = null means it is nullable but optional. There are common cases where arguments are nullable and required in multi-argument constructors: e.g, where one passes five arguments where only the fifth is optional, but the second is nullable.

PHP allows optional argument declaration in the middle of the arguemnt list, but it is bad practice (and meaningless).

Extbase should support nullable types.

Found on v8, but valid for all others, I assume.

Actions

Also available in: Atom PDF