Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a6b629

Browse files
committed
[Validator] removed deprecated methods
1 parent 925ecaf commit 2a6b629

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+230
-2896
lines changed

src/Symfony/Component/Validator/ClassBasedInterface.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Symfony/Component/Validator/ConstraintValidator.php

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
namespace Symfony\Component\Validator;
1313

14-
use Symfony\Component\Validator\Context\ExecutionContextInterface as ExecutionContextInterface2Dot5;
15-
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
16-
use Symfony\Component\Validator\Violation\LegacyConstraintViolationBuilder;
14+
use Symfony\Component\Validator\Context\ExecutionContextInterface;
1715

1816
/**
1917
* Base class for constraint validators.
@@ -50,51 +48,6 @@ public function initialize(ExecutionContextInterface $context)
5048
$this->context = $context;
5149
}
5250

53-
/**
54-
* Wrapper for {@link ExecutionContextInterface::buildViolation} that
55-
* supports the 2.4 context API.
56-
*
57-
* @param string $message The violation message
58-
* @param array $parameters The message parameters
59-
*
60-
* @return ConstraintViolationBuilderInterface The violation builder
61-
*
62-
* @deprecated since version 2.5, to be removed in 3.0.
63-
*/
64-
protected function buildViolation($message, array $parameters = array())
65-
{
66-
@trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
67-
68-
if ($this->context instanceof ExecutionContextInterface2Dot5) {
69-
return $this->context->buildViolation($message, $parameters);
70-
}
71-
72-
return new LegacyConstraintViolationBuilder($this->context, $message, $parameters);
73-
}
74-
75-
/**
76-
* Wrapper for {@link ExecutionContextInterface::buildViolation} that
77-
* supports the 2.4 context API.
78-
*
79-
* @param ExecutionContextInterface $context The context to use
80-
* @param string $message The violation message
81-
* @param array $parameters The message parameters
82-
*
83-
* @return ConstraintViolationBuilderInterface The violation builder
84-
*
85-
* @deprecated since version 2.5, to be removed in 3.0.
86-
*/
87-
protected function buildViolationInContext(ExecutionContextInterface $context, $message, array $parameters = array())
88-
{
89-
@trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
90-
91-
if ($context instanceof ExecutionContextInterface2Dot5) {
92-
return $context->buildViolation($message, $parameters);
93-
}
94-
95-
return new LegacyConstraintViolationBuilder($context, $message, $parameters);
96-
}
97-
9851
/**
9952
* Returns a string representation of the type of the value.
10053
*

src/Symfony/Component/Validator/ConstraintValidatorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Validator;
1313

14+
use Symfony\Component\Validator\Context\ExecutionContextInterface;
15+
1416
/**
1517
* @author Bernhard Schussek <[email protected]>
1618
*/

src/Symfony/Component/Validator/ConstraintViolation.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,6 @@ public function getMessageTemplate()
141141

142142
/**
143143
* {@inheritdoc}
144-
*
145-
* @deprecated since version 2.7, to be removed in 3.0.
146-
* Use getParameters() instead
147-
*/
148-
public function getMessageParameters()
149-
{
150-
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.7, to be removed in 3.0. Use the ConstraintViolation::getParameters() method instead.', E_USER_DEPRECATED);
151-
152-
return $this->parameters;
153-
}
154-
155-
/**
156-
* Alias of {@link getMessageParameters()}.
157144
*/
158145
public function getParameters()
159146
{
@@ -162,19 +149,6 @@ public function getParameters()
162149

163150
/**
164151
* {@inheritdoc}
165-
*
166-
* @deprecated since version 2.7, to be removed in 3.0.
167-
* Use getPlural() instead
168-
*/
169-
public function getMessagePluralization()
170-
{
171-
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.7, to be removed in 3.0. Use the ConstraintViolation::getPlural() method instead.', E_USER_DEPRECATED);
172-
173-
return $this->plural;
174-
}
175-
176-
/**
177-
* Alias of {@link getMessagePluralization()}.
178152
*/
179153
public function getPlural()
180154
{

src/Symfony/Component/Validator/ConstraintViolationInterface.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getMessage();
4646
* Returns the raw violation message.
4747
*
4848
* The raw violation message contains placeholders for the parameters
49-
* returned by {@link getMessageParameters}. Typically you'll pass the
49+
* returned by {@link getParameters}. Typically you'll pass the
5050
* message template and parameters to a translation engine.
5151
*
5252
* @return string The raw violation message.
@@ -60,10 +60,8 @@ public function getMessageTemplate();
6060
* that appear in the message template.
6161
*
6262
* @see getMessageTemplate()
63-
*
64-
* @deprecated since version 2.7, to be replaced by getParameters() in 3.0.
6563
*/
66-
public function getMessageParameters();
64+
public function getParameters();
6765

6866
/**
6967
* Returns a number for pluralizing the violation message.
@@ -80,10 +78,8 @@ public function getMessageParameters();
8078
* pluralization form (in this case "choices").
8179
*
8280
* @return int|null The number to use to pluralize of the message.
83-
*
84-
* @deprecated since version 2.7, to be replaced by getPlural() in 3.0.
8581
*/
86-
public function getMessagePluralization();
82+
public function getPlural();
8783

8884
/**
8985
* Returns the root element of the validation.

src/Symfony/Component/Validator/Constraints/GroupSequence.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Validator\Constraints;
1313

14-
use Symfony\Component\Validator\Exception\OutOfBoundsException;
15-
1614
/**
1715
* A sequence of validation groups.
1816
*

src/Symfony/Component/Validator/Constraints/Valid.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ class Valid extends Constraint
2424
{
2525
public $traverse = true;
2626

27-
/**
28-
* @deprecated since version 2.5, to be removed in Symfony 3.0.
29-
*/
30-
public $deep = true;
31-
3227
public function __construct($options = null)
3328
{
3429
if (is_array($options) && array_key_exists('groups', $options)) {
@@ -38,10 +33,6 @@ public function __construct($options = null)
3833
));
3934
}
4035

41-
if (is_array($options) && array_key_exists('deep', $options)) {
42-
@trigger_error('The "deep" option for the Valid constraint is deprecated since version 2.5 and will be removed in 3.0. When traversing arrays, nested arrays are always traversed. When traversing nested objects, their traversal strategy is used.', E_USER_DEPRECATED);
43-
}
44-
4536
parent::__construct($options);
4637
}
4738
}

src/Symfony/Component/Validator/Context/ExecutionContext.php

Lines changed: 4 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
namespace Symfony\Component\Validator\Context;
1313

1414
use Symfony\Component\Translation\TranslatorInterface;
15-
use Symfony\Component\Validator\ClassBasedInterface;
1615
use Symfony\Component\Validator\Constraint;
17-
use Symfony\Component\Validator\Constraints\Valid;
1816
use Symfony\Component\Validator\ConstraintViolation;
1917
use Symfony\Component\Validator\ConstraintViolationList;
18+
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
2019
use Symfony\Component\Validator\Mapping\MetadataInterface;
20+
use Symfony\Component\Validator\Mapping\MemberMetadata;
2121
use Symfony\Component\Validator\Mapping\PropertyMetadataInterface;
2222
use Symfony\Component\Validator\Util\PropertyPath;
2323
use Symfony\Component\Validator\Validator\ValidatorInterface;
24-
use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
2524
use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
2625

2726
/**
@@ -183,25 +182,8 @@ public function setConstraint(Constraint $constraint)
183182
/**
184183
* {@inheritdoc}
185184
*/
186-
public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null)
185+
public function addViolation($message, array $parameters = array())
187186
{
188-
// The parameters $invalidValue and following are ignored by the new
189-
// API, as they are not present in the new interface anymore.
190-
// You should use buildViolation() instead.
191-
if (func_num_args() > 2) {
192-
@trigger_error('The parameters $invalidValue, $plural and $code in method '.__METHOD__.' are deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED);
193-
194-
$this
195-
->buildViolation($message, $parameters)
196-
->setInvalidValue($invalidValue)
197-
->setPlural($plural)
198-
->setCode($code)
199-
->addViolation()
200-
;
201-
202-
return;
203-
}
204-
205187
$this->violations->add(new ConstraintViolation(
206188
$this->translator->trans($message, $parameters, $this->translationDomain),
207189
$message,
@@ -294,7 +276,7 @@ public function getGroup()
294276
*/
295277
public function getClassName()
296278
{
297-
return $this->metadata instanceof ClassBasedInterface ? $this->metadata->getClassName() : null;
279+
return $this->metadata instanceof MemberMetadata || $this->metadata instanceof ClassMetadataInterface ? $this->metadata->getClassName() : null;
298280
}
299281

300282
/**
@@ -313,103 +295,6 @@ public function getPropertyPath($subPath = '')
313295
return PropertyPath::append($this->propertyPath, $subPath);
314296
}
315297

316-
/**
317-
* {@inheritdoc}
318-
*/
319-
public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null)
320-
{
321-
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED);
322-
323-
if (func_num_args() > 2) {
324-
$this
325-
->buildViolation($message, $parameters)
326-
->atPath($subPath)
327-
->setInvalidValue($invalidValue)
328-
->setPlural($plural)
329-
->setCode($code)
330-
->addViolation()
331-
;
332-
333-
return;
334-
}
335-
336-
$this
337-
->buildViolation($message, $parameters)
338-
->atPath($subPath)
339-
->addViolation()
340-
;
341-
}
342-
343-
/**
344-
* {@inheritdoc}
345-
*/
346-
public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false)
347-
{
348-
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator() method instead.', E_USER_DEPRECATED);
349-
350-
if (is_array($value)) {
351-
// The $traverse flag is ignored for arrays
352-
$constraint = new Valid(array('traverse' => true, 'deep' => $deep));
353-
354-
return $this
355-
->getValidator()
356-
->inContext($this)
357-
->atPath($subPath)
358-
->validate($value, $constraint, $groups)
359-
;
360-
}
361-
362-
if ($traverse && $value instanceof \Traversable) {
363-
$constraint = new Valid(array('traverse' => true, 'deep' => $deep));
364-
365-
return $this
366-
->getValidator()
367-
->inContext($this)
368-
->atPath($subPath)
369-
->validate($value, $constraint, $groups)
370-
;
371-
}
372-
373-
return $this
374-
->getValidator()
375-
->inContext($this)
376-
->atPath($subPath)
377-
->validate($value, null, $groups)
378-
;
379-
}
380-
381-
/**
382-
* {@inheritdoc}
383-
*/
384-
public function validateValue($value, $constraints, $subPath = '', $groups = null)
385-
{
386-
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator() method instead.', E_USER_DEPRECATED);
387-
388-
return $this
389-
->getValidator()
390-
->inContext($this)
391-
->atPath($subPath)
392-
->validate($value, $constraints, $groups)
393-
;
394-
}
395-
396-
/**
397-
* {@inheritdoc}
398-
*/
399-
public function getMetadataFactory()
400-
{
401-
@trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the new Symfony\Component\Validator\Context\ExecutionContext::getValidator method in combination with Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED);
402-
403-
$validator = $this->getValidator();
404-
405-
if ($validator instanceof LegacyValidatorInterface) {
406-
return $validator->getMetadataFactory();
407-
}
408-
409-
// The ValidatorInterface extends from the deprecated MetadataFactoryInterface, so return it when we don't have the factory instance itself
410-
return $validator;
411-
}
412-
413298
/**
414299
* {@inheritdoc}
415300
*/

0 commit comments

Comments
 (0)