mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 11:54:32 +02:00
Improved typing and phpdoc type annotations
This commit is contained in:
parent
3817ba774d
commit
b7c8ca2a48
39 changed files with 189 additions and 129 deletions
|
@ -162,9 +162,11 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
|||
/**
|
||||
* Set the option of the form.
|
||||
* This a bit hacky because we access private properties....
|
||||
*
|
||||
* @param FormConfigInterface $builder The form on which the option should be set
|
||||
* @param string $option The option which should be changed
|
||||
* @param mixed $value The new value
|
||||
*/
|
||||
public function setOption(FormConfigInterface $builder, string $option, $value): void
|
||||
public function setOption(FormConfigInterface $builder, string $option, mixed $value): void
|
||||
{
|
||||
if (!$builder instanceof FormConfigBuilder) {
|
||||
throw new \RuntimeException('This method only works with FormConfigBuilder instances.');
|
||||
|
@ -173,10 +175,8 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
|||
//We have to use FormConfigBuilder::class here, because options is private and not available in subclasses
|
||||
$reflection = new ReflectionClass(FormConfigBuilder::class);
|
||||
$property = $reflection->getProperty('options');
|
||||
$property->setAccessible(true);
|
||||
$tmp = $property->getValue($builder);
|
||||
$tmp[$option] = $value;
|
||||
$property->setValue($builder, $tmp);
|
||||
$property->setAccessible(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ final class PermissionsMapper implements DataMapperInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Maps the view data of a compound form to its children.
|
||||
* Maps the view data of a compound form to its children.
|
||||
*
|
||||
* The method is responsible for calling {@link FormInterface::setData()}
|
||||
* on the children of compound forms, defining their underlying model data.
|
||||
* The method is responsible for calling {@link FormInterface::setData()}
|
||||
* on the children of compound forms, defining their underlying model data.
|
||||
*
|
||||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param Traversable $forms A list of {@link FormInterface} instances
|
||||
*/
|
||||
public function mapDataToForms($viewData, \Traversable $forms): void
|
||||
{
|
||||
|
@ -68,29 +68,29 @@ final class PermissionsMapper implements DataMapperInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Maps the model data of a list of children forms into the view data of their parent.
|
||||
* Maps the model data of a list of children forms into the view data of their parent.
|
||||
*
|
||||
* This is the internal cascade call of FormInterface::submit for compound forms, since they
|
||||
* cannot be bound to any input nor the request as scalar, but their children may:
|
||||
* This is the internal cascade call of FormInterface::submit for compound forms, since they
|
||||
* cannot be bound to any input nor the request as scalar, but their children may:
|
||||
*
|
||||
* $compoundForm->submit($arrayOfChildrenViewData)
|
||||
* // inside:
|
||||
* $childForm->submit($childViewData);
|
||||
* // for each entry, do the same and/or reverse transform
|
||||
* $this->dataMapper->mapFormsToData($compoundForm, $compoundInitialViewData)
|
||||
* // then reverse transform
|
||||
* $compoundForm->submit($arrayOfChildrenViewData)
|
||||
* // inside:
|
||||
* $childForm->submit($childViewData);
|
||||
* // for each entry, do the same and/or reverse transform
|
||||
* $this->dataMapper->mapFormsToData($compoundForm, $compoundInitialViewData)
|
||||
* // then reverse transform
|
||||
*
|
||||
* When a simple form is submitted the following is happening:
|
||||
* When a simple form is submitted the following is happening:
|
||||
*
|
||||
* $simpleForm->submit($submittedViewData)
|
||||
* // inside:
|
||||
* $this->viewData = $submittedViewData
|
||||
* // then reverse transform
|
||||
* $simpleForm->submit($submittedViewData)
|
||||
* // inside:
|
||||
* $this->viewData = $submittedViewData
|
||||
* // then reverse transform
|
||||
*
|
||||
* The model data can be an array or an object, so this second argument is always passed
|
||||
* by reference.
|
||||
* The model data can be an array or an object, so this second argument is always passed
|
||||
* by reference.
|
||||
*
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
*/
|
||||
|
|
|
@ -143,13 +143,13 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Maps the view data of a compound form to its children.
|
||||
* Maps the view data of a compound form to its children.
|
||||
*
|
||||
* The method is responsible for calling {@link FormInterface::setData()}
|
||||
* on the children of compound forms, defining their underlying model data.
|
||||
* The method is responsible for calling {@link FormInterface::setData()}
|
||||
* on the children of compound forms, defining their underlying model data.
|
||||
*
|
||||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param Traversable $forms A list of {@link FormInterface} instances
|
||||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
|
||||
*/
|
||||
|
@ -176,29 +176,29 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Maps the model data of a list of children forms into the view data of their parent.
|
||||
* Maps the model data of a list of children forms into the view data of their parent.
|
||||
*
|
||||
* This is the internal cascade call of FormInterface::submit for compound forms, since they
|
||||
* cannot be bound to any input nor the request as scalar, but their children may:
|
||||
* This is the internal cascade call of FormInterface::submit for compound forms, since they
|
||||
* cannot be bound to any input nor the request as scalar, but their children may:
|
||||
*
|
||||
* $compoundForm->submit($arrayOfChildrenViewData)
|
||||
* // inside:
|
||||
* $childForm->submit($childViewData);
|
||||
* // for each entry, do the same and/or reverse transform
|
||||
* $this->dataMapper->mapFormsToData($compoundForm, $compoundInitialViewData)
|
||||
* // then reverse transform
|
||||
* $compoundForm->submit($arrayOfChildrenViewData)
|
||||
* // inside:
|
||||
* $childForm->submit($childViewData);
|
||||
* // for each entry, do the same and/or reverse transform
|
||||
* $this->dataMapper->mapFormsToData($compoundForm, $compoundInitialViewData)
|
||||
* // then reverse transform
|
||||
*
|
||||
* When a simple form is submitted the following is happening:
|
||||
* When a simple form is submitted the following is happening:
|
||||
*
|
||||
* $simpleForm->submit($submittedViewData)
|
||||
* // inside:
|
||||
* $this->viewData = $submittedViewData
|
||||
* // then reverse transform
|
||||
* $simpleForm->submit($submittedViewData)
|
||||
* // inside:
|
||||
* $this->viewData = $submittedViewData
|
||||
* // then reverse transform
|
||||
*
|
||||
* The model data can be an array or an object, so this second argument is always passed
|
||||
* by reference.
|
||||
* The model data can be an array or an object, so this second argument is always passed
|
||||
* by reference.
|
||||
*
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue