Skip to content
Browse files

[Form] fixed and added phpDoc

  • Loading branch information...
1 parent a132add commit 5cc6b2473629d8a9dc361a7d5c347f6805bb8137 @Tobion Tobion committed
Showing with 79 additions and 102 deletions.
  1. +2 −2 Event/DataEvent.php
  2. +37 −78 Form.php
  3. +2 −1 FormBuilder.php
  4. +0 −1 FormConfigBuilder.php
  5. +4 −4 FormConfigBuilderInterface.php
  6. +1 −1 FormConfigInterface.php
  7. +5 −5 FormError.php
  8. +27 −9 FormInterface.php
  9. +1 −1 Util/PropertyPathIterator.php
View
4 Event/DataEvent.php
@@ -50,7 +50,7 @@ public function getForm()
/**
* Returns the data associated with this event.
*
- * @return type
+ * @return mixed
*/
public function getData()
{
@@ -58,7 +58,7 @@ public function getData()
}
/**
- * Allows updating with some filtered data
+ * Allows updating with some filtered data.
*
* @param mixed $data
*/
View
115 Form.php
@@ -164,9 +164,7 @@ public function __clone()
}
/**
- * Returns the configuration of the form.
- *
- * @return FormConfigInterface The form's configuration.
+ * {@inheritdoc}
*/
public function getConfig()
{
@@ -174,9 +172,7 @@ public function getConfig()
}
/**
- * Returns the name by which the form is identified in forms.
- *
- * @return string The name of the form.
+ * {@inheritdoc}
*/
public function getName()
{
@@ -247,11 +243,7 @@ public function isDisabled()
}
/**
- * Sets the parent form.
- *
- * @param FormInterface $parent The parent form
- *
- * @return Form The current form
+ * {@inheritdoc}
*/
public function setParent(FormInterface $parent = null)
{
@@ -269,9 +261,7 @@ public function setParent(FormInterface $parent = null)
}
/**
- * Returns the parent form.
- *
- * @return FormInterface The parent form
+ * {@inheritdoc}
*/
public function getParent()
{
@@ -279,9 +269,7 @@ public function getParent()
}
/**
- * Returns whether the form has a parent.
- *
- * @return Boolean
+ * {@inheritdoc}
*/
public function hasParent()
{
@@ -289,9 +277,7 @@ public function hasParent()
}
/**
- * Returns the root of the form tree.
- *
- * @return FormInterface The root of the tree
+ * {@inheritdoc}
*/
public function getRoot()
{
@@ -299,9 +285,7 @@ public function getRoot()
}
/**
- * Returns whether the form is the root of the form tree.
- *
- * @return Boolean
+ * {@inheritdoc}
*/
public function isRoot()
{
@@ -339,11 +323,7 @@ public function getAttribute($name)
}
/**
- * Updates the form with default data.
- *
- * @param mixed $modelData The data formatted as expected for the underlying object
- *
- * @return Form The current form
+ * {@inheritdoc}
*/
public function setData($modelData)
{
@@ -440,9 +420,7 @@ public function setData($modelData)
}
/**
- * Returns the data in the format needed for the underlying object.
- *
- * @return mixed
+ * {@inheritdoc}
*/
public function getData()
{
@@ -454,11 +432,7 @@ public function getData()
}
/**
- * Returns the normalized data of the form.
- *
- * @return mixed When the form is not bound, the default data is returned.
- * When the form is bound, the normalized bound data is
- * returned if the form is valid, null otherwise.
+ * {@inheritdoc}
*/
public function getNormData()
{
@@ -470,9 +444,7 @@ public function getNormData()
}
/**
- * Returns the data transformed by the value transformer.
- *
- * @return string
+ * {@inheritdoc}
*/
public function getViewData()
{
@@ -497,9 +469,7 @@ public function getClientData()
}
/**
- * Returns the extra data.
- *
- * @return array The bound data which do not belong to a child
+ * {@inheritdoc}
*/
public function getExtraData()
{
@@ -507,13 +477,7 @@ public function getExtraData()
}
/**
- * Binds data to the form, transforms and validates it.
- *
- * @param string|array $submittedData The data
- *
- * @return Form The current form
- *
- * @throws UnexpectedTypeException
+ * {@inheritdoc}
*/
public function bind($submittedData)
{
@@ -677,11 +641,7 @@ public function bindRequest(Request $request)
}
/**
- * Adds an error to this form.
- *
- * @param FormError $error
- *
- * @return Form The current form
+ * {@inheritdoc}
*/
public function addError(FormError $error)
{
@@ -708,9 +668,7 @@ public function getErrorBubbling()
}
/**
- * Returns whether the form is bound.
- *
- * @return Boolean true if the form is bound to input values, false otherwise
+ * {@inheritdoc}
*/
public function isBound()
{
@@ -718,9 +676,7 @@ public function isBound()
}
/**
- * Returns whether the data in the different formats is synchronized.
- *
- * @return Boolean
+ * {@inheritdoc}
*/
public function isSynchronized()
{
@@ -728,9 +684,7 @@ public function isSynchronized()
}
/**
- * Returns whether the form is empty.
- *
- * @return Boolean
+ * {@inheritdoc}
*/
public function isEmpty()
{
@@ -744,9 +698,7 @@ public function isEmpty()
}
/**
- * Returns whether the form is valid.
- *
- * @return Boolean
+ * {@inheritdoc}
*/
public function isValid()
{
@@ -783,9 +735,7 @@ public function hasErrors()
}
/**
- * Returns all errors.
- *
- * @return array An array of FormError instances that occurred during binding
+ * {@inheritdoc}
*/
public function getErrors()
{
@@ -962,11 +912,11 @@ public function get($name)
}
/**
- * Returns true if the child exists (implements the \ArrayAccess interface).
+ * Returns whether a child with the given name exists (implements the \ArrayAccess interface).
*
* @param string $name The name of the child
*
- * @return Boolean true if the widget exists, false otherwise
+ * @return Boolean
*/
public function offsetExists($name)
{
@@ -974,11 +924,13 @@ public function offsetExists($name)
}
/**
- * Returns the form child associated with the name (implements the \ArrayAccess interface).
+ * Returns the child with the given name (implements the \ArrayAccess interface).
+ *
+ * @param string $name The name of the child
*
- * @param string $name The offset of the value to get
+ * @return FormInterface The child form
*
- * @return FormInterface A form instance
+ * @throws \InvalidArgumentException If the named child does not exist.
*/
public function offsetGet($name)
{
@@ -989,7 +941,12 @@ public function offsetGet($name)
* Adds a child to the form (implements the \ArrayAccess interface).
*
* @param string $name Ignored. The name of the child is used.
- * @param FormInterface $child The child to be added
+ * @param FormInterface $child The child to be added.
+ *
+ * @throws AlreadyBoundException If the form has already been bound.
+ * @throws FormException When trying to add a child to a non-compound form.
+ *
+ * @see self::add()
*/
public function offsetSet($name, $child)
{
@@ -999,7 +956,9 @@ public function offsetSet($name, $child)
/**
* Removes the child with the given name from the form (implements the \ArrayAccess interface).
*
- * @param string $name The name of the child to be removed
+ * @param string $name The name of the child to remove
+ *
+ * @throws AlreadyBoundException If the form has already been bound.
*/
public function offsetUnset($name)
{
@@ -1043,7 +1002,7 @@ public function createView(FormView $parent = null)
*
* @param mixed $value The value to transform
*
- * @return string
+ * @return mixed
*/
private function modelToNorm($value)
{
@@ -1077,7 +1036,7 @@ private function normToModel($value)
*
* @param mixed $value The value to transform
*
- * @return string
+ * @return mixed
*/
private function normToView($value)
{
View
3 FormBuilder.php
@@ -44,7 +44,8 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
private $unresolvedChildren = array();
/**
- * The parent of this builder
+ * The parent of this builder.
+ *
* @var FormBuilder
*/
private $parent;
View
1 FormConfigBuilder.php
@@ -143,7 +143,6 @@ class FormConfigBuilder implements FormConfigBuilderInterface
* @param EventDispatcherInterface $dispatcher The event dispatcher
* @param array $options The form options
*
- * @throws UnexpectedTypeException If the name is not a string.
* @throws \InvalidArgumentException If the data class is not a valid class or if
* the name contains invalid characters.
*/
View
8 FormConfigBuilderInterface.php
@@ -162,9 +162,9 @@ public function setRequired($required);
/**
* Sets the property path that the form should be mapped to.
*
- * @param string|PropertyPath $propertyPath The property path or null if the path
- * should be set automatically based on
- * the form's name.
+ * @param null|string|PropertyPathInterface $propertyPath The property path or null if the path
+ * should be set automatically based on
+ * the form's name.
*
* @return self The configuration object.
*/
@@ -184,7 +184,7 @@ public function setMapped($mapped);
* Sets whether the form's data should be modified by reference.
*
* @param Boolean $byReference Whether the data should be
- * modified by reference.
+ * modified by reference.
*
* @return self The configuration object.
*/
View
2 FormConfigInterface.php
@@ -35,7 +35,7 @@ public function getName();
/**
* Returns the property path that the form should be mapped to.
*
- * @return Util\PropertyPath The property path.
+ * @return null|Util\PropertyPathInterface The property path.
*/
public function getPropertyPath();
View
10 FormError.php
@@ -41,12 +41,12 @@ class FormError
*
* Any array key in $messageParameters will be used as a placeholder in
* $messageTemplate.
- * @see Symfony\Component\Translation\Translator
+ * @see \Symfony\Component\Translation\Translator
*
- * @param string $messageTemplate The template for the error message
- * @param array $messageParameters The parameters that should be
- * substituted in the message template.
- * @param integer $messagePluralization The value for error message pluralization
+ * @param string $messageTemplate The template for the error message
+ * @param array $messageParameters The parameters that should be
+ * substituted in the message template.
+ * @param integer|null $messagePluralization The value for error message pluralization
*/
public function __construct($messageTemplate, array $messageParameters = array(), $messagePluralization = null)
{
View
36 FormInterface.php
@@ -12,7 +12,7 @@
namespace Symfony\Component\Form;
/**
- * A form group bundling multiple form forms
+ * A form group bundling multiple forms in a hierarchical structure.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
@@ -24,6 +24,10 @@
* @param FormInterface $parent The parent form
*
* @return FormInterface The form instance
+ *
+ * @throws Exception\AlreadyBoundException If the form has already been bound.
+ * @throws Exception\FormException When trying to set a parent for a form with
+ * an empty name.
*/
public function setParent(FormInterface $parent = null);
@@ -47,6 +51,9 @@ public function hasParent();
* @param FormInterface $child The FormInterface to add as a child
*
* @return FormInterface The form instance
+ *
+ * @throws Exception\AlreadyBoundException If the form has already been bound.
+ * @throws Exception\FormException When trying to add a child to a non-compound form.
*/
public function add(FormInterface $child);
@@ -56,6 +63,8 @@ public function add(FormInterface $child);
* @param string $name The name of the child
*
* @return FormInterface The child form
+ *
+ * @throws \InvalidArgumentException If the named child does not exist.
*/
public function get($name);
@@ -74,6 +83,8 @@ public function has($name);
* @param string $name The name of the child to remove
*
* @return FormInterface The form instance
+ *
+ * @throws Exception\AlreadyBoundException If the form has already been bound.
*/
public function remove($name);
@@ -92,11 +103,16 @@ public function all();
public function getErrors();
/**
- * Updates the field with default data.
+ * Updates the form with default data.
*
* @param array $modelData The data formatted as expected for the underlying object
*
* @return FormInterface The form instance
+ *
+ * @throws Exception\AlreadyBoundException If the form has already been bound.
+ * @throws Exception\FormException If listeners try to call setData in a cycle. Or if
+ * the view data does not match the expected type
+ * according to {@link FormConfigInterface::getDataClass}.
*/
public function setData($modelData);
@@ -111,15 +127,15 @@ public function getData();
* Returns the normalized data of the field.
*
* @return mixed When the field is not bound, the default data is returned.
- * When the field is bound, the normalized bound data is
- * returned if the field is valid, null otherwise.
+ * When the field is bound, the normalized bound data is
+ * returned if the field is valid, null otherwise.
*/
public function getNormData();
/**
* Returns the data transformed by the value transformer.
*
- * @return string
+ * @return mixed
*/
public function getViewData();
@@ -154,7 +170,7 @@ public function getName();
/**
* Returns the property path that the form is mapped to.
*
- * @return Util\PropertyPath The property path.
+ * @return Util\PropertyPathInterface The property path.
*/
public function getPropertyPath();
@@ -213,13 +229,15 @@ public function isEmpty();
public function isSynchronized();
/**
- * Writes data into the form.
+ * Binds data to the form, transforms and validates it.
*
- * @param mixed $data The data
+ * @param null|string|array $submittedData The data
*
* @return FormInterface The form instance
+ *
+ * @throws Exception\AlreadyBoundException If the form has already been bound.
*/
- public function bind($data);
+ public function bind($submittedData);
/**
* Returns the root of the form tree.
View
2 Util/PropertyPathIterator.php
@@ -21,7 +21,7 @@ class PropertyPathIterator extends \ArrayIterator implements PropertyPathIterato
{
/**
* The traversed property path
- * @var PropertyPath
+ * @var PropertyPathInterface
*/
protected $path;

0 comments on commit 5cc6b24

Please sign in to comment.
Something went wrong with that request. Please try again.