Skip to content

Commit 3ec562d

Browse files
committed
merged branch bschussek/move-existence-constraints (PR #7701)
This PR was merged into the master branch. Discussion ---------- [Validator] Moved constraints Optional and Required to the Constraints\ namespace | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#2512 Commits ------- a868048 [Validator] Moved constraints Optional and Required to the Constraints\ namespace
2 parents 69a3458 + 504b3ae commit 3ec562d

37 files changed

+151
-24
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
2.3.0
5+
-----
6+
7+
* copied the constraints `Optional` and `Required` to the
8+
`Symfony\Component\Validator\Constraints\` namespace and deprecated the original
9+
classes.
10+
411
2.2.0
512
-----
613

Constraints/All.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/**
1818
* @Annotation
1919
*
20+
* @author Bernhard Schussek <[email protected]>
21+
*
2022
* @api
2123
*/
2224
class All extends Constraint

Constraints/Blank.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Blank extends Constraint

Constraints/Callback.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Callback extends Constraint

Constraints/Choice.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Choice extends Constraint

Constraints/Collection.php

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

1414
use Symfony\Component\Validator\Constraint;
15-
use Symfony\Component\Validator\Constraints\Collection\Required;
16-
use Symfony\Component\Validator\Constraints\Collection\Optional;
15+
use Symfony\Component\Validator\Constraints\Required;
16+
use Symfony\Component\Validator\Constraints\Optional;
1717
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1818

1919
/**
2020
* @Annotation
2121
*
22+
* @author Bernhard Schussek <[email protected]>
23+
*
2224
* @api
2325
*/
2426
class Collection extends Constraint

Constraints/Collection/Optional.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111

1212
namespace Symfony\Component\Validator\Constraints\Collection;
1313

14-
use Symfony\Component\Validator\Constraint;
14+
use Symfony\Component\Validator\Constraints\Optional as BaseOptional;
1515

1616
/**
1717
* @Annotation
18+
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
21+
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use
22+
* {@link \Symfony\Component\Validator\Constraints\Optional} instead.
1823
*/
19-
class Optional extends Constraint
24+
class Optional extends BaseOptional
2025
{
21-
public $constraints = array();
22-
23-
public function getDefaultOption()
24-
{
25-
return 'constraints';
26-
}
2726
}

Constraints/Collection/Required.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111

1212
namespace Symfony\Component\Validator\Constraints\Collection;
1313

14-
use Symfony\Component\Validator\Constraint;
14+
use Symfony\Component\Validator\Constraints\Required as BaseRequired;
1515

1616
/**
1717
* @Annotation
18+
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
21+
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use
22+
* {@link \Symfony\Component\Validator\Constraints\Required} instead.
1823
*/
19-
class Required extends Constraint
24+
class Required extends BaseRequired
2025
{
21-
public $constraints = array();
22-
23-
public function getDefaultOption()
24-
{
25-
return 'constraints';
26-
}
2726
}

Constraints/CollectionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\ConstraintValidator;
1616
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
17-
use Symfony\Component\Validator\Constraints\Collection\Optional;
17+
use Symfony\Component\Validator\Constraints\Optional;
1818

1919
/**
2020
* @author Bernhard Schussek <[email protected]>

Constraints/Count.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/**
1818
* @Annotation
1919
*
20+
* @author Bernhard Schussek <[email protected]>
21+
*
2022
* @api
2123
*/
2224
class Count extends Constraint

Constraints/Country.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Country extends Constraint

Constraints/Date.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Date extends Constraint

Constraints/DateTime.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class DateTime extends Constraint

Constraints/Email.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Email extends Constraint

Constraints/Existence.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Constraints;
13+
14+
use Symfony\Component\Validator\Constraint;
15+
16+
/**
17+
* @author Bernhard Schussek <[email protected]>
18+
*/
19+
abstract class Existence extends Constraint
20+
{
21+
public $constraints = array();
22+
23+
public function getDefaultOption()
24+
{
25+
return 'constraints';
26+
}
27+
}

Constraints/False.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class False extends Constraint

Constraints/File.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class File extends Constraint

Constraints/GroupSequence.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Annotation for group sequences
1616
*
1717
* @Annotation
18+
*
1819
* @author Bernhard Schussek <[email protected]>
1920
*
2021
* @api

Constraints/Ip.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Validates that a value is a valid IP address
1919
*
2020
* @Annotation
21+
*
2122
* @author Bernhard Schussek <[email protected]>
2223
* @author Joseph Bielawski <[email protected]>
2324
*

Constraints/Language.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Language extends Constraint

Constraints/Length.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/**
1818
* @Annotation
1919
*
20+
* @author Bernhard Schussek <[email protected]>
21+
*
2022
* @api
2123
*/
2224
class Length extends Constraint

Constraints/Locale.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Locale extends Constraint

Constraints/NotBlank.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class NotBlank extends Constraint

Constraints/NotBlankValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Validator\ConstraintValidator;
1616

1717
/**
18+
* @author Bernhard Schussek <[email protected]>
19+
*
1820
* @author Bernhard Schussek <[email protected]>
1921
*
2022
* @api

Constraints/NotNull.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class NotNull extends Constraint

Constraints/Null.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Null extends Constraint

Constraints/Optional.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Constraints;
13+
14+
/**
15+
* @Annotation
16+
*
17+
* @author Bernhard Schussek <[email protected]>
18+
*/
19+
class Optional extends Existence
20+
{
21+
}

Constraints/Range.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/**
1818
* @Annotation
1919
*
20+
* @author Bernhard Schussek <[email protected]>
21+
*
2022
* @api
2123
*/
2224
class Range extends Constraint

Constraints/Regex.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Regex extends Constraint

Constraints/Required.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Constraints;
13+
14+
/**
15+
* @Annotation
16+
*
17+
* @author Bernhard Schussek <[email protected]>
18+
*/
19+
class Required extends Existence
20+
{
21+
}

Constraints/Time.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Time extends Constraint

Constraints/True.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class True extends Constraint

Constraints/Type.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Type extends Constraint

Constraints/Url.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <[email protected]>
20+
*
1921
* @api
2022
*/
2123
class Url extends Constraint

0 commit comments

Comments
 (0)