Commit 3e7fc67c authored by Elias Häußler's avatar Elias Häußler 🐛 Committed by Oliver Hader
Browse files

[BUGFIX] Fix several type annotations in FormDefinition

This patches replaces several wrong or incomplete type annotations in
FormDefinition. Additionally, the `$renderables` property is now
explicitly declared and annotated as `array<int, Page>` since it only
contains pages.

Resolves: #97545
Releases: main, 11.5
Change-Id: I182a861276c65142be7266ec7b10420f8532372c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74508


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Björn Jacob's avatarBjörn Jacob <bjoern.jacob@tritum.de>
Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Björn Jacob's avatarBjörn Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
parent 7195b429
...@@ -3570,16 +3570,6 @@ parameters: ...@@ -3570,16 +3570,6 @@ parameters:
count: 1 count: 1
path: ../../typo3/sysext/form/Classes/Domain/Finishers/SaveToDatabaseFinisher.php path: ../../typo3/sysext/form/Classes/Domain/Finishers/SaveToDatabaseFinisher.php
-
message: "#^Method TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\FormDefinition\\:\\:getPageByIndex\\(\\) should return TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\FormElements\\\\Page but returns TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\Renderable\\\\RenderableInterface\\.$#"
count: 1
path: ../../typo3/sysext/form/Classes/Domain/Model/FormDefinition.php
-
message: "#^Method TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\FormDefinition\\:\\:getPages\\(\\) should return array\\<TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\FormElements\\\\Page\\> but returns array\\<TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\Renderable\\\\RenderableInterface\\>\\.$#"
count: 1
path: ../../typo3/sysext/form/Classes/Domain/Model/FormDefinition.php
- -
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\FormElements\\\\FormElementInterface\\:\\:setOptions\\(\\)\\.$#" message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Form\\\\Domain\\\\Model\\\\FormElements\\\\FormElementInterface\\:\\:setOptions\\(\\)\\.$#"
count: 1 count: 1
......
...@@ -222,17 +222,25 @@ use TYPO3\CMS\Form\Mvc\ProcessingRule; ...@@ -222,17 +222,25 @@ use TYPO3\CMS\Form\Mvc\ProcessingRule;
*/ */
class FormDefinition extends AbstractCompositeRenderable implements VariableRenderableInterface class FormDefinition extends AbstractCompositeRenderable implements VariableRenderableInterface
{ {
/**
* The Form's pages
*
* @var array<int, Page>
*/
protected $renderables = [];
/** /**
* The finishers for this form * The finishers for this form
* *
* @var \TYPO3\CMS\Form\Domain\Finishers\FinisherInterface[] * @var list<FinisherInterface>
*/ */
protected $finishers = []; protected $finishers = [];
/** /**
* Property Mapping Rules, indexed by element identifier * Property Mapping Rules, indexed by element identifier
* *
* @var \TYPO3\CMS\Form\Mvc\ProcessingRule[] * @var array<string, ProcessingRule>
*/ */
protected $processingRules = []; protected $processingRules = [];
...@@ -240,14 +248,14 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -240,14 +248,14 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
* Contains all elements of the form, indexed by identifier. * Contains all elements of the form, indexed by identifier.
* Is used as internal cache as we need this really often. * Is used as internal cache as we need this really often.
* *
* @var \TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface[] * @var array<string, FormElementInterface>
*/ */
protected $elementsByIdentifier = []; protected $elementsByIdentifier = [];
/** /**
* Form element default values in the format ['elementIdentifier' => 'default value'] * Form element default values in the format ['elementIdentifier' => 'default value']
* *
* @var array * @var array<string, mixed>
*/ */
protected $elementDefaultValues = []; protected $elementDefaultValues = [];
...@@ -259,17 +267,17 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -259,17 +267,17 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
protected $rendererClassName = ''; protected $rendererClassName = '';
/** /**
* @var array * @var array<string, array<string, mixed>>
*/ */
protected $typeDefinitions; protected $typeDefinitions;
/** /**
* @var array * @var array<string, array<string, mixed>>
*/ */
protected $validatorsDefinition; protected $validatorsDefinition;
/** /**
* @var array * @var array<string, array<string, mixed>>
*/ */
protected $finishersDefinition; protected $finishersDefinition;
...@@ -291,7 +299,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -291,7 +299,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
* @param string $identifier The Form Definition's identifier, must be a non-empty string. * @param string $identifier The Form Definition's identifier, must be a non-empty string.
* @param array $prototypeConfiguration overrides form defaults of this definition * @param array $prototypeConfiguration overrides form defaults of this definition
* @param string $type element type of this form * @param string $type element type of this form
* @param string $persistenceIdentifier the persistence identifier of the form * @param string|null $persistenceIdentifier the persistence identifier of the form
* @throws IdentifierNotValidException if the identifier was not valid * @throws IdentifierNotValidException if the identifier was not valid
*/ */
public function __construct( public function __construct(
...@@ -447,7 +455,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -447,7 +455,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
/** /**
* Get the Form's pages * Get the Form's pages
* *
* @return array|Page[] The Form's pages in the correct order * @return array<int, Page> The Form's pages in the correct order
*/ */
public function getPages(): array public function getPages(): array
{ {
...@@ -471,7 +479,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -471,7 +479,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
* If page at $index does not exist, an exception is thrown. @see hasPageWithIndex() * If page at $index does not exist, an exception is thrown. @see hasPageWithIndex()
* *
* @param int $index * @param int $index
* @return Page the page, or NULL if none found. * @return Page the page
* @throws FormException if the specified index does not exist * @throws FormException if the specified index does not exist
*/ */
public function getPageByIndex(int $index) public function getPageByIndex(int $index)
...@@ -517,7 +525,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -517,7 +525,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
/** /**
* Gets all finishers of this form * Gets all finishers of this form
* *
* @return \TYPO3\CMS\Form\Domain\Finishers\FinisherInterface[] * @return list<FinisherInterface>
*/ */
public function getFinishers(): array public function getFinishers(): array
{ {
...@@ -557,7 +565,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -557,7 +565,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
/** /**
* Get all form elements with their identifiers as keys * Get all form elements with their identifiers as keys
* *
* @return FormElementInterface[] * @return array<string, FormElementInterface>
*/ */
public function getElements(): array public function getElements(): array
{ {
...@@ -570,7 +578,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -570,7 +578,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
* If identifier does not exist, returns NULL. * If identifier does not exist, returns NULL.
* *
* @param string $elementIdentifier * @param string $elementIdentifier
* @return FormElementInterface The element with the given $elementIdentifier or NULL if none found * @return FormElementInterface|null The element with the given $elementIdentifier or NULL if none found
*/ */
public function getElementByIdentifier(string $elementIdentifier) public function getElementByIdentifier(string $elementIdentifier)
{ {
...@@ -670,7 +678,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -670,7 +678,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
/** /**
* Get all mapping rules * Get all mapping rules
* *
* @return \TYPO3\CMS\Form\Mvc\ProcessingRule[] * @return array<string, ProcessingRule>
* @internal * @internal
*/ */
public function getProcessingRules(): array public function getProcessingRules(): array
...@@ -679,7 +687,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -679,7 +687,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
} }
/** /**
* @return array * @return array<string, array<string, mixed>>
* @internal * @internal
*/ */
public function getTypeDefinitions(): array public function getTypeDefinitions(): array
...@@ -688,7 +696,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend ...@@ -688,7 +696,7 @@ class FormDefinition extends AbstractCompositeRenderable implements VariableRend
} }
/** /**
* @return array * @return array<string, array<string, mixed>>
* @internal * @internal
*/ */
public function getValidatorsDefinition(): array public function getValidatorsDefinition(): array
......
Supports Markdown
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