Skip to content

Commit f3478f9

Browse files
[3.0] Cleaning Form and Validator a bit more
1 parent 4067a5c commit f3478f9

File tree

15 files changed

+33
-310
lines changed

15 files changed

+33
-310
lines changed

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ class ExceptionHandler
3838

3939
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
4040
{
41-
if (false !== strpos($charset, '%')) {
42-
// Swap $charset and $fileLinkFormat for BC reasons
43-
$pivot = $fileLinkFormat;
44-
$fileLinkFormat = $charset;
45-
$charset = $pivot;
46-
}
4741
$this->debug = $debug;
4842
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
4943
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -845,136 +845,6 @@ public static function xpathLiteral($s)
845845
return sprintf('concat(%s)', implode($parts, ', '));
846846
}
847847

848-
/**
849-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
850-
*/
851-
public function attach($object, $data = null)
852-
{
853-
$this->triggerDeprecation(__METHOD__);
854-
855-
parent::attach($object, $data);
856-
}
857-
858-
/**
859-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
860-
*/
861-
public function detach($object)
862-
{
863-
$this->triggerDeprecation(__METHOD__);
864-
865-
parent::detach($object);
866-
}
867-
868-
/**
869-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
870-
*/
871-
public function contains($object)
872-
{
873-
$this->triggerDeprecation(__METHOD__);
874-
875-
return parent::contains($object);
876-
}
877-
878-
/**
879-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
880-
*/
881-
public function addAll($storage)
882-
{
883-
$this->triggerDeprecation(__METHOD__);
884-
885-
parent::addAll($storage);
886-
}
887-
888-
/**
889-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
890-
*/
891-
public function removeAll($storage)
892-
{
893-
$this->triggerDeprecation(__METHOD__);
894-
895-
parent::removeAll($storage);
896-
}
897-
898-
/**
899-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
900-
*/
901-
public function removeAllExcept($storage)
902-
{
903-
$this->triggerDeprecation(__METHOD__);
904-
905-
parent::removeAllExcept($storage);
906-
}
907-
908-
/**
909-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
910-
*/
911-
public function getInfo()
912-
{
913-
$this->triggerDeprecation(__METHOD__);
914-
915-
return parent::getInfo();
916-
}
917-
918-
/**
919-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
920-
*/
921-
public function setInfo($data)
922-
{
923-
$this->triggerDeprecation(__METHOD__);
924-
925-
parent::setInfo($data);
926-
}
927-
928-
/**
929-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
930-
*/
931-
public function offsetExists($object)
932-
{
933-
$this->triggerDeprecation(__METHOD__);
934-
935-
return parent::offsetExists($object);
936-
}
937-
938-
/**
939-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
940-
*/
941-
public function offsetSet($object, $data = null)
942-
{
943-
$this->triggerDeprecation(__METHOD__);
944-
945-
parent::offsetSet($object, $data);
946-
}
947-
948-
/**
949-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
950-
*/
951-
public function offsetUnset($object)
952-
{
953-
$this->triggerDeprecation(__METHOD__);
954-
955-
parent::offsetUnset($object);
956-
}
957-
958-
/**
959-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
960-
*/
961-
public function offsetGet($object)
962-
{
963-
$this->triggerDeprecation(__METHOD__);
964-
965-
return parent::offsetGet($object);
966-
}
967-
968-
/**
969-
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
970-
*/
971-
public function getHash($object)
972-
{
973-
$this->triggerDeprecation(__METHOD__, true);
974-
975-
return parent::getHash($object);
976-
}
977-
978848
/**
979849
* Filters the list of nodes with an XPath expression.
980850
*
@@ -1179,23 +1049,4 @@ private function createSubCrawler($nodes)
11791049

11801050
return $crawler;
11811051
}
1182-
1183-
private function triggerDeprecation($methodName, $useTrace = false)
1184-
{
1185-
$traces = array();
1186-
$caller = array();
1187-
1188-
if ($useTrace || defined('HHVM_VERSION')) {
1189-
$traces = debug_backtrace();
1190-
$caller = $traces[2];
1191-
}
1192-
1193-
// The SplObjectStorage class performs calls to its own methods. These
1194-
// method calls must not lead to triggered deprecation notices.
1195-
if (isset($caller['class']) && 'SplObjectStorage' === $caller['class']) {
1196-
return;
1197-
}
1198-
1199-
@trigger_error('The '.$methodName.' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
1200-
}
12011052
}

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,11 @@ public function configureOptions(OptionsResolver $resolver)
245245
return '';
246246
};
247247

248-
$placeholder = function (Options $options) {
248+
$placeholderDefault = function (Options $options) {
249249
return $options['required'] ? null : '';
250250
};
251251

252-
$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory) {
253-
if ($choiceList) {
254-
@trigger_error('The "choice_list" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', E_USER_DEPRECATED);
255-
256-
return $choiceList;
257-
}
258-
252+
$choiceListNormalizer = function (Options $options) use ($choiceListFactory) {
259253
if (null !== $options['choice_loader']) {
260254
return $choiceListFactory->createListFromLoader(
261255
$options['choice_loader'],
@@ -316,7 +310,7 @@ public function configureOptions(OptionsResolver $resolver)
316310
'preferred_choices' => array(),
317311
'group_by' => null,
318312
'empty_data' => $emptyData,
319-
'placeholder' => $placeholder,
313+
'placeholder' => $placeholderDefault,
320314
'error_bubbling' => false,
321315
'compound' => $compound,
322316
// The view data is always a string, even if the "data" option
@@ -330,7 +324,7 @@ public function configureOptions(OptionsResolver $resolver)
330324
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
331325
$resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer);
332326

333-
$resolver->setAllowedTypes('choice_list', array('null', 'Symfony\Component\Form\ChoiceList\ChoiceListInterface', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'));
327+
$resolver->setAllowedTypes('choice_list', array('null', 'Symfony\Component\Form\ChoiceList\ChoiceListInterface'));
334328
$resolver->setAllowedTypes('choices', array('null', 'array', '\Traversable'));
335329
$resolver->setAllowedTypes('choice_translation_domain', array('null', 'bool', 'string'));
336330
$resolver->setAllowedTypes('choices_as_values', 'bool');

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ public function configureOptions(OptionsResolver $resolver)
159159
'empty_data' => $emptyData,
160160
'trim' => true,
161161
'required' => true,
162-
'max_length' => null,
163-
'pattern' => null,
164162
'property_path' => null,
165163
'mapped' => true,
166164
'by_reference' => true,

src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public static function getSubscribedEvents()
3535
return array(FormEvents::POST_SUBMIT => 'validateForm');
3636
}
3737

38-
/**
39-
* @param ValidatorInterface $validator
40-
* @param ViolationMapperInterface $violationMapper
41-
*/
4238
public function __construct(ValidatorInterface $validator, ViolationMapperInterface $violationMapper)
4339
{
4440
$this->validator = $validator;

src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class FormTypeValidatorExtension extends BaseValidatorExtension
3333
*/
3434
private $violationMapper;
3535

36-
/**
37-
* @param ValidatorInterface $validator
38-
*/
3936
public function __construct(ValidatorInterface $validator)
4037
{
4138
$this->validator = $validator;

src/Symfony/Component/Form/FormFactory.php

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,11 @@ public function createForProperty($class, $property, $data = null, array $option
6161
*/
6262
public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array())
6363
{
64-
$name = null;
65-
$typeName = null;
66-
67-
if ($type instanceof ResolvedFormTypeInterface) {
68-
if (method_exists($type, 'getBlockPrefix')) {
69-
// As of Symfony 3.0, the block prefix of the type is used as
70-
// default name
71-
$name = $type->getBlockPrefix();
72-
} else {
73-
// BC
74-
$typeName = $type->getName();
75-
}
76-
} elseif ($type instanceof FormTypeInterface) {
77-
// BC
78-
$typeName = $type->getName();
79-
} elseif (is_string($type)) {
80-
// BC
81-
$typeName = $type;
82-
} else {
83-
throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface');
84-
}
85-
86-
if (null === $name) {
87-
if (false === strpos($typeName, '\\')) {
88-
// No FQCN - leave unchanged for BC
89-
$name = $typeName;
90-
} else {
91-
// FQCN
92-
$name = StringUtil::fqcnToBlockPrefix($typeName);
93-
}
64+
if (!is_string($type)) {
65+
throw new UnexpectedTypeException($type, 'string');
9466
}
9567

96-
return $this->createNamedBuilder($name, $type, $data, $options);
68+
return $this->createNamedBuilder(StringUtil::fqcnToBlockPrefix($type), $type, $data, $options);
9769
}
9870

9971
/**

src/Symfony/Component/Form/FormFactoryInterface.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ interface FormFactoryInterface
2121
*
2222
* @see createBuilder()
2323
*
24-
* @param string|FormTypeInterface $type The type of the form
25-
* @param mixed $data The initial data
26-
* @param array $options The options
24+
* @param string $type The type of the form
25+
* @param mixed $data The initial data
26+
* @param array $options The options
2727
*
2828
* @return FormInterface The form named after the type
2929
*
@@ -36,10 +36,10 @@ public function create($type = 'Symfony\Component\Form\Extension\Core\Type\FormT
3636
*
3737
* @see createNamedBuilder()
3838
*
39-
* @param string|int $name The name of the form
40-
* @param string|FormTypeInterface $type The type of the form
41-
* @param mixed $data The initial data
42-
* @param array $options The options
39+
* @param string|int $name The name of the form
40+
* @param string $type The type of the form
41+
* @param mixed $data The initial data
42+
* @param array $options The options
4343
*
4444
* @return FormInterface The form
4545
*
@@ -66,9 +66,9 @@ public function createForProperty($class, $property, $data = null, array $option
6666
/**
6767
* Returns a form builder.
6868
*
69-
* @param string|FormTypeInterface $type The type of the form
70-
* @param mixed $data The initial data
71-
* @param array $options The options
69+
* @param string $type The type of the form
70+
* @param mixed $data The initial data
71+
* @param array $options The options
7272
*
7373
* @return FormBuilderInterface The form builder
7474
*
@@ -79,10 +79,10 @@ public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Typ
7979
/**
8080
* Returns a form builder.
8181
*
82-
* @param string|int $name The name of the form
83-
* @param string|FormTypeInterface $type The type of the form
84-
* @param mixed $data The initial data
85-
* @param array $options The options
82+
* @param string|int $name The name of the form
83+
* @param string $type The type of the form
84+
* @param mixed $data The initial data
85+
* @param array $options The options
8686
*
8787
* @return FormBuilderInterface The form builder
8888
*
@@ -93,7 +93,7 @@ public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extens
9393
/**
9494
* Returns a form builder for a property of a class.
9595
*
96-
* If any of the 'max_length', 'required' and type options can be guessed,
96+
* If any of the 'required' and type options can be guessed,
9797
* and are not provided in the options argument, the guessed value is used.
9898
*
9999
* @param string $class The fully qualified class name

src/Symfony/Component/Form/Tests/FormFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function testCreateNamedBuilderThrowsUnderstandableException()
162162

163163
/**
164164
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
165-
* @expectedExceptionMessage Expected argument of type "string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface", "stdClass" given
165+
* @expectedExceptionMessage Expected argument of type "string", "stdClass" given
166166
*/
167167
public function testCreateThrowsUnderstandableException()
168168
{
@@ -182,7 +182,7 @@ public function testCreateUsesTypeNameIfTypeGivenAsString()
182182

183183
$resolvedType->expects($this->once())
184184
->method('createBuilder')
185-
->with($this->factory, 'TYPE', $options)
185+
->with($this->factory, 'type', $options)
186186
->will($this->returnValue($this->builder));
187187

188188
$this->builder->expects($this->any())

src/Symfony/Component/Form/Util/InheritDataAwareIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getChildren()
3434
}
3535

3636
/**
37-
*{@inheritdoc}
37+
* {@inheritdoc}
3838
*/
3939
public function hasChildren()
4040
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy