From 1c4f632f606b1a424ccaba6ef39d7e3c9720f9e7 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 24 May 2012 15:20:49 +0200 Subject: [PATCH] [Form] Fixed API docs and usage of FormBuilderInterface instead of FormBuilder --- .../Component/Form/DataMapperInterface.php | 19 +++++-- src/Symfony/Component/Form/Form.php | 8 +-- src/Symfony/Component/Form/FormFactory.php | 14 +++--- .../Component/Form/FormFactoryInterface.php | 49 ++++++++++--------- src/Symfony/Component/Form/FormInterface.php | 6 +-- .../Form/FormTypeExtensionInterface.php | 2 +- .../Form/FormTypeGuesserInterface.php | 13 +++-- .../Component/Form/FormTypeInterface.php | 2 +- 8 files changed, 64 insertions(+), 49 deletions(-) diff --git a/src/Symfony/Component/Form/DataMapperInterface.php b/src/Symfony/Component/Form/DataMapperInterface.php index 587a4abd78..75841865cd 100644 --- a/src/Symfony/Component/Form/DataMapperInterface.php +++ b/src/Symfony/Component/Form/DataMapperInterface.php @@ -11,15 +11,28 @@ namespace Symfony\Component\Form; +/** + * @author Bernhard Schussek + */ interface DataMapperInterface { /** - * @param dataClass $data - * @param array $forms + * Maps properties of some data to a list of forms. * - * @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported + * @param mixed $data Structured data. + * @param array $forms A list of {@link FormInterface} instances. + * + * @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported. */ function mapDataToForms($data, array $forms); + /** + * Maps the data of a list of forms into the properties of some data. + * + * @param array $forms A list of {@link FormInterface} instances. + * @param mixed $data Structured data. + * + * @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported. + */ function mapFormsToData(array $forms, &$data); } diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 5255ed8b24..3e99bb4f1a 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -955,13 +955,9 @@ class Form implements \IteratorAggregate, FormInterface } /** - * Creates a view. - * - * @param FormView $parent The parent view - * - * @return FormView The view + * {@inheritdoc} */ - public function createView(FormView $parent = null) + public function createView(FormViewInterface $parent = null) { if (null === $parent && $this->parent) { $parent = $this->parent->createView(); diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index f95fa7d173..fc199f4e17 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -109,7 +109,7 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function create($type, $data = null, array $options = array(), FormBuilder $parent = null) + public function create($type, $data = null, array $options = array(), FormBuilderInterface $parent = null) { return $this->createBuilder($type, $data, $options, $parent)->getForm(); } @@ -117,7 +117,7 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function createNamed($name, $type, $data = null, array $options = array(), FormBuilder $parent = null) + public function createNamed($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null) { return $this->createNamedBuilder($name, $type, $data, $options, $parent)->getForm(); } @@ -125,7 +125,7 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function createForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null) + public function createForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null) { return $this->createBuilderForProperty($class, $property, $data, $options, $parent)->getForm(); } @@ -133,7 +133,7 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function createBuilder($type, $data = null, array $options = array(), FormBuilder $parent = null) + public function createBuilder($type, $data = null, array $options = array(), FormBuilderInterface $parent = null) { $name = is_object($type) ? $type->getName() : $type; @@ -143,7 +143,7 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilder $parent = null) + public function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null) { if (!array_key_exists('data', $options)) { $options['data'] = $data; @@ -217,7 +217,7 @@ class FormFactory implements FormFactoryInterface } if (!$builder) { - throw new TypeDefinitionException(sprintf('Type "%s" or any of its parents should return a FormBuilder instance from createBuilder()', $type->getName())); + throw new TypeDefinitionException(sprintf('Type "%s" or any of its parents should return a FormBuilderInterface instance from createBuilder()', $type->getName())); } $builder->setTypes($types); @@ -239,7 +239,7 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null) + public function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null) { if (!$this->guesser) { $this->loadGuesser(); diff --git a/src/Symfony/Component/Form/FormFactoryInterface.php b/src/Symfony/Component/Form/FormFactoryInterface.php index 73aa7ffcae..6b242b3459 100644 --- a/src/Symfony/Component/Form/FormFactoryInterface.php +++ b/src/Symfony/Component/Form/FormFactoryInterface.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Form; +/** + * @author Bernhard Schussek + */ interface FormFactoryInterface { /** @@ -21,13 +24,13 @@ interface FormFactoryInterface * @param string|FormTypeInterface $type The type of the form * @param mixed $data The initial data * @param array $options The options - * @param FormBuilder $parent The parent builder + * @param FormBuilderInterface $parent The parent builder * * @return FormInterface The form named after the type * * @throws Exception\FormException if any given option is not applicable to the given type */ - function create($type, $data = null, array $options = array(), FormBuilder $parent = null); + function create($type, $data = null, array $options = array(), FormBuilderInterface $parent = null); /** * Returns a form. @@ -38,30 +41,30 @@ interface FormFactoryInterface * @param string|FormTypeInterface $type The type of the form * @param mixed $data The initial data * @param array $options The options - * @param FormBuilder $parent The parent builder + * @param FormBuilderInterface $parent The parent builder * * @return FormInterface The form * * @throws Exception\FormException if any given option is not applicable to the given type */ - function createNamed($name, $type, $data = null, array $options = array(), FormBuilder $parent = null); + function createNamed($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null); /** * Returns a form for a property of a class. * * @see createBuilderForProperty() * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * @param mixed $data The initial data - * @param array $options The options for the builder - * @param FormBuilder $parent The parent builder + * @param string $class The fully qualified class name + * @param string $property The name of the property to guess for + * @param mixed $data The initial data + * @param array $options The options for the builder + * @param FormBuilderInterface $parent The parent builder * * @return FormInterface The form named after the property * * @throws Exception\FormException if any given option is not applicable to the form type */ - function createForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null); + function createForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null); /** * Returns a form builder. @@ -69,13 +72,13 @@ interface FormFactoryInterface * @param string|FormTypeInterface $type The type of the form * @param mixed $data The initial data * @param array $options The options - * @param FormBuilder $parent The parent builder + * @param FormBuilderInterface $parent The parent builder * - * @return FormBuilder The form builder + * @return FormBuilderInterface The form builder * * @throws Exception\FormException if any given option is not applicable to the given type */ - function createBuilder($type, $data = null, array $options = array(), FormBuilder $parent = null); + function createBuilder($type, $data = null, array $options = array(), FormBuilderInterface $parent = null); /** * Returns a form builder. @@ -84,13 +87,13 @@ interface FormFactoryInterface * @param string|FormTypeInterface $type The type of the form * @param mixed $data The initial data * @param array $options The options - * @param FormBuilder $parent The parent builder + * @param FormBuilderInterface $parent The parent builder * - * @return FormBuilder The form builder + * @return FormBuilderInterface The form builder * * @throws Exception\FormException if any given option is not applicable to the given type */ - function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilder $parent = null); + function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null); /** * Returns a form builder for a property of a class. @@ -98,17 +101,17 @@ interface FormFactoryInterface * If any of the 'max_length', 'required' and type options can be guessed, * and are not provided in the options argument, the guessed value is used. * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * @param mixed $data The initial data - * @param array $options The options for the builder - * @param FormBuilder $parent The parent builder + * @param string $class The fully qualified class name + * @param string $property The name of the property to guess for + * @param mixed $data The initial data + * @param array $options The options for the builder + * @param FormBuilderInterface $parent The parent builder * - * @return FormBuilder The form builder named after the property + * @return FormBuilderInterface The form builder named after the property * * @throws Exception\FormException if any given option is not applicable to the form type */ - function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null); + function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null); /** * Returns a type by name. diff --git a/src/Symfony/Component/Form/FormInterface.php b/src/Symfony/Component/Form/FormInterface.php index 7e9557c73f..915ab19d9a 100644 --- a/src/Symfony/Component/Form/FormInterface.php +++ b/src/Symfony/Component/Form/FormInterface.php @@ -238,9 +238,9 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable /** * Creates a view. * - * @param FormView $parent The parent view + * @param FormViewInterface $parent The parent view * - * @return FormView The view + * @return FormViewInterface The view */ - function createView(FormView $parent = null); + function createView(FormViewInterface $parent = null); } diff --git a/src/Symfony/Component/Form/FormTypeExtensionInterface.php b/src/Symfony/Component/Form/FormTypeExtensionInterface.php index ab3ad6a4bb..b83cf02268 100644 --- a/src/Symfony/Component/Form/FormTypeExtensionInterface.php +++ b/src/Symfony/Component/Form/FormTypeExtensionInterface.php @@ -62,7 +62,7 @@ interface FormTypeExtensionInterface /** * Overrides the default options from the extended type. * - * @param OptionsResolver $resolver The resolver for the options. + * @param OptionsResolverInterface $resolver The resolver for the options. */ function setDefaultOptions(OptionsResolverInterface $resolver); diff --git a/src/Symfony/Component/Form/FormTypeGuesserInterface.php b/src/Symfony/Component/Form/FormTypeGuesserInterface.php index d38d4dc5fc..5750336020 100644 --- a/src/Symfony/Component/Form/FormTypeGuesserInterface.php +++ b/src/Symfony/Component/Form/FormTypeGuesserInterface.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Form; +/** + * @author Bernhard Schussek + */ interface FormTypeGuesserInterface { /** @@ -19,7 +22,7 @@ interface FormTypeGuesserInterface * @param string $class The fully qualified class name * @param string $property The name of the property to guess for * - * @return TypeGuess A guess for the field's type and options + * @return Guess\TypeGuess A guess for the field's type and options */ function guessType($class, $property); @@ -29,7 +32,7 @@ interface FormTypeGuesserInterface * @param string $class The fully qualified class name * @param string $property The name of the property to guess for * - * @return Guess A guess for the field's required setting + * @return Guess\Guess A guess for the field's required setting */ function guessRequired($class, $property); @@ -39,7 +42,7 @@ interface FormTypeGuesserInterface * @param string $class The fully qualified class name * @param string $property The name of the property to guess for * - * @return Guess A guess for the field's maximum length + * @return Guess\Guess A guess for the field's maximum length */ function guessMaxLength($class, $property); @@ -49,7 +52,7 @@ interface FormTypeGuesserInterface * @param string $class The fully qualified class name * @param string $property The name of the property to guess for * - * @return Guess A guess for the field's minimum length + * @return Guess\Guess A guess for the field's minimum length * * @deprecated Deprecated since version 2.1, to be removed in 2.3. */ @@ -67,7 +70,7 @@ interface FormTypeGuesserInterface * @param string $class The fully qualified class name * @param string $property The name of the property to guess for * - * @return Guess A guess for the field's required pattern + * @return Guess\Guess A guess for the field's required pattern */ function guessPattern($class, $property); } diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php index 55e4e5bb12..22f874c156 100644 --- a/src/Symfony/Component/Form/FormTypeInterface.php +++ b/src/Symfony/Component/Form/FormTypeInterface.php @@ -85,7 +85,7 @@ interface FormTypeInterface /** * Sets the default options for this type. * - * @param OptionsResolver $resolver The resolver for the options. + * @param OptionsResolverInterface $resolver The resolver for the options. */ function setDefaultOptions(OptionsResolverInterface $resolver);